radon's receive rate: a one-segment window and a tick per round trip
Name: provisional.
A child of notes/designware-ethernet.md (milestone 53 (the board's
own peripherals: network and storage on real silicon)), whose Results row is the 2.3 Mbit/s this
page explains. Its names are provisional: socket_contract::polled_wait, TCP_RECEIVE_BUF,
CurrentCpuPage::tick_hertz, user_mode_runtime::tick_hertz, MappedWindow::copy_to_slice and
copy_from_slice, the rehearsal's --debug-userspace, the bench boot's receive line, and this
page's stem.
Why the row is 2.3 Mbit/s
Two things in net_stack, each measured, and they multiply.
- The window was one segment. Every TCP socket advertised 2 KiB with no window scaling. The peer sends a 1460-byte segment, and the 588 bytes left are under its silly-window threshold, so it waits for the acknowledgment. One segment per round trip.
- Every round trip waited for a scheduler tick. Neither polled NIC raises an interrupt, so
when the ring was empty
net_stackslept 1 ms. The kernel ends a timed wait only at a tick (DECISIONS ยง147 (a timer a userspace service cannot hold)), 100 Hz on every architecture, so the sleep lasted up to 10 ms. On a local area network the next segment comes back well within a tick, and found the stack asleep.
One 1460-byte segment per half tick on average is 2.34 Mbit/s, and the row is 104,857,600 bytes in 71,820 segments over 362.965 s, 5.05 ms each.
QEMU hides both, because slirp answers in microseconds and the next frame is already in the ring
when the stack looks. A filter-buffer on the e1000e's netdev (interval=300) reproduces
radon's shape on cargo xtask network-bench's image, 8 MiB in. Its delay measured a 1.04 ms
median from the guest's acknowledgment to the next segment reaching it. A filter-dump either
side of it shows the window and the guest's turnaround:
| wait | window | no added delay | added delay | guest's data-to-ACK median |
|---|---|---|---|---|
| sleep when the ring is empty | 2 KiB | 72 Mbit/s | 1.16 Mbit/s | 10.15 ms |
| sleep when the ring is empty | 16 KiB | 240 Mbit/s | 9.3 Mbit/s | |
| look for a tick after a frame | 2 KiB | 81 Mbit/s | 8.6 Mbit/s | |
| look for a tick after a frame | 16 KiB | 235 Mbit/s | 67.7 Mbit/s |
The tree is the last row. The receive window is 16 KiB (socket_table::TCP_RECEIVE_BUF), bounded
at compile time by the polled rings and the heap. The polled wait keeps looking, yielding between
looks, for one tick after the last frame and sleeps only after that
(socket_contract::polled_wait, host-tested). A tick is the bound because it is what a sleep
costs. The price is a busy core while a stream flows.
The bench step
The parent's bench step, unchanged, from
a commit that has the fix: same peer, same image flags, same console capture. While the transfer
runs, in a fourth terminal on the same Mac, capture the stream (it needs sudo; without it, skip
the capture and say so in the Results row):
sudo tcpdump -i en0 -nn -c 20000 -w bench/radon-$(date -u +%F)/network-bench-rate.pcap tcp port 9494
Then read two things out of it. The windows radon advertised, which should reach 16384:
tcpdump -nn -r bench/radon-$(date -u +%F)/network-bench-rate.pcap 'src port not 9494' | grep -o 'win [0-9]*' | sort | uniq -c | sort -rn | head
And the gaps between radon's acknowledgments, in milliseconds, which should be well under a tick:
tcpdump -nn -tt -r bench/radon-$(date -u +%F)/network-bench-rate.pcap 'src port not 9494' | awk '{if (p) print ($1-p)*1000; p=$1}' | sort -n | awk '{a[NR]=$1} END {print "p50", a[int(NR/2)], "p90", a[int(NR*0.9)]}'
On radon the two causes do not separate by rate alone. The window by itself gives 16 KiB per half tick, about 26 Mbit/s; the wait by itself gives one segment per local area network round trip, tens of Mbit/s. Together they allow over 100 Mbit/s at a 1 ms round trip, so radon's cores copying each frame probably set the rate. The capture decides:
| what the run shows | meaning | next |
|---|---|---|
| over 50 Mbit/s | both changes hold on silicon | a Results row in the parent; its first BUGS entry comes out |
| windows stay at 2048 | the window change is not in the image | git log -1 against the image; rebuild |
| windows reach 16384, acknowledgment gaps near 5 to 10 ms | the stack still sleeps to a tick per round trip | a lane, with the capture |
| windows reach 16384, gaps well under a tick, rate under 50 | a third limit, probably copying on radon's cores | a Results row and a BUGS entry naming it; a lane to profile |
| about 2.3 Mbit/s | neither change is in the image | git log -1 against the image; rebuild |
What radon measured, 2026-10-22
Two boots of the bench step from 699fcf61a, which has the fix: 14.329 and 14.313 Mbit/s, six
times the 2.3 and short of the 50 the table above asks for
(bench/radon-2026-10-22/53-network-rate.log). patagonia's tcpdump needs sudo, which the run
did not have, so the second boot's peer was a Python server that reads its own socket's
TCP_CONNECTION_INFO every 5 ms instead, which macOS gives any process
(bench/radon-2026-10-22/53-network-rate-peer.py). It served the same 100 MiB, and the rate
matched the first boot's nc, so the peer is not the limit. What its socket saw
(53-network-rate-peer.txt):
| field | value |
|---|---|
| radon's window scale | 0 (none offered) |
| maximum segment | 1460 bytes |
| radon's advertised window, its six commonest values | 4,596, 4,704, 5,288, 4,412, 4,996 and 4,120 bytes, 1,710 to 2,428 samples each; the next two, 9,084 and 7,624, in 8 and 6 |
| smoothed round trip, in whole milliseconds | 2 ms median and 90th percentile, 5 ms the most |
| retransmitted bytes | 0 |
So the window does reach past 2 KiB, which says the fix is in the image, and the wait does not sleep to a tick, since a round trip is 2 ms. But radon advertises about 4.6 KiB of the 16 KiB buffer at every acknowledgment, so about 11.5 KiB sits unread each time. A window of 4.6 KiB per 2 ms round trip allows 18 Mbit/s, near the measured 14.3 given a round trip read only in whole milliseconds. No row of the table above has that shape. The nearest is its fourth: a third limit, on radon's side and after the wire. The copy drains the buffer slower than a gigabit link fills it, as the next section measures.
What drains it slowly: radon's programs are debug builds
script/board-image packs the userspace archive in the debug profile under a release kernel
(milestone 797 (release userspace in board images)), so radon's net_stack runs at opt-level 0.
The QEMU table above came from cargo xtask network-bench, which packs release programs, so it
never paid that price. Each RECEIVE call carries at most one frame of 4,088 bytes. An
unoptimized build moved every byte through a loop twice: from the DMA buffer into smoltcp, then
from smoltcp into the socket's frame. Each byte cost a call, a bounds check and a volatile access.
smoltcp's own checksum and buffers ran unoptimized beside them.
The rehearsal's --debug-userspace flag packs the archive the way radon's image does. Its
receive line, from the drain client's second report, splits the transfer by call:
| programs | copies | smoltcp | rate | inside one call |
|---|---|---|---|---|
| debug | byte loops | opt-level 0 | 7.4 and 7.5 Mbit/s | |
| debug | byte loops | opt-level 2 | 11.5 Mbit/s | |
| debug | bulk | opt-level 0 | 22.9 Mbit/s | 1,427 us |
| debug | bulk | opt-level 2 | 70.3, 70.8 and 71.9 Mbit/s | 454 to 464 us |
| release | byte loops | release | 56 and 67 Mbit/s | |
| release | bulk | release | 181, 195 and 225 Mbit/s | 144 to 180 us |
Every call in the runs that report it came back full, 2,051 of 2,053. The client spent no measurable time between calls. So the server's turnaround per call sets the rate, and radon's 4.6 KiB windows are its shape on silicon. About 11.5 KiB waits in the buffer at each acknowledgment, because the server empties it 4,088 bytes per call. At 14.3 Mbit/s a call on radon takes about 2.3 ms. These are QEMU's rates on one host and mean nothing about a NIC; the ratios between rows are the finding.
The tree has both changes. MappedWindow::copy_to_slice and copy_from_slice check a range once
and copy it in bulk, and both transports, the socket operations and the client's frame use them.
The workspace profile builds smoltcp at opt-level 2 even in a debug build.
The bench step for the drain
The parent's bench step, unchanged, from a commit with these changes. The console log then holds
one more line after transfer:
network-bench: receive : N calls, B bytes each on average, F full; I us inside a call and O us between calls, on average
Read four numbers from it and the transfer line:
| what the log shows | meaning | next |
|---|---|---|
rate over 50 Mbit/s, I under 650 |
the copies and smoltcp set the old rate | a Results row in the parent; its first BUGS entry comes out |
I near 2,300, F near N |
the turnaround did not move on silicon: a cost QEMU does not have, such as the IPC round trip or the timer read | a lane, with the log |
O large against I |
the client's own loop is slow | a lane |
F well under N |
calls come back short, so the server waits for frames, and the window or the wait is the limit again | the capture above |
no receive line |
the image predates these changes | git log -1 against the image; rebuild |
The expected range is 40 to 140 Mbit/s with I between 230 and 800 us. With debug programs
QEMU's turnaround fell by about 9.5 times, from about 4,400 us to 460: every call comes back
full, so the turnaround scales as the inverse of the rate. A factor of 9.5 on radon's 2.3 ms
gives about 240 us. radon's cores pay a different mix of copying and emulation costs, so the
factor there is the measurement, not a prediction.