Skip to content

perf(resources): change-gate ResourceEvent sends to stop per-tick spam - #2885

Merged
Z1Meme merged 1 commit into
devfrom
perf/resource-event-throttle
Aug 24, 2026
Merged

Z1Meme merged 1 commit into
devfrom
perf/resource-event-throttle

Conversation

@Z1Meme

@Z1Meme Z1Meme commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

server.updateResource and updateResourceToAllWithSpawnedEntity sent a ResourceEvent every call with no comparison to the last value sent, so the 3s resource tick re-sent decaying resources (hunger/hydration/endurance/comfort, and virus via virusBurnTick) every tick even though the raw change was too small to move the client-displayed bar.

Track the last-sent value per resource on the character and only emit when the client- displayed value would change: quantize to permille of the resource MAX_VALUE, and always emit exact empty/full transitions. Non-player entities (vehicles/doors/construction) are never gated, so their behavior is unchanged. The cache is reset in resetResources so respawn/resync always resends; a freshly-created character starts with an empty cache.

Net: a steady-state character emits ~0 ResourceEvents; real changes (damage, eating, drinking, healing, decay crossing a visible step) still send. Permille granularity is a conservative floor pending RE confirmation of the client's real bar resolution.

server.updateResource and updateResourceToAllWithSpawnedEntity sent a ResourceEvent every
call with no comparison to the last value sent, so the 3s resource tick re-sent decaying
resources (hunger/hydration/endurance/comfort, and virus via virusBurnTick) every tick even
though the raw change was too small to move the client-displayed bar.

Track the last-sent value per resource on the character and only emit when the client-
displayed value would change: quantize to permille of the resource MAX_VALUE, and always
emit exact empty/full transitions. Non-player entities (vehicles/doors/construction) are
never gated, so their behavior is unchanged. The cache is reset in resetResources so
respawn/resync always resends; a freshly-created character starts with an empty cache.

Net: a steady-state character emits ~0 ResourceEvents; real changes (damage, eating,
drinking, healing, decay crossing a visible step) still send. Permille granularity is a
conservative floor pending RE confirmation of the client's real bar resolution.
@github-actions github-actions Bot added the client-2016 About the 2016 client label Aug 23, 2026
@Z1Meme
Z1Meme requested a review from johnoclockdk August 24, 2026 03:33
@Z1Meme
Z1Meme merged commit bb1f627 into dev Aug 24, 2026
18 checks passed
@Z1Meme
Z1Meme deleted the perf/resource-event-throttle branch August 24, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-2016 About the 2016 client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants