Pressure plates need to be more performant #3600
Labels
No Label
#P1 CRITICAL
#P2: HIGH
#P3: elevated
#P4 priority: medium
#P6: low
#Review
annoying
API
bug
code quality
combat
commands
compatibility
configurability
contribution inside
controls
core feature
creative mode
delayed for engine release
documentation
duplicate
enhancement
environment
feature request
gameplay
graphics
ground content conflict
GUI/HUD
help wanted
incomplete feature
invalid / won't fix
items
looking for contributor
mapgen
meta
mineclone2+
Minecraft >= 1.13
Minecraft >= 1.17
missing feature
mobile
mobs
mod support
model needed
multiplayer
Needs adoption
needs discussion
needs engine change
needs more information
needs research
nodes
non-mob entities
performance
player
possible close
redstone
release notes
schematics
Skyblock
sounds
Testing / Retest
tools
translation
unconfirmed
mcl5
mcla
Media missing
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: VoxeLibre/VoxeLibre#3600
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
MineClone2 version: master
What happened?
Pressure plates are quite expensive. When you have a few around, they can take 4% and locally, it was at 9.21%.
I think this is because the timer runs every 0.4 seconds, and it searches for players close by. I understand why we functionally do this and had some real issues with plates thinking they were pressed. What I am wondering is if we can change the distance searched, or the interval so it is less frequent.
I don't know if there is a reason it is 0.04, or could be higher say 0.2, or 0.25, or 0.5. It probably bare minimum needs to work for the minimum time a pressure plate is affected. This could reduce load by 75-80% potentially.
I have no idea what the best way to approach this is. @MrRar do you have any ideas, as you seem to be our resident pressure plate expert.
What should happen:
Pressure plates should work less frequently, but still function effectively.
Steps to reproduce
When profiling with pressure plates close by.
Some pressure plates also need to be triggered when items fall on them. Would it be a good trade-off for items landing on something to check if they fell on a pressure plate? The complicated(?) part here is that light/heavy weighted pressure plates need to be triggered based on how many entities/items are on them.
In the case of mobs and players, would collision checking with pressure plates be more expensive?
not to mention we are still missing 2 pressure plates left if there was a better way to implement them in heavy and light weighted pressure plates
I think any performance improvement will have to involve reducing the timer. However this will make it more likely that an object can pass over the pressure plate without triggering it. But there might be a way to optimize it without losing much functionality. For example, the pressure plates could have a slow timer most of the time but if they detect a moving entity nearby they could decrease the timer for the next server tick.
I will have to experiment.
I'm at a loss right now about how to test the performance of the pressure plates.
I had a world with 1024 pressure plates.
First I tried using jitprofile. I tried different values for the node timer. Below is the results. The first number is the node timer. The second number is the execution time percentage for pressure plates.
0.04: 21%
0.2: 22%
0.5: 31%
2: 18%
As you can see it's basically random. I think this might be because it's a percentage and not an absolute time. So whatever happens to be going on the world will have as much of an impact as the pressure plates themselves.
Next I tried Minetest's built-in profiler. But the pressure plates did not show up at all under that as far as I can tell.
Then I tried Minetest's built in time functions minetest.get_gametime() and minetest.get_us_time() but apparently they only update between server ticks.
I will see if there is anything else to try.
If anyone has any suggestions, that would be great.
What was taking up the performance? Was maploading happening at same time?
I may only have a handful of pressure plates and they should up, so this is weird.
How much will we lose. 0.04 seconds is 25 times a second. Even if it's 5 times a second, it should cover almost all cases. I cannot think of anything 0.25s, I cannot see a situation in which it not triggering would be a big deal.
The performance issue as I see it is far too frequent looking around. Looking for nodes or entities near by is very cpu intensive.
I will post the SVG files I made tomorrow.
Default server tick is 0.09 so that would allow 11 times a second at the most. The node timer never runs more than one time per node per tick.
It's good to have them as reliable as possible. I think the timer can be increased without losing much reliability. Reliability can be tested. But I can't test the performance. Maybe increasing the timer has no substantial impact on performance for some reason. Since I don't have any data you might just have to increase the timer and hope for the best.
local PRESSURE_PLATE_INTERVAL = 0.04
I'm happy with that, I just didn't know if increasing timer meant I had to change other times too. I don't know how the total times are stored or calculated.
I acknowledge the timer is 0.04. But I assert that it actually can't run more frequently than the server tick which is 0.09 by default.
Just change PRESSURE_PLATE_INTERVAL and your good.
I have attached the SVG files a made using jitprofiler
That is some weird results? I would have expected different (higher time bringing lower effect). How about 30 or so plates? Any more than probably won't happen frequently.
I tried 9 and it did not show up on the SVG at all. Then I tried 49 plates. I have attached the SVG files. No pattern to it.