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.
This PR tries to grab some of the low hanging fruit for ways to improve CPU performance for larger render distances. Based on profiling I've done on my end, these are likely the easiest performance improvements we can make, and larger performance improvements would likely require more work.
This PR has two changes to make metrics easier to use and two changes that improve performance:
Metrics:
Performance:
traversal::nearby_nodes
are reused so that they only have to run once per frameAs for what this did, here are some very rough metrics for a render distance of 120:
Before:
After:
This is over a 3x improvement. The game feels laggy but playable, especially if the server tick rate is reduced to 10 (since
ensure_nearby
is not optimized).I expect that in the future, we will want to work towards a smarter data structure, one that doesn't require us to walk the graph every frame (which involves quite a few floating point operations and random memory access). With enough work, I'm hopeful that we can get Hypermine to be GPU-bottlenecked.
However, for now, I'm satisfied with these performance improvements.