perf: lazy load MGUMatch/MGUGame fields#7610
Conversation
mbergen
left a comment
There was a problem hiding this comment.
Can you test how this affects MatchTable? IIRC that's also using this.
|
|
While I like the approach, since so many m2g will need to be loaded, it may be worth batching them rather than going back and forth with the database. While the Lua time difference is negligible, the real-time difference can add up. Also, we need to look at not loading the m2g extradata field to reduce memory further |
because lazy loading is implemented through
that part is already included Lua-Modules/lua/wikis/commons/MatchGroup/Util.lua Lines 586 to 613 in 9d24c8a |
9d24c8a to
5decb63
Compare
There was a problem hiding this comment.
won't this increase runtime for anything that needs to access game extradata fields?
it needs to spin up a new mw.ext.LiquipediaDB.lpdb for every time it needs to access extradata of a game (the first time per game)
(same concern for other fileds for which you spin up an additional mw.ext.LiquipediaDB.lpdb)
maybe an option param to tell it that it needs to query them with the original mw.ext.LiquipediaDB.lpdb call?
depends; if you fetch all the relevant fields from
|
aa434e3 to
d46fe40
Compare
If we take standings as an example, it will most of the time require m2g, but not m2g.extradata. But because we cannot control which m2g fields we query, we will receive all of them, including extradata, if we fetch m2g. This is obviously a problem in the linked ticket, which is why it's split up here. However, because we will (always?) need the m2g info, it would be advantageous to batch all the m2g queries (without extradata retrieval) into a single query, rather than running them one by one. |
not for swiss; matches tiebreakers only need m2 (though you need m2o regardless) and games tiebreakers rely on scores stored in m2o (#6720). iirc you only need m2g for rounds tiebreakers I don't recall what the situation is for ffastandings 🤷 |
|
Mm ok |
| vod = nilIfEmpty(record.vod), | ||
| walkover = walkover and walkover:lower() or nil, | ||
| winner = tonumber(record.winner), | ||
| record = record, |
There was a problem hiding this comment.
I would prefer not to keep the entire record in memory, especially when it's not needed. This can easily cause duplication of data in memory (eg. we fetch with m2g and then access it), which can be very painful on some wikis. Can we optimize this to only store data we need later, and clean up information no longer needed?
|
I'm a little concerned at the only 10% memory saving too. |
Summary
See #7398 for context.
Some fields in MGUMatch/MGUGame are not used in certain contexts, e.g., a lot of
extradatafields inMGUGameare not needed during match results processings in standings tables. This PR adds lazy loading to such fields to reduce overall memory consumption.How did you test this change?
https://liquipedia.net/valorant/User:ElectricalBoy/Sandbox2