Skip to content

fix: io_uring bench MEMLOCK + Criterion workflow target_tag - #3575

Merged
oferchen merged 2 commits into
masterfrom
fix/io-uring-bench-ring-per-iter
May 3, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/io-uring-bench-ring-per-iter

Conversation

@oferchen

@oferchen oferchen commented May 3, 2026 •

Copy link
Copy Markdown
Owner

Two release-blocker fixes for the v0.6.1 Criterion publishing pipeline.

fix(bench): hoist io_uring reader to prevent MEMLOCK exhaustion

The v0.6.1 Criterion workflow (run 25276974185) panicked with Cannot allocate memory (os error 12) during io_uring/io_uring/64kb warm-up. Per-iteration IoUringReader::open allocates a fresh ring; at ~6us/iter across 3s warm-up + 5s measurement, hundreds of thousands of ring allocations exhaust RLIMIT_MEMLOCK on CI runners.

Fix:

  • Reads: hoist IoUringReader allocation outside b.iter. read_all_batched reads from offset 0 each call and returns registered-buffer slots via Drop, so reuse is safe. The hoisted open also doubles as the sentinel: a failed open skips the sub-bench and keeps the standard_io baseline measurable.
  • Writes: IoUringWriter owns its file with an internal byte cursor (no reset path), so cross-iter reuse is impractical. Bound the write iteration count instead via sample_size(10), warm_up_time(500ms), measurement_time(2s).

fix(ci): allow Criterion workflow to publish to existing release tag

Mirrors the target_tag dispatch pattern from benchmark.yml (PR #3574). Adds a workflow_dispatch input plus a Resolve release tag step so the Criterion workflow can be re-run against an existing release tag without retagging - required to publish criterion results to v0.6.1 once the bench fix above lands.

Verification

The io_uring read sub-bench in fast_io/io_optimizations.rs was
allocating a fresh ring (and registered-buffer group) per criterion
iteration. With ~6us per read iter, the 3s warm-up + 5s measurement
window allocated hundreds of thousands of rings, exhausting
RLIMIT_MEMLOCK on CI runners and panicking with ENOMEM.

`IoUringReader::read_all_batched` reads from offset 0 each call and
returns registered-buffer slots via Drop, so the reader is safe to
reuse across iterations. Hoist allocation outside `b.iter` (the
allocation also doubles as the existing sentinel guard).

The writer sub-bench has the same per-iter allocation pattern, but
the writer owns its file with an internal cursor -- cross-iter reuse
would grow the file unboundedly. Apply a defensive iteration bound
via reduced sample_size and warm_up/measurement times instead.

Failure observed in run 25276974185 at io_optimizations.rs:204 during
warm-up of io_uring/io_uring/64kb.
@github-actions github-actions Bot added the bug Something isn't working label May 3, 2026
Mirror the target_tag dispatch pattern from benchmark.yml (PR #3574) so
the Criterion workflow can be re-run against an existing release tag
(e.g. v0.6.1) without requiring a tag push. Adds:

- workflow_dispatch input target_tag
- Resolve release tag step that prefers the dispatch input over the
  push ref
- Updated gates and TAG bindings on Append criterion summary and
  Upload criterion results to use the resolved tag

Required when the original tag-triggered Criterion run failed (e.g.
v0.6.1 panicked on RLIMIT_MEMLOCK exhaustion) so the rebuilt
benchmark output can be appended to the already-published release
notes without retagging.
@oferchen oferchen changed the title fix(bench): hoist io_uring reader to prevent MEMLOCK exhaustion fix: io_uring bench MEMLOCK + Criterion workflow target_tag May 3, 2026
@oferchen
oferchen merged commit 4a0d9c6 into master May 3, 2026
44 checks passed
@oferchen
oferchen deleted the fix/io-uring-bench-ring-per-iter branch May 3, 2026 13:01
oferchen added a commit that referenced this pull request May 3, 2026
The io_uring write benchmark allocated a fresh ring inside `b.iter()`
via `IoUringWriter::create`, which on CI runners exhausts RLIMIT_MEMLOCK
(each ring + registered buffers locks ~512 KB). When the writer bench
runs immediately after the reader bench, the kernel has not yet
reclaimed the reader's MEMLOCK pages, and the very first writer
iteration panics with `ENOMEM` from `io_uring_setup()`.

Hoist `IoUringWriter::create` outside `b.iter()` and reuse the ring
across iterations via `writer.write_all_batched(data, 0)`. This public
method takes an explicit offset and bypasses the internal write cursor,
so writing to offset 0 every iteration overwrites the file in place
rather than growing it -- so cross-iter reuse is safe. Same pattern as
PR #3575 used for the reader.

Removes the defensive `sample_size`/`warm_up_time`/`measurement_time`
bounds from PR #3575 since they are no longer needed: with one ring per
sub-benchmark we are now within RLIMIT_MEMLOCK regardless of iter count.

Unblocks the Criterion Benchmarks workflow on the v0.6.1 release.
oferchen added a commit that referenced this pull request May 5, 2026
* fix(bench): hoist io_uring reader to prevent MEMLOCK exhaustion

The io_uring read sub-bench in fast_io/io_optimizations.rs was
allocating a fresh ring (and registered-buffer group) per criterion
iteration. With ~6us per read iter, the 3s warm-up + 5s measurement
window allocated hundreds of thousands of rings, exhausting
RLIMIT_MEMLOCK on CI runners and panicking with ENOMEM.

`IoUringReader::read_all_batched` reads from offset 0 each call and
returns registered-buffer slots via Drop, so the reader is safe to
reuse across iterations. Hoist allocation outside `b.iter` (the
allocation also doubles as the existing sentinel guard).

The writer sub-bench has the same per-iter allocation pattern, but
the writer owns its file with an internal cursor -- cross-iter reuse
would grow the file unboundedly. Apply a defensive iteration bound
via reduced sample_size and warm_up/measurement times instead.

Failure observed in run 25276974185 at io_optimizations.rs:204 during
warm-up of io_uring/io_uring/64kb.

* fix(ci): allow Criterion workflow to publish to existing release tag

Mirror the target_tag dispatch pattern from benchmark.yml (PR #3574) so
the Criterion workflow can be re-run against an existing release tag
(e.g. v0.6.1) without requiring a tag push. Adds:

- workflow_dispatch input target_tag
- Resolve release tag step that prefers the dispatch input over the
  push ref
- Updated gates and TAG bindings on Append criterion summary and
  Upload criterion results to use the resolved tag

Required when the original tag-triggered Criterion run failed (e.g.
v0.6.1 panicked on RLIMIT_MEMLOCK exhaustion) so the rebuilt
benchmark output can be appended to the already-published release
notes without retagging.
oferchen added a commit that referenced this pull request May 5, 2026
The io_uring write benchmark allocated a fresh ring inside `b.iter()`
via `IoUringWriter::create`, which on CI runners exhausts RLIMIT_MEMLOCK
(each ring + registered buffers locks ~512 KB). When the writer bench
runs immediately after the reader bench, the kernel has not yet
reclaimed the reader's MEMLOCK pages, and the very first writer
iteration panics with `ENOMEM` from `io_uring_setup()`.

Hoist `IoUringWriter::create` outside `b.iter()` and reuse the ring
across iterations via `writer.write_all_batched(data, 0)`. This public
method takes an explicit offset and bypasses the internal write cursor,
so writing to offset 0 every iteration overwrites the file in place
rather than growing it -- so cross-iter reuse is safe. Same pattern as
PR #3575 used for the reader.

Removes the defensive `sample_size`/`warm_up_time`/`measurement_time`
bounds from PR #3575 since they are no longer needed: with one ring per
sub-benchmark we are now within RLIMIT_MEMLOCK regardless of iter count.

Unblocks the Criterion Benchmarks workflow on the v0.6.1 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant