Mitigate overhead of walking all loaded submaps for vehicle processing. #36913
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.
The code is inappropriately walking all loaded submaps in order to process vehicle power production and consumption.
This mitigates the overhead by skipping most of the processing in the common case when a submap has no vehicle.
Summary
SUMMARY: Bugfixes "Mitigate out of control vehicle processing overhead."
Purpose of change
As reported in #36453 the game is suffering from increasing per-turn overhead the more map area is explored between saves.
The cause of this is this chunk of code that updates idle state.
Cataclysm-DDA/src/game.cpp
Lines 1520 to 1531 in 64b5e04
Describe the solution
This partially mitigates the problem by doing a very cheap check to skip most (I think about 80%) of the overhead caused by this issue, the remaining work is simply iterating over the tree.
Describe alternatives you've considered
I need to completely replace this mechanism with a list of vehicles on the map plus vehicles connected to them, which will not scale in the same way.
Testing
Insure vehicles are still processed, i.e. fuel and battery consumption.