Skip to content

fix(ci): guard zero-ratio in benchmark chart - #3574

Merged
oferchen merged 1 commit into
masterfrom
fix/benchmark-chart-zero-ratio
May 3, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/benchmark-chart-zero-ratio

Conversation

@oferchen

@oferchen oferchen commented May 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Guard ratio <= 0 in ratio_text() to fix ZeroDivisionError that broke the v0.6.1 Benchmark workflow twice (runs 25271859729, 25276974191).
  • Extract speedup classification thresholds into named constants (RATIO_FASTER_BELOW, RATIO_SAME_UPPER).
  • Add target_tag workflow_dispatch input 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.py rounds the oc_rsync / upstream timing ratio to 2 decimals. Sub-millisecond ratios (e.g. 0.004 = 250x faster) collapse to exactly 0.0. benchmark_chart.py:273 then computes 1.0 / ratio and 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

  • Unit-validated ratio_text locally: 0.0 -> ">100x faster", -0.5 -> ">100x faster", 0.04 -> "25.0x faster", 1.0 -> "~same", 2.5 -> "2.5x slower".
  • CI green on this PR (fmt+clippy, nextest, Windows, macOS, Linux musl).
  • After merge: gh workflow run benchmark.yml --ref master -f target_tag=v0.6.1 to 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.

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".
@github-actions github-actions Bot added the bug Something isn't working label May 3, 2026
@oferchen
oferchen merged commit 016766d into master May 3, 2026
8 checks passed
@oferchen
oferchen deleted the fix/benchmark-chart-zero-ratio branch May 3, 2026 11:59
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.
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