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
[no sq] Server/env optimizations #14582
Conversation
7fe51fb
to
a193f95
Compare
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.
Initial code review. Looks good so far.
for (std::vector<ChangingLight>::const_iterator it = lights.begin(); | ||
it < lights.end(); ++it) { | ||
const auto &lights = light_sources.lights[i]; | ||
for (auto it = lights.begin(); it < lights.end(); ++it) { |
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.
Range-based for
loop would be possible now. Same for the other occurrences.
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.
I opted to not touch this code too much because it looked non-trivial.
Due to how node data is stored iterating X last provides better cache locality.
Since this is fixed overhead for every entity, this is important to optimize. This optimizes one very common case. before: push_collision_move_result [us] _____________ 64512x 3.562 after: push_collision_move_result [us] _____________ 72636x 0.831
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.
Works on my machine.
I profiled a bit and optimized some functions
"Optimize pushing collision data for entity on_step" -> a good test case is dropping lots of items
(hint: use worldedit to place grass_2 in the air and then punch one)
"Reduce wasteful memory allocations in update_lighting_nodes()" -> this is obvious when you look at the flamegraph for a mod that uses
remove_node
a lot, e.g. worldedits//drain