Repository navigation
fix(ci): guard zero-ratio in benchmark chart - #3574
Merged
Merged
Conversation
The Benchmark workflow has failed twice on v0.6.1 with a ZeroDivisionError in benchmark_chart.py:273. Root cause: ratio_text() does `1.0 / ratio` without guarding `ratio == 0`, but benchmark.py rounds ratios to 2 decimals, collapsing sub-millisecond ratios (e.g. 0.004 = 250x faster) to exactly 0.0. The chart consumer then divides by zero. Fix in two places: 1. benchmark_chart.py: add a `ratio <= 0` guard at the top of ratio_text() that returns ">100x faster" with COLOR_FASTER. Extract magic numbers into RATIO_FASTER_BELOW (0.95) and RATIO_SAME_UPPER (1.05) constants so the classification thresholds are named. 2. benchmark.yml: add a `target_tag` workflow_dispatch input and a "Resolve release tag" step. This lets us dispatch the workflow from master (with the fixed chart script) and still publish artifacts to an existing release tag whose tag-triggered run failed - no retag needed. Validated locally: ratio 0.0 -> ">100x faster", -0.5 -> ">100x faster", 0.04 -> "25.0x faster", 1.0 -> "~same", 2.5 -> "2.5x slower".
oferchen
added a commit
that referenced
this pull request
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
added a commit
that referenced
this pull request
May 3, 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
…tch (#3574) The Benchmark workflow has failed twice on v0.6.1 with a ZeroDivisionError in benchmark_chart.py:273. Root cause: ratio_text() does `1.0 / ratio` without guarding `ratio == 0`, but benchmark.py rounds ratios to 2 decimals, collapsing sub-millisecond ratios (e.g. 0.004 = 250x faster) to exactly 0.0. The chart consumer then divides by zero. Fix in two places: 1. benchmark_chart.py: add a `ratio <= 0` guard at the top of ratio_text() that returns ">100x faster" with COLOR_FASTER. Extract magic numbers into RATIO_FASTER_BELOW (0.95) and RATIO_SAME_UPPER (1.05) constants so the classification thresholds are named. 2. benchmark.yml: add a `target_tag` workflow_dispatch input and a "Resolve release tag" step. This lets us dispatch the workflow from master (with the fixed chart script) and still publish artifacts to an existing release tag whose tag-triggered run failed - no retag needed. Validated locally: ratio 0.0 -> ">100x faster", -0.5 -> ">100x faster", 0.04 -> "25.0x faster", 1.0 -> "~same", 2.5 -> "2.5x slower".
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.
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ratio <= 0inratio_text()to fixZeroDivisionErrorthat broke the v0.6.1 Benchmark workflow twice (runs 25271859729, 25276974191).RATIO_FASTER_BELOW,RATIO_SAME_UPPER).target_tagworkflow_dispatchinput and a "Resolve release tag" step so we can dispatch the Benchmark workflow from master and still publish artifacts to an existing release tag without retagging.Root cause
benchmark.pyrounds theoc_rsync / upstreamtiming ratio to 2 decimals. Sub-millisecond ratios (e.g.0.004= 250x faster) collapse to exactly0.0.benchmark_chart.py:273then computes1.0 / ratioand crashes the entire chart-generation step. Because the chart step is non-conditional, the workflow fails before the release-publish steps run, so no benchmark.png and no Performance Benchmark section land on the release.Why this matters now
v0.6.0 happened to have no zero-ratio entries; v0.6.1 does. Both v0.6.1 tag-triggered runs of the Benchmark workflow have failed at this exact line. The Criterion Benchmarks workflow (separate file) is unaffected.
Test plan
ratio_textlocally:0.0 -> ">100x faster",-0.5 -> ">100x faster",0.04 -> "25.0x faster",1.0 -> "~same",2.5 -> "2.5x slower".gh workflow run benchmark.yml --ref master -f target_tag=v0.6.1to publish the missing chart + notes section to the v0.6.1 release. Master HEAD is byte-identical to v0.6.1 modulo this one tooling change, so the benchmarked binary represents v0.6.1 exactly.