Skip to content

Warn when the kernel caps the UDP buffers - #379

Merged
lambdanature merged 10 commits into
mainfrom
375-udp-socket-buffers
Nov 29, 2026
Merged

lambdanature merged 10 commits into
mainfrom
375-udp-socket-buffers

Conversation

@lambdanature

Copy link
Copy Markdown
Contributor

irsync asks for a 7 MiB UDP buffer on each socket (iroh's netwatch does), but a stock Linux kernel quietly gives 208 KiB (net.core.rmem_max / wmem_max). On a link with a long round trip the receiver then drops packets. Between San Jose and Europe (143 ms) a 2.5 GB push took 9m47s with the default limit and 3m12s with it raised. Nothing told the user.

Now irsync says so, on the machine the user types on, for both machines:

irsync: warning: the kernel on aragorn limits UDP buffers to 208 KiB; irsync asks for 7 MiB.
irsync: warning: On a link with a long round trip, such as across an ocean, that loses packets and slows the sync down. To fix it on aragorn:
irsync: warning:   sudo sysctl -w net.core.rmem_max=16777216 net.core.wmem_max=16777216
irsync: warning:   then restart the daemon there: systemctl --user restart irsync
irsync: warning: see "Tune the kernel for long-distance links" in the manual
  • Probe (net/udp_buffers.rs): opens a UDP socket, asks for 7 MiB each way and reads back what the kernel granted (halved on Linux, which reports double). None on Windows.
  • Daemon: probes when it binds its sockets (at start and on reload), logs the warning, and sends the result in HelloAck.socket_buffers. Protocol version 11.
  • Client: probes once per run. The progress reporter prints each machine's warning once, none with -q.
  • Book: "Tune the kernel for long-distance links" in the troubleshooting how-to (commands for Linux, macOS and FreeBSD, and how to keep them after a reboot), plus the new field in the protocol reference.
  • Tests: tests of the probe and the wording, golden bytes for the field, reporter tests, and end-to-end runs with the real binaries. Binaries built with test-hooks read IRSYNC_TEST_UDP_BUFFERS instead of probing, and the test helper sets it to "uncapped", so machines with the small default don't see the warning in other tests.

Checked with tools/ci.sh check and tools/ci.sh typecheck, and on the real link: both warnings with the limits at 208 KiB, none at 16 MiB after a daemon restart.

Design: docs/superpowers/specs/2026-11-29-udp-buffer-warning-design.md; plan: docs/superpowers/plans/2026-11-29-udp-buffer-warning.md.

Still open: the daemon still dropped about 11,000 packets with 7 MiB buffers. Its receive path is probably the next limit, and that's a separate question.

Closes #375

irsync asks for 7 MiB UDP buffers, but a stock Linux kernel quietly gives
208 KB, which made a long-link push three times slower (#375).
The link that showed the problem carries only about 20 MB/s, but over a
143 ms round trip. Word the warning and the book section for that.
iroh asks for 7 MiB per UDP socket, but Linux quietly caps it at
net.core.rmem_max. A socket of our own shows what the real ones get (#375).
So the client can warn about a server whose kernel caps them. Protocol
version 11.
It probes when it binds its sockets, logs the warning, and sends the
result in every HelloAck.
The client probes its own sockets once per run and reads the daemon's
result from HelloAck; the reporter prints each machine's warning once,
none with -q.
irsync pair leaves a running daemon of the same version alone, so it
did not pick up a raised limit. A restart or SIGHUP binds new sockets.
@lambdanature
lambdanature merged commit 0bc3140 into main Nov 29, 2026
17 checks passed
@lambdanature
lambdanature deleted the 375-udp-socket-buffers branch November 29, 2026 00:58
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.

Use bigger UDP socket buffers, and warn on the client when either kernel caps them

1 participant