-
Notifications
You must be signed in to change notification settings - Fork 118
perf(mapcache): Simplify and improve implementation of MapCache to prevent expensive reoccurring redundant map cache reads #1775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…event expensive reoccurring redundant map cache reads
Mauller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, only a few points to help clear up the logic.
| TheFileSystem->createDirectory(mapDir); | ||
|
|
||
| filepath.concat(m_mapCacheName); | ||
| FILE *fp = fopen(filepath.str(), "w"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are rewriting this, should we make use of the game file system like we did with the recorder class instead of raw C file handling? It might make some of the file handling a bit cleaner.
could be someting for a followup PR at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe yes. I did not specifically touch the file handling stuff, just nearby code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that as a follow up PR.
Mauller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me now, could probably be more optimised in the future but the current gains in performance are pretty decent from the current refactor.
|
Some things could be moved out of the update function into init function. Replicated in Generals without conflicts. |
This change simplifies and improves the implementation of MapCache to prevent expensive reoccurring redundant map cache reads. It also removes DEBUG_LOG in
buildMapListForNumPlayersbecause it is a spammy log that adds stalling.Originally, the implementation in
MapCache::updateCachewas a total munkee disaster. Very complicated and inefficient. This change turned out to be half refactor, half performance optimization.Problems in MapCache were:
MapCache::updateCache, even if already loadedMapCache::loadUserMapsTheGlobalData->m_buildMapCachestd::map<AsciiString, Bool> m_seenAll this is fixed.
Performance measurement
Measured in optimized vs2022 build, with RTS_DEBUG.
TODO