-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add Active Object Spatial Cache #14643
Open
ExeVirus
wants to merge
3
commits into
minetest:master
Choose a base branch
from
ExeVirus:feature/exevirus_optimize_server_object_lookups
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Active Object Spatial Cache #14643
ExeVirus
wants to merge
3
commits into
minetest:master
from
ExeVirus:feature/exevirus_optimize_server_object_lookups
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
appgurueu
reviewed
May 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gave it a quick look
9659ff0
to
6f0c224
Compare
appgurueu
reviewed
May 19, 2024
138beb3
to
f0d41f6
Compare
f0d41f6
to
7e504cb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 adds a simple cache to server active objects (SAOs) based on position. This PR was made to solve the problem outlined in #14613, hoping to improve by orders of magnitude our ability to handle more entities in Minetest, and to make more performant ways to get objects in a given area/radius.
This directly addresses section 2.4 of the current roadmap for minetest. It specifically calls out the old version of the issue this task tries to address.
The implementation is best described as a single-layer of buckets implemented using unordered_multimap, which is a fancy term for "It's sorts entities into buckets the same size as mapblocks (16x16x16)". When you ask for entities in a given area/radius, this map allows you to filter out the vast majority of irrelevant entities.
Performance:
Areas where the cache is integrated in this PR:
Builtin Benchmarking
To do: Done
How to test
benchmarking:
Stability/Correctness
Stable and Validated
I have done extensive testing using a pseudorandom test function that tests insertion and removal of SAO's during iteration through SAOs, as well as testing inRadius and inArea checks and moving all found entities, and veriified that master and this branch have identical results for all steps after 20x200 iterations of 1000 entities. That function for your review is here Note that I am not advocating its inclusion; it's only useful for this one core change and not much thereafter.
Slight Difference compared to master
Using this new spatial map, when we iterate over entities during an inArea or inRadius search, it is now possible for some (not all) entities that are added during iteration to be found within the current search iteration. Future work may want to take this some steps further to guarantee all added objects are checked for the current search iteration, and that may be a solution to #14614. That is future work, however.