Skip to content

fix(yip-io): make io_uring loopback recycle tests robust on default rmem#113

Merged
vxfemboy merged 4 commits into
mainfrom
fix/uring-loopback-buffer-flake
Jul 26, 2026
Merged

fix(yip-io): make io_uring loopback recycle tests robust on default rmem#113
vxfemboy merged 4 commits into
mainfrom
fix/uring-loopback-buffer-flake

Conversation

@vxfemboy

Copy link
Copy Markdown
Member

Problem

Two io_uring tests fail deterministically on any box with a default UDP receive buffer:

  • uring_loopback_roundtrip_recycles_recv_buffers
  • uring_in_flight_send_table_reuses_slots_after_completions

Both blasted all datagrams into the socket before draining, then asserted more than 256 (RING_BUFS / SEND_SLOTS) round-trip. That requires the kernel to buffer >256 datagrams at once, but the default net.core.rmem_default (~208 KB) only holds ~230 small datagrams (per-skb truesize overhead). Result on a stock box: got 237, needed >256 → fail. It only passed where rmem was tuned up.

Fix

Interleave send and drain with a bounded in-flight window (64), so the kernel receive buffer never has to hold more than 64 at once. Nothing is dropped, both counts reach total on any box.

The test's intent is preserved: recycling of the fixed pool is still proven by round-tripping far more than the pool size through it, and a genuine leak still stalls at ≤ pool size and fails both asserts.

Verify

  • Each test 10/10 green locally on a box with default rmem_default = 212992.
  • Full cargo test workspace suite passes (pre-commit hook).
  • Bonus: no more stall-spinning — each test drops from ~4.6 s to ~0.2 s.

Both `uring_loopback_roundtrip_recycles_recv_buffers` and
`uring_in_flight_send_table_reuses_slots_after_completions` blasted all
datagrams into the socket before draining, then asserted more than 256
(RING_BUFS / SEND_SLOTS) round-trip. That requires the kernel to buffer >256
datagrams at once, but the default net.core.rmem_default (~208 KB) only holds
~230 small datagrams (per-skb truesize overhead), so the assert failed
deterministically on stock-configured boxes (got 237, needed >256).

Interleave send and drain with a bounded in-flight window (64) so nothing is
dropped and both counts reach `total` on any box. Recycling of the fixed pool
is still proven — far more than the pool size flows *through* it — and a real
leak still stalls at <= pool size and fails. Bonus: no more stall-spinning, so
the tests drop from ~4.6 s to ~0.2 s.
@vxfemboy
vxfemboy merged commit 380e75f into main Jul 26, 2026
9 checks passed
@vxfemboy
vxfemboy deleted the fix/uring-loopback-buffer-flake branch July 26, 2026 05:28
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