-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Map memory speedup #27457
Merged
ZhilkinSerg
merged 2 commits into
CleverRaven:master
from
kevingranade:map-memory-speedup
Jan 13, 2019
Merged
Map memory speedup #27457
ZhilkinSerg
merged 2 commits into
CleverRaven:master
from
kevingranade:map-memory-speedup
Jan 13, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mlangsdorf
added
Code: Performance
Performance boosting code (CPU, memory, etc.)
[C++]
Changes (can be) made in C++. Previously named `Code`
Mechanics: Map Memory
Performance issues, weird behavior, improvements to map memory feature
labels
Jan 6, 2019
kevingranade
force-pushed
the
map-memory-speedup
branch
3 times, most recently
from
January 7, 2019 00:14
95358c4
to
dc85994
Compare
Tested in a debug build. Hoooooooleeeeeeeshiiiiittttt it's slow without this. |
kevingranade
force-pushed
the
map-memory-speedup
branch
2 times, most recently
from
January 7, 2019 07:48
6322aae
to
7e53984
Compare
Nominally done now, though haven't tested the tiles support yet.
|
If this helps take some weight off of my and others' CPU's while playing, then I this should be added ASAP! |
jbytheway
reviewed
Jan 7, 2019
kevingranade
force-pushed
the
map-memory-speedup
branch
from
January 8, 2019 08:33
333526d
to
ca042eb
Compare
kevingranade
force-pushed
the
map-memory-speedup
branch
from
January 10, 2019 05:08
6a0107e
to
e8e8389
Compare
This was referenced Jan 24, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Performance
Performance boosting code (CPU, memory, etc.)
Mechanics: Map Memory
Performance issues, weird behavior, improvements to map memory feature
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.
Summary
SUMMARY: Performance "Only memorize map features the first time they are seen"
Purpose of change
Currently map memory consumes approximately 1.5% of the game's overall CPU utilization just memorizing tiles. The reason for this is every turn it re-memorizes every tile in sight (up to 14,641 tiles, not counting other-z-level tiles!), making a not-that-expensive operation problematically slow. Worse, in debug mode it consumes many times this much time because of the use of debug containers. With this cache, this full-screen memorization can only occur upon changing z-levels, and thereafter can only trigger a number of memorizations equal to the new tiles seen in a turn.
Describe the solution
Added a cache of which tiles have been seen since their most recent load, and only memorize the tile if it has not been seen before.
Initial perf testing indicates that in release builds the overhead from map memorization has become immeasurably small. The new caching logic likewise does not appear in profiling.
Describe alternatives you've considered
Reverse tile memorization to only occur when tiles move out of sight instead of when they first become visible. This is more correct, but the caching logic to do this is much more complicated and potentially expensive than the approach in this PR.
TODO