performance: optimize entity packet broadcasting#2803
Open
Conversation
80b30e8 to
060e558
Compare
- Add snapshot caching for entity stats, vitals, statuses and player equipment - Cache per-(player,npc) aggression to skip unchanged NpcAggressionPacket sends - Cache per-(player,map) visible map-items hash to avoid regenerating identical MapItemsPacket data - Skip redundant broadcasts when cached state matches current values - Clear all snapshots when entities leave map/layer/instance (including player/npc aggression) - Batch vital and status updates to only include entities with actual changes - Equipment broadcasts now only send when items change These changes significantly reduce network bandwidth and server CPU in high-entity scenarios (raids, events, crowded maps) by eliminating unnecessary/duplicate packet transmissions to clients while preserving first-send guarantees and correctness. Behavior is fully backwards-compatible; clients see the same game state with less packet noise and lower latency impact from server-side broadcasting.
060e558 to
3a2d944
Compare
pandinocoder
reviewed
Feb 3, 2026
Member
pandinocoder
left a comment
There was a problem hiding this comment.
How does the cache interact with clients connecting after the cache is established? Does the cache get hit there and skip sending values to them?
Does the cache properly clear when NPCs and players die/spawn/connect/disconnect?
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
Contributor
Author
When clients connect:
The cache is cleared via:
|
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.
performance: optimize packet broadcasting by caching entity snapshots
These changes significantly reduce network bandwidth and server CPU in high-entity scenarios (raids, events, crowded maps) by eliminating unnecessary/duplicate packet transmissions to clients while preserving first-send guarantees and correctness. Behavior is fully backwards-compatible; clients see the same game state with less packet noise and lower latency impact from server-side broadcasting.