perf: serialize identical broadcasts once (deferred — invisible at friends scale) #52
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo#52
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
From the code-review performance pass (its only actionable item).
WebSocketConnection.SendAsyncserializes the message per call, so an identical broadcast to N nearby listeners (Swing / Attacked / PlayerDied / PlayerResurrected / PlayerSaid) is serialized + allocated N times.Deferred deliberately: at the target scale (tens of players clustered) this is microseconds and negligible Gen0 garbage — the perf reviewer flagged it as the one worth doing eventually but explicitly invisible now, and it adds send-path plumbing (a pre-serialized-bytes path on
IClientConnection+ the test fake). Per the project's right-size-performance principle, not worth the churn yet.When to do it: if player counts or broadcast frequency ever grow enough to show GC pressure.
Scope (when picked up)
ReadOnlyMemory<byte>send path toIClientConnection/WebSocketConnection(enqueue pre-serialized bytes).ConnectionManager.SendToManyAsync(ids, message)serializes once, sends the same buffer to all.Definition of Done
Reconfirmed by this session's critical performance review: at friends scale this is genuinely fine-as-is (a handful of observers = a handful of tiny JSON encodes per event, GC-trivial at a 100ms tick). The DTO object graph is already built once per event; only the final JSON+UTF8 encoding is per-recipient. Fix path when it ever matters: encode the frame to a byte[] once in WorldTick and hand the pre-encoded bytes to each connection (a SendRaw(byte[]) path). Staying deferred.