perf(wt_bridge): add pprof + batch UDP reads with recvmmsg#376
Merged
Conversation
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>
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.
Summary
Add
--pprof <addr>flag for live CPU/memory profiling under load.Switch UDP receive from per-packet
recvfromto batchedrecvmmsg(64 packets per syscall) via
golang.org/x/net/ipv4.ReadBatch.CPU profile at ~10k packets/sec showed 95%+ of bridge CPU in syscalls
(
recvfrom44%,epollWait36%) 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 buildpasses--pprof :6060and compare CPU usage--pprofendpoint responds at/debug/pprof/🤖 Generated with Claude Code