Skip to content

test(mp3): CPU trend gates cycle counts at 5%, which is below the runner pool's own variance #4130

Closed

Description

@zackees

What happens

ci/codec_cpu/audit.py gates counter_median.cycles at a 5% budget. That is tighter than the variance between machines in the ubuntu-24.04 pool, so the check fails on PRs that provably cannot have caused it.

Observed on #4128, whose only code change is inside #if MINIMP3_HAVE_FIXED_POINT blocks and therefore cannot alter the float build at all:

RuntimeError: minimp3-float/counter/cycles regressed: 46509592.0 > 45758997.900000

The discriminator is in the same run's output:

metric baseline this run delta
callgrind instructions 261,532,799 261,533,566 +0.0003%
counter cycles 43,580,950 (alt host) 46,509,592 +6.7%

Identical work, different cycles. Callgrind instruction counts are deterministic and confirm the float decoder executed the same instructions to within 767 out of 261.5 million. Only the wall-clock-derived cycle counter moved.

Why host-keying does not currently save it

check_trend already host-keys baselines by cpu_model | compiler | governor (#4064) and falls back to host_baselines for known hosts. But that key does not separate machines — two runners reporting the same CPU model and governor can differ by more than 5% in cycles depending on neighbour contention on the hypervisor. The key identifies a CPU family, not a performance environment.

This is the second instance of the same shape

#4106 was exactly this: a host-dependent measurement (stack-watermark-observed) gated as if it were deterministic, failing unrelated PRs. That one was fixed by removing the host dependence at the source — the harness stopped calling into glibc, and the number became reproducible.

The equivalent move here is to stop gating on the metric that carries the host dependence, and keep gating the one that does not.

Options

  1. Demote cycles to informational, keep callgrind/instructions as the gate. Instructions are deterministic, already collected, already gated, and already caught real regressions. Cycles then get recorded for trend-watching without failing builds. This mirrors what test(mp3): helix stack-watermark-observed is flaky and can fail the memory audit spuriously #4106 concluded about the watermark, and is the option I would take.
  2. Widen the cycles budget to something above the observed pool spread. Requires characterising that spread first — a handful of repeat runs on the same commit would establish it — and leaves a weaker gate that still fires occasionally.
  3. Key baselines per machine. Not really available: runners are ephemeral and expose no stable identity beyond CPU model.

Option 1 keeps a strict gate on the thing that actually measures the code, and stops a noise source from blocking review.

Acceptance criteria

  • cycles (and ipc, which is derived from it) no longer fail the build; they are reported and recorded.
  • callgrind/instructions, callgrind/branches, callgrind/branch_misses, the per-function attribution shares, the exact operation ledger and the target codegen bounds all stay gated.
  • The demotion is visible in output, not silent -- print the delta so a real slowdown is still noticeable to a human reading the log.
  • codec_cpu_trend.json prose or ci/codec_cpu/audit.py records why, so the next person does not "restore" the gate without reading this.

Found while landing #4128 (#4127).

Refs #4106, #4064, #4127

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions