ScanForFunctions: Speed up game loading by only trying to insert the newly found functions into the symbol map. #12652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wondered why ScanForFunctions was so incredibly slow in debug, and the answer wasn't just all the std::map manipulation in g_symbolMap->AddFunction...
It's not very clear in the code (needs some renaming and cleanup) but
functions
is a global vector here and at the end of ScanForFunctions, we'd loop through the entire thing and add all of them to the symbol map. ScanForFunctions is often called many times during load due to lots of little sections in the binary (most of which actually don't contain functions, it turns out) so we ended up trying to add the same large vector of symbols many times.Now, we just try to add the newly found functions instead of all of the old ones again.
It's no longer somewhat painful to start big games in debug mode, and it is noticeably faster to start up games in general. I don't see how this could break anything, but @unknownbrackets might want a quick look?
(you'd think that the "foundInSymbolMap" thing would prevent this, but it didn't anticipate trying to add all the old symbols repeatedly, which won't have that flag...)