HUD/mcl_hbarmor: Armor bar is hidden and unhidden in global step, causing server to send useless HUDUPDATE packets #111
Labels
No Label
blocker
bug
code quality
confirmed
critical
discussion
high priority
incompatibility
incomplete feature
invalid
low priority
missing feauture
needs testing
packet spam
performance
project
regression
translations
unconfirmed
in review
ready for review
No Milestone
No project
No Assignees
4 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#111
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?
What happened?
When the automatic hiding of the armor bar is enabled, it is is hidden or unhidden in each game tick, even if it was already hidden or unhidden.
This causes a ridiculous amount of unnecesary HUDUPDATE packets sent from the server to the client.
What did I expect?
I expected the armor bar to be only hidden or unhidden if the players armor state changed.
How to get it to happen
9f086a9242
create a new world with the singlenode mapgen.minetest --verbose 2>&1 >/dev/null |grep TOCLIENT_HUDCHANGE
.9f086a9242
.cmd 75 (TOCLIENT_HUDCHANGE) count
and a number.mods/HUD/mcl_hbarbor/init.lua
, change the linemcl_hbarmor.autohide = true
tomcl_hbarmor.autohide = false
.9f086a9242
with the change from step 8.cmd 75 (TOCLIENT_HUDCHANGE) count
and a number.Environment
Mineclonia Version:
9f086a9242
Minetest Version: some 5.5-dev (this likely does not matter)
This code from
HUD/mcl_hbarmor/init.lua
hides or unhides the armor bar:If I am right about this causing HUDUPDATE packet spam, setting
mcl_hbarmor.autohide
to something falsy should drastically reduce the rate of packets sent.HUD/mcl_hbarmor: Armor bar is hidden and unhidden in global step, causing HUDUPDATE packet spamto HUD/mcl_hbarmor: Armor bar is hidden and unhidden in global step, causing server to send useless HUDUPDATE packetsPacket count for step 6 (
mcl_hbarmor.autohide = true
): 1845Packet count for step 11 (
mcl_hbarmor.autohide = false
): 1500The packet count is for 30 seconds.
Edit: The difference is 345 packets in 30 s or 11.5 packets/s.
i can't really confirm this:
with autohide=true
with autohide=false:
i mean theres no question we got a hudchange problem but this doesnt seem to be it.
EDIT:
I'm getting a larger sample.
Ok so maybe there is something to it:
Samplesize 10 for
autohide=true:
Median: 2142
autohide=false
Median: 1530
If the difference @cora determined is even remotely accurate, the needless armor bar hiding and unhiding accounts for a full quarter of the HUDCHANGE spam.
I would expect 2 or 3 other interface elements to be implemented in a similar broken way.
I think this should just be turned off, with a TODO comment added to it.
Almost all the other HUDCHANGE spam is from the health and breath statbars.
Could HUDCHANGE spam be fixed by wrapping the hud API with something that doesn't call hud_change when a hud field isn't actually changed?
@anon5 I think the hud bars mod actually should do that, but it does not.
However, I also think that fixing the problem at the source is preferable.
I made a shell script I called
analyze-packet-spam
:Playing Mineclonia for 10 minutes with armor bar autohiding turned on yielded this:
Playing Mineclonia for 10 minutes with armor bar autohiding turned off yielded this:
Ideally, the Minetest engine wouldn't send HUDCHANGE packets if the field hasn't actually changed, because this would solve this problem for all Minetest games and mods.
I've opened an issue because I think this is the best solution, but a workaround could be used until this is implemented in the engine.
As a workaround, you could either make the hud bars mod not call hud_change when nothing has changed or wrap the HUD API.
I think this was fixed in the upstream hudbars mod in https://repo.or.cz/minetest_hudbars.git/commitdiff/a44de6230bcde79b78749bc6024a5ee8614bc6c0.
Thanks, @luk3yx! I tested this patch by Wuzzy and it removed the entire HUDUPDATE spam:
https://repo.or.cz/minetest_hudbars.git/patch/a44de6230bcde79b78749bc6024a5ee8614bc6c0
Now that PR #123 has been merged, I have rebased PR #122 to get a cleaner history.
I close this now because PR #122 was merged.