Skip to content

beacon: shard discover/relay/punch rate limiters (fix UDP recv-queue saturation) - #48

Merged
TeoSlayer merged 2 commits into
mainfrom
perf/shard-ratelimiters
Jul 26, 2026
Merged

beacon: shard discover/relay/punch rate limiters (fix UDP recv-queue saturation)#48
TeoSlayer merged 2 commits into
mainfrom
perf/shard-ratelimiters

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Under a full-fleet reconverge flood the beacon's UDP recv-queue grew unbounded (60K→350K bytes, never draining) while the box had CPU headroom — classic lock contention. All 2×NumCPU reader goroutines serialized on three single global mutexes (discoverRateMu, relayRateMu, punchRateMu), each taken on every discover/relay/punch packet. This shards each limiter 256 ways (the endpoint store nodeMap was already sharded).

Deployed effect (live): recv-queue now drains to 0 between bursts instead of growing without bound; the beacon keeps up with the reconverge flood so tunnel coordination proceeds. Full -race suite green.

🤖 Generated with Claude Code

…uration)

Under a full-fleet reconverge flood the beacon's UDP recv-queue grew
unbounded (60K->350K bytes, never draining) while the box had CPU
headroom — the signature of lock contention. All 2*NumCPU reader
goroutines serialized on three single global mutexes (discoverRateMu,
relayRateMu, punchRateMu), each taken on every discover/relay/punch
packet. Shard each rate limiter 256 ways (the endpoint store was already
sharded), so readers touching different keys proceed in parallel.

Deployed effect: recv-queue drains to 0 between bursts instead of growing;
tunnel coordination keeps up under the flood.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer
TeoSlayer merged commit f9fef08 into main Jul 26, 2026
5 checks passed
@TeoSlayer
TeoSlayer deleted the perf/shard-ratelimiters branch July 26, 2026 14:09
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.

2 participants