Skip to content
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

Merged
merged 5 commits into from May 3, 2024
Merged

[no sq] Server/env optimizations #14582

merged 5 commits into from May 3, 2024

Conversation

sfan5
Copy link
Member

@sfan5 sfan5 commented Apr 23, 2024

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

Copy link
Member

@SmallJoker SmallJoker left a 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.

src/voxelalgorithms.cpp Show resolved Hide resolved
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) {
Copy link
Member

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.

Copy link
Member Author

@sfan5 sfan5 Apr 27, 2024

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.

@sfan5 sfan5 changed the title Server/env optimizations [no sq] Server/env optimizations May 2, 2024
sfan5 added 5 commits May 2, 2024 12:16
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
Copy link
Member

@SmallJoker SmallJoker left a 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.

@sfan5 sfan5 merged commit 9c3c286 into minetest:master May 3, 2024
15 checks passed
@sfan5 sfan5 deleted the branch2304 branch May 3, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants