Perf: Gateway broadcast clones payload per recipient; unregister scans all channels #85
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom#85
Loading…
Add table
Add a link
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?
Category: Performance — found in code review 2026-07-07.
Problem
server/src/gateway/registry.rs:76—broadcast_to_channel/send_to_user/broadcast_alldosender.send(payload.to_string())inside the loop: one heap allocation of the same JSON per recipient. A busy channel with N subscribers = N copies. The read lock is also held across all N allocations.Related:
unregister(registry.rs:51) scans every channel's subscription set on each disconnect (O(channels)), even channels the connection never joined.Fix
Arc<str>(orArc<String>); build the payload once, clone the pointer per recipient.unregisteronly touches relevant channels.