Skip to content

perf(wt_bridge): add pprof + batch UDP reads with recvmmsg#376

Merged
osamu620 merged 2 commits into
mainfrom
feat/wt-bridge-pprof
May 11, 2026
Merged

perf(wt_bridge): add pprof + batch UDP reads with recvmmsg#376
osamu620 merged 2 commits into
mainfrom
feat/wt-bridge-pprof

Conversation

@osamu620

Copy link
Copy Markdown
Owner

Summary

  • Add --pprof <addr> flag for live CPU/memory profiling under load.

  • Switch UDP receive from per-packet recvfrom to batched recvmmsg
    (64 packets per syscall) via golang.org/x/net/ipv4.ReadBatch.

    CPU profile at ~10k packets/sec showed 95%+ of bridge CPU in syscalls
    (recvfrom 44%, epollWait 36%) and Go scheduler wake overhead
    (18%) — zero in application code. Batching reduces syscall count
    ~64× and proportionally reduces scheduler wake cycles.

    Falls back to single reads on non-Linux transparently.

Test plan

  • go build passes
  • LAN and split-mode streaming works
  • Re-profile with --pprof :6060 and compare CPU usage
  • Verify --pprof endpoint responds at /debug/pprof/

🤖 Generated with Claude Code

osamu620 and others added 2 commits May 11, 2026 13:53
Add --pprof <addr> (e.g. --pprof :6060) to start a pprof HTTP server
for live CPU and memory profiling.  Use with:

  go tool pprof http://<bridge-ip>:6060/debug/pprof/profile?seconds=10

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CPU profile showed 95%+ of bridge CPU in syscalls and scheduler
overhead — one recvfrom + goroutine wake per packet at ~10k packets/sec.

Switch to ipv4.PacketConn.ReadBatch which uses recvmmsg on Linux to
read up to 64 packets per syscall.  On non-Linux, falls back to single
reads transparently.  This reduces syscall count ~64× and scheduler
wake cycles proportionally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@osamu620 osamu620 merged commit 39d1805 into main May 11, 2026
12 checks passed
@osamu620 osamu620 deleted the feat/wt-bridge-pprof branch May 27, 2026 07:02
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