Skip to content

perf(io): implement per-core UMEM slab allocation and vectorized ring operations in AF_XDP - #177

Merged
tailroom merged 1 commit into
mainfrom
perf/afxdp-per-core-umem-slab
Oct 27, 2026
Merged

tailroom merged 1 commit into
mainfrom
perf/afxdp-per-core-umem-slab

Conversation

@vxfemboy

Copy link
Copy Markdown
Member

Resolves #172

Summary

This PR resolves Issue #172 by eliminating centralized free-list contention and cross-core MESI cache-line invalidation in AF_XDP kernel-bypass networking. It introduces per-core UmemSlab partitioning, lock-free batch recycling between CompletionRing and FillRing, and vectorizes ring buffer batch operations.

Changes

  1. Per-Core UmemSlab Partitioning (crates/yip-io/src/af_xdp.rs):
    • Added UmemSlab managing disjoint, non-overlapping chunk partitions from a shared UmemPool mapping.
    • Added UmemPool::create_slabs and UmemPool::new_slabs to construct and partition shared memory regions without lock contention.
    • Workers allocate and recycle chunk addresses locally with zero cross-core cache invalidation or atomic locks.
    • Added slab.chunk_slice and slab.chunk_slice_mut with strict bounds checking and memory isolation guarantees.
  2. Lock-Free Batch Ring Recycling:
    • Added UmemSlab::recycle_from_rings to harvest completed chunk descriptors directly from CompletionRing and push them into FillRing in batch, spilling any surplus directly back to the thread-local slab without heap allocations.
    • Added UmemSlab::populate_fill_ring for fast batch priming of fill rings.
  3. Vectorized Ring Operations:
    • Replaced scalar item-by-item loops in FillRing, CompletionRing, RxRing, and TxRing with power-of-two masked contiguous slice copies (copy_from_slice), boosting circular ring batch throughput from 1,438 Mops/s to 4,057 Mops/s (0.25 ns/op).
  4. Daemon Integration (bin/yipd/src/sharding.rs):
    • Multi-queue worker shards now partition a single shared UmemPool into per-worker slabs, adhering to real Linux kernel XDP_SHARED_UMEM requirements.
  5. Benchmarks & Unit Tests:
    • Updated crates/yip-bench/benches/af_xdp_scale.rs to benchmark UmemSlab alloc/free, ring-to-ring recycling, and single-pool multi-slab scaling across 1, 2, 4, and 8 worker threads.
    • Added 6 comprehensive unit tests in crates/yip-io/tests/umem_test.rs validating slab allocation, bounds, batching, recycling, ring wrap-around, and Send/Sync invariants.
  6. Documentation & Roadmap:
    • Updated CHANGELOG.md, ROADMAP.md, README.md, docs/03-architecture.md, and docs/05-benchmarking-and-performance.md.

Benchmark Results (af_xdp_scale)

Metric / Scenario Baseline UmemSlab + Vectorized Rings Improvement
Circular Rings (Batch 32) 1,438 Mops/s (0.70 ns/op) 4,057 Mops/s (0.25 ns/op) 2.8× faster (-64.3% latency)
Ring-to-Ring Recycling (Batch 32) Single-chunk loop 1,063 Mops/s (0.94 ns/op) Direct ring transfer
8-Worker Aggregate Throughput 17.17 Gbps (1.677 Mpps) 19.60 Gbps (1.914 Mpps) +2.43 Gbps line rate
Packet Drops / Out-of-Order 0 drops / 0 OOO 0 drops / 0 OOO Strict FIFO ordering preserved

Verification

  • cargo test --workspace: All 387 unit + 98 integration tests pass cleanly.
  • cargo clippy --workspace --all-targets -- -D warnings: Clean.
  • cargo fmt --check: Clean.
  • cargo shear: Clean.

@vxfemboy
vxfemboy temporarily deployed to benchmark-approval October 27, 2026 02:34 — with GitHub Actions Inactive
@vxfemboy
vxfemboy temporarily deployed to benchmark-approval October 27, 2026 02:34 — with GitHub Actions Inactive
@vxfemboy
vxfemboy temporarily deployed to benchmark-approval October 27, 2026 02:46 — with GitHub Actions Inactive
@tailroom
tailroom merged commit 8fc0be9 into main Oct 27, 2026
12 checks passed
@tailroom
tailroom deleted the perf/afxdp-per-core-umem-slab branch October 27, 2026 03:13

This branch was previously deployed

1 inactive deployment
benchmark-approval — 7aecfb43 Deployed Oct 27, 2026 by vxfemboy via wan-benchmark #39
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.

perf(io): implement per-core UMEM slab allocation and eliminate shared free-list bottleneck in AF_XDP

2 participants