Skip to content

perf(io_uring): add IORING_OP_RECV/IORING_OP_SEND for socket I/O - #2513

Merged
oferchen merged 1 commit into
masterfrom
perf/io-uring-socket-io
Feb 27, 2026
Merged

oferchen merged 1 commit into
masterfrom
perf/io-uring-socket-io

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add io_uring-based socket reader/writer (IORING_OP_RECV/IORING_OP_SEND) for daemon transfer path
  • On Linux 5.6+, replaces BufReader<TcpStream> with IoUringSocketReader that fills via ring submission
  • Batched IORING_OP_SEND via submit_send_batch() replaces per-write syscalls on socket output
  • IoUringPolicy::Auto tries io_uring first, gracefully falls back to FdReader/FdWriter adapters
  • Non-Linux platforms use stub implementations that always use standard I/O

Changes

File Change
crates/fast_io/src/io_uring.rs +615 lines: submit_send_batch(), IoUringSocketReader, IoUringSocketWriter, enum wrappers, factory functions, FdReader/FdWriter adapters, 6 socket pair tests
crates/fast_io/src/io_uring_stub.rs +191 lines: matching stubs for non-Linux platforms
crates/fast_io/src/lib.rs +6 lines: re-export socket types and factory functions (unix-gated)
crates/daemon/Cargo.toml +1 line: fast_io dependency
crates/daemon/src/daemon/sections/module_access.rs +17 lines: wrap TcpStream fds in io_uring socket wrappers in execute_transfer()

Test plan

  • 6 new socket pair tests (roundtrip, large payload, disabled policy, FdReader/FdWriter)
  • All 22,364 workspace tests pass
  • cargo fmt --all -- --check clean
  • cargo clippy -p fast_io -p daemon --all-targets --all-features --no-deps -D warnings clean

Add io_uring-based socket reader and writer that replace BufReader
and direct TcpStream writes in the daemon transfer path. On Linux
5.6+ this eliminates per-operation syscall overhead for socket I/O
via ring submission and batched sends.

New types:
- IoUringSocketReader: buffered recv via IORING_OP_RECV
- IoUringSocketWriter: batched send via IORING_OP_SEND
- IoUringOrStdSocketReader/Writer: enum-based fallback wrappers
- socket_reader_from_fd/socket_writer_from_fd: factory functions
  following the existing IoUringPolicy (Auto/Enabled/Disabled)

Integration:
- Daemon execute_transfer() wraps TcpStream fds in io_uring socket
  wrappers before calling run_server_with_handshake()
- Non-Linux platforms use FdReader/FdWriter thin adapters
- All paths tested via Unix socket pair roundtrip tests
@oferchen
oferchen force-pushed the perf/io-uring-socket-io branch from 2085afb to 14336a4 Compare February 27, 2026 04:22
@oferchen
oferchen merged commit 04912bf into master Feb 27, 2026
7 of 8 checks passed
@oferchen
oferchen deleted the perf/io-uring-socket-io branch February 27, 2026 09:46
oferchen added a commit that referenced this pull request May 1, 2026
perf(io_uring): add IORING_OP_RECV/IORING_OP_SEND for socket I/O
oferchen added a commit that referenced this pull request May 5, 2026
perf(io_uring): add IORING_OP_RECV/IORING_OP_SEND for socket I/O
oferchen added a commit that referenced this pull request May 21, 2026
…SO-5)

Adds the ZSO-5 (task #2513) regression suite at
crates/matching/tests/zsync_wire_parity.rs. For each ZSO-1..4
optimization, constructs a basis + source pair designed to exercise
that optimization's code path, runs generate_delta, serialises the
DeltaScript through the production wire-format encoder
(protocol::wire::write_token_stream), and pins the resulting bytes
against (a) determinism across repeated runs and (b) round-trip
reconstruction of the source via apply_delta.

Active tests:
- bithash_optimization_preserves_wire_bytes (ZSO-1, task #2510, shipped
  in PR #3737) - 16 KiB random basis + disjoint random source so every
  rolling probe walks the bithash reject path. Asserts all-literal
  script and deterministic wire bytes.
- seq_match_optimization_preserves_wire_bytes (ZSO-2, task #2510,
  landing on PR #4624) - 84-block basis used as its own source so
  every adjacent-block hint fires. Asserts single fat Copy token and
  deterministic wire bytes. Test was authored to remain green on
  master (extend_run + script-level coalescing already produce the
  pinned shape) and stays green when PR #4624 swaps the probe path.
- all_active_zso_fixtures_are_deterministic - cross-cutting check that
  signals "matching pipeline became non-deterministic" as a single
  failure.

Stub tests (#[ignore]):
- hash_chain_prune_preserves_wire_bytes (ZSO-3, task #2511)
- compact_rolling_key_preserves_wire_bytes (ZSO-4, task #2512)

The stubs are structured so the only step required when those
optimizations land is to drop #[ignore] and swap the placeholder
basis/source for the duplicate-heavy / small-basis corpora documented
in the test rustdoc.

Complements the protocol-layer golden tests at
crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs which
pin the token frame format but do not synthesize ZSO-specific basis
fixtures.

No production code changes. No new dependencies (uses a small in-test
LCG to keep the corpus deterministic). All 321 matching tests pass;
407 protocol golden tests pass.
oferchen added a commit that referenced this pull request May 21, 2026
…SO-5) (#4627)

Adds the ZSO-5 (task #2513) regression suite at
crates/matching/tests/zsync_wire_parity.rs. For each ZSO-1..4
optimization, constructs a basis + source pair designed to exercise
that optimization's code path, runs generate_delta, serialises the
DeltaScript through the production wire-format encoder
(protocol::wire::write_token_stream), and pins the resulting bytes
against (a) determinism across repeated runs and (b) round-trip
reconstruction of the source via apply_delta.

Active tests:
- bithash_optimization_preserves_wire_bytes (ZSO-1, task #2510, shipped
  in PR #3737) - 16 KiB random basis + disjoint random source so every
  rolling probe walks the bithash reject path. Asserts all-literal
  script and deterministic wire bytes.
- seq_match_optimization_preserves_wire_bytes (ZSO-2, task #2510,
  landing on PR #4624) - 84-block basis used as its own source so
  every adjacent-block hint fires. Asserts single fat Copy token and
  deterministic wire bytes. Test was authored to remain green on
  master (extend_run + script-level coalescing already produce the
  pinned shape) and stays green when PR #4624 swaps the probe path.
- all_active_zso_fixtures_are_deterministic - cross-cutting check that
  signals "matching pipeline became non-deterministic" as a single
  failure.

Stub tests (#[ignore]):
- hash_chain_prune_preserves_wire_bytes (ZSO-3, task #2511)
- compact_rolling_key_preserves_wire_bytes (ZSO-4, task #2512)

The stubs are structured so the only step required when those
optimizations land is to drop #[ignore] and swap the placeholder
basis/source for the duplicate-heavy / small-basis corpora documented
in the test rustdoc.

Complements the protocol-layer golden tests at
crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs which
pin the token frame format but do not synthesize ZSO-specific basis
fixtures.

No production code changes. No new dependencies (uses a small in-test
LCG to keep the corpus deterministic). All 321 matching tests pass;
407 protocol golden tests pass.
oferchen added a commit that referenced this pull request Aug 24, 2026
…SO-5) (#4627)

Adds the ZSO-5 (task #2513) regression suite at
crates/matching/tests/zsync_wire_parity.rs. For each ZSO-1..4
optimization, constructs a basis + source pair designed to exercise
that optimization's code path, runs generate_delta, serialises the
DeltaScript through the production wire-format encoder
(protocol::wire::write_token_stream), and pins the resulting bytes
against (a) determinism across repeated runs and (b) round-trip
reconstruction of the source via apply_delta.

Active tests:
- bithash_optimization_preserves_wire_bytes (ZSO-1, task #2510, shipped
  in PR #3737) - 16 KiB random basis + disjoint random source so every
  rolling probe walks the bithash reject path. Asserts all-literal
  script and deterministic wire bytes.
- seq_match_optimization_preserves_wire_bytes (ZSO-2, task #2510,
  landing on PR #4624) - 84-block basis used as its own source so
  every adjacent-block hint fires. Asserts single fat Copy token and
  deterministic wire bytes. Test was authored to remain green on
  master (extend_run + script-level coalescing already produce the
  pinned shape) and stays green when PR #4624 swaps the probe path.
- all_active_zso_fixtures_are_deterministic - cross-cutting check that
  signals "matching pipeline became non-deterministic" as a single
  failure.

Stub tests (#[ignore]):
- hash_chain_prune_preserves_wire_bytes (ZSO-3, task #2511)
- compact_rolling_key_preserves_wire_bytes (ZSO-4, task #2512)

The stubs are structured so the only step required when those
optimizations land is to drop #[ignore] and swap the placeholder
basis/source for the duplicate-heavy / small-basis corpora documented
in the test rustdoc.

Complements the protocol-layer golden tests at
crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs which
pin the token frame format but do not synthesize ZSO-specific basis
fixtures.

No production code changes. No new dependencies (uses a small in-test
LCG to keep the corpus deterministic). All 321 matching tests pass;
407 protocol golden tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant