Suppress forwarding of redundant identical SetHealth packets to controlling clients#310
Open
iiroak wants to merge 1 commit into
Open
Suppress forwarding of redundant identical SetHealth packets to controlling clients#310iiroak wants to merge 1 commit into
iiroak wants to merge 1 commit into
Conversation
…olling clients Servers such as 2b2t send ClientboundSetHealthPacket every tick even when health/food/saturation are unchanged. GrimAC emits a transaction sandwich for every SetHealth it sends, so forwarding these 1:1 roughly doubles the transaction rate and delivers transactions in bursts, corrupting Grim's movement clock and producing constant Simulation/Timer setbacks. This is mostly invisible to human players but makes automated/pathfinding clients crawl or get stuck in a setback loop. Still update the player cache and fire events for every packet, but only forward a SetHealth to connected client(s) when health/food/saturation actually change compared to the last one forwarded. Newly connected clients receive their current health via the login cache sync (EntityPlayer#addPackets), so nothing observable changes client-side. Fixes rfresh2#309
Owner
|
i dont observe spammy sethealth packet behavior on 2b2t, nor a local server running open source grim seems more like an issue for your "Automated/pathfinding clients" to solve i feel like you may be confusing something. like for example the lower your ping the more frequently you are sent ping transactions. or that your health/food/saturation is indeed changing slightly every tick. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #309.
Problem
Servers like 2b2t send
ClientboundSetHealthPacketon (nearly) every tick even when health/food/saturation are unchanged. When a client is controlling the proxy on a GrimAC server, these are forwarded 1:1 to the controller. GrimAC emits a transaction (ClientboundPing) sandwich for everySetHealth, so this roughly doubles the transaction rate and delivers transactions in bursts, corrupting Grim's movement clock and producing constantSimulation/Timersetbacks.Human players barely notice. Automated/pathfinding clients crawl at a fraction of normal speed or get stuck in a setback loop, since they can't absorb constant sub-block rewinds.
Change
SetHealthHandlerstill updates the cache and firesPlayerHealthChangedEventfor every packet (viaapplyAsync, unchanged), but now overridesapplyto only forward aSetHealthto connected client(s) when health/food/saturation actually differ from the last one forwarded. Returningnulldrops the redundant packet from the forward path inClientSession#callPacketReceived.A freshly connected controller still receives its current health via the login cache sync (
EntityPlayer#addPackets), so nothing observable changes client-side — only the redundant per-tick stream is dropped. The dedup state lives on the client session's netty thread (whereapplyruns), so no synchronization is needed.Testing
Built as a shadowJar and run on two live instances against a 1.21.4 GrimAC backend, same account/route:
SetHealthto client (idle)SimulationsetbacksTimersetbacksNote
I wasn't sure whether the 1:1 forwarding is intentional, so I kept the change minimal and conservative (drop only byte-for-byte-identical consecutive packets). If you'd prefer this gated behind a config flag, happy to adjust. See #309 for the full investigation.