Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Nov 2, 2025

This change simplifies and improves the implementation of MapCache to prevent expensive reoccurring redundant map cache reads. It also removes DEBUG_LOG in buildMapListForNumPlayers because it is a spammy log that adds stalling.

Originally, the implementation in MapCache::updateCache was a total munkee disaster. Very complicated and inefficient. This change turned out to be half refactor, half performance optimization.

Problems in MapCache were:

  • Standard and User Map Cache INI loaded on every call to MapCache::updateCache, even if already loaded
  • Too much different logic cramped into MapCache::loadUserMaps
  • Overcomplicated logic around TheGlobalData->m_buildMapCache
  • Overcomplicated and inefficient logic around std::map<AsciiString, Bool> m_seen
  • Standard Maps Cache built in two code paths
  • Standard Maps Cache built after existing Cache was already loaded, causing poisened Map Cache generation

All this is fixed.

Performance measurement

Measured in optimized vs2022 build, with RTS_DEBUG.

Map List Click Original Time Optimized Time (This Change)
System Maps 203 ms 62 ms
User Maps 313 ms 62 ms

TODO

  • Replicate in Generals

…event expensive reoccurring redundant map cache reads
@xezon xezon added GUI For graphical user interface Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals GUI For graphical user interface Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant