Optimize finding lightning rods #4665

Open
teknomunk wants to merge 1 commits from optimize-lightning into master
Member

Superceds #4230

Optimize lightning strike handling with respect to lightning rods. Previously mcl_lightning_rods was using a minetest.find_nodes_near() call with a 256x256x256 block search area, which caused significant server lag for the lookup.

This branch replaces that call with an index check of lightning attractors in 64x64x64 block cubes, which is much quicker and doesn't have to inspect nodes that aren't attractors.

This also adds a log warning for server lag greater than 110 ms into the global step handler in mcl_player.

MineClone2/MineClone2#4228

Testing

  1. Checkout this branch.
  2. Place a lightning rod
  3. Use /lightning to cause a lightning strike nearby
  4. Verify the lightning strikes the rod
  5. Verify there are no log messages about server lag that always occur with the lightning strike.
  6. Inspect mod_storage.sqlite with "SELECT * FROM entries WHERE modname='mcl_lightning_rods';" and verify at least one entry appears (the location of the lightning rod placed in step 2).
Superceds #4230 Optimize lightning strike handling with respect to lightning rods. Previously mcl_lightning_rods was using a minetest.find_nodes_near() call with a 256x256x256 block search area, which caused significant server lag for the lookup. This branch replaces that call with an index check of lightning attractors in 64x64x64 block cubes, which is much quicker and doesn't have to inspect nodes that aren't attractors. This also adds a log warning for server lag greater than 110 ms into the global step handler in mcl_player. ### Related issues https://git.minetest.land/MineClone2/MineClone2/issues/4228 ### Testing 1. Checkout this branch. 2. Place a lightning rod 3. Use /lightning to cause a lightning strike nearby 4. Verify the lightning strikes the rod 5. Verify there are no log messages about server lag that always occur with the lightning strike. 6. Inspect mod_storage.sqlite with "SELECT * FROM entries WHERE modname='mcl_lightning_rods';" and verify at least one entry appears (the location of the lightning rod placed in step 2).
teknomunk added this to the 1 - Now milestone 2024-09-28 17:26:20 +02:00
teknomunk added the
nodes
Testing / Retest
code quality
performance
#P3: elevated
environment
labels 2024-09-28 17:26:20 +02:00
teknomunk added 1 commit 2024-09-28 17:26:21 +02:00
teknomunk modified the milestone from 1 - Now to 0.89.0 2024-10-01 15:19:58 +02:00
First-time contributor

Seems to work as intended? I don't see anything out of the ordinary when running it at least. The entry appears in the mod_storage.sqlite as well, so yeah 👍

Seems to work as intended? I don't see anything out of the ordinary when running it at least. The entry appears in the mod_storage.sqlite as well, so yeah 👍
teknomunk force-pushed optimize-lightning from b64f7c81b2 to 2c3659b355 2024-11-14 14:59:49 +01:00 Compare
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#4665
No description provided.