Skip to content

perf(wt_bridge): reduce hot-path allocations and syscalls#375

Merged
osamu620 merged 1 commit into
mainfrom
perf/wt-bridge-reduce-hot-path-overhead
May 11, 2026
Merged

perf(wt_bridge): reduce hot-path allocations and syscalls#375
osamu620 merged 1 commit into
mainfrom
perf/wt-bridge-reduce-hot-path-overhead

Conversation

@osamu620
Copy link
Copy Markdown
Owner

Summary

  • broadcast(): hold mutex during iteration instead of allocating a
    subscriber-slice copy per packet. All channel ops are non-blocking
    (select with default), so lock duration is bounded. Eliminates
    ~10k slice allocs/sec at typical RTP rates.
  • runSession(): merge the 2-byte length header and body into a
    single stream.Write via a reusable buffer. Halves write-syscall
    count per subscriber per packet.
  • Bump forwarded-count log interval to 150,000 packets (~15 s).

Test plan

  • go build passes
  • Split-mode and LAN-mode streaming still works
  • Verify reduced CPU usage on the bridge host under load

🤖 Generated with Claude Code

broadcast(): hold the mutex during iteration instead of copying the
subscriber slice on every packet.  All channel operations are
non-blocking (select with default), so lock duration is bounded.
Eliminates ~10k slice allocations/sec at typical RTP rates.

runSession(): merge the 2-byte length header and packet body into a
single stream.Write using a reusable buffer.  Halves the number of
write syscalls per subscriber per packet.

Also bump the forwarded-count log interval from 100k to 150k packets
(~15 s at the user's observed rate).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@osamu620 osamu620 merged commit cd6c742 into main May 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant