Get neighbor from same map block if possible in ABMHandler #4998
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 noticed that when I use the Technic mod and a larg'ish
active_block_range
- 7 or 8 in my case - I see messages like these:2017-01-05 21:55:04: WARNING[Server]: active block modifiers took 623ms (longer than 200ms)
Without actually doing anything. Turns out that the time is spent in the required neighbor check.
Looking at the code one can observe that the majority of the neighbors of the nodes are actually found in the very map block that we already have a reference to; so use that one to get the neighorhing map node instead of going back to getting the mapnode via map->sector->mapblock->mapnode.
That brought the max down from 623ms to to 223ms. And the average from about 490ms to 210ms.