Skip to content

Add optional parallel UDP writers and reuse subgroup inboxes - #126

Merged
floatdrop merged 1 commit into
draft-22from
relay-parallel-writers
Nov 6, 2026
Merged

floatdrop merged 1 commit into
draft-22from
relay-parallel-writers

Conversation

@floatdrop

Copy link
Copy Markdown
Owner

The shared UDP batch writer can occupy one core while a relay still has CPU headroom. Add opt-in two-writer Linux batching through WithUDPSendWriters(2) / -udp-send-writers 2, using duplicated handles to the same socket and stable destination affinity. One writer remains the default, and the total queue budget stays 256.

Reuse subgroup inbox storage only after its writer has drained or terminated. A separate close signal and producer/recycle lock barrier prevent late producers from touching a new subgroup. Retention is bounded to 1024 empty queues with capacity at most 256. The focused 64-object inbox lifecycle benchmark decreases from 6720 to 576 B/op; this is not a whole-relay allocation reduction.

Validation: full native race suite, vet/build, CI-pinned golangci-lint 2.14, quick allocation guards and benchmark smoke; Linux GSO/ECN/source metadata, raw QUIC/WebTransport, deadline, fallback, listener drain and socket-release tests with upstream and application QUIC forks. Serial-dispatch and no-reuse negative controls fail the intended regressions. Protocol/conventions review found no issues.

Relay load and playback measurements remain necessary before enabling the new writer count in production.

Add opt-in two-writer Linux batching with stable destination affinity,
duplicated socket handles, a fixed total queue budget, and coordinated
deadline/close handling. Keep one writer as the default.

Reuse bounded, empty subgroup inbox storage after drain/termination with
a producer barrier that prevents stale writers touching recycled queues.

Verified regression controls: serial dispatch fails the parallel-progress
test; fresh-only allocation fails the inbox-reuse test. Restored code passes
both under race detection. Protocol/conventions review found no issues.
@floatdrop
floatdrop marked this pull request as ready for review November 6, 2026 11:40
@floatdrop
floatdrop merged commit 10dfc11 into draft-22 Nov 6, 2026
11 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