Repository navigation
Description
What happens
ci/codec_memory/audit.py's stack-watermark-observed metric for the helix backend is not reproducible across CI runs. On identical decoder code (PR #4105; two pushes differing only in codec_cpu_trend.json, which the memory audit does not read):
| run | helix | minimp3-float | result |
|---|---|---|---|
| 33451259174 | 1736 | 2056 | pass |
| 33451529474 | 3336 | 2056 | fail |
| same run, re-run of the failed job | 3336 | 2056 | fail |
| local, clang 21.1.5 | 1816 | 2056 | n/a |
The ledger records 1736 with a 2% allowance, so 3336 fails the gate.
Two things are worth noting. minimp3-float is identical to the byte in every one of those — only helix moves. And the two CI values are each exact and one of them reproduced on a re-run, so this is not noise around a mean; it is the measurement landing on genuinely different answers depending on something about the environment. Both runs used runner image ubuntu-24.04 version 20260823.283.1, so the image is not the variable, and the audit does not log enough about the host to say what is. (The CPU trend already host-keys its baselines by CPU model and fails closed on unknown hosts, from #4064, because the ubuntu-24.04 pool rotates hardware — the memory ledger has a single global baseline for a measurement with comparable sensitivity.)
Where the sensitivity comes from
finishWatermark in ci/codec_memory/watermark.cpp scans the painted region from the bottom and takes the first byte that no longer equals PATTERN as the deepest point the decode reached:
for (size_t i = 0; i < painted_bytes; ++i) {
if (context->stack[i] != PATTERN) { first_changed = i; break; }
}So the metric is the deepest byte anything disturbed, not the deepest byte the decoder used. A single excursion below the real high-water mark — a lazy PLT resolution on the first call into the decoder, a signal frame, allocator or valgrind bookkeeping — moves the figure by kilobytes. Helix is more exposed than minimp3 because its first decode call resolves considerably more.
I am not certain that is the whole story, and a naive "require N consecutive disturbed bytes" filter would not help if the disturbance is a real frame. The mechanism needs someone to actually instrument it rather than reason about it.
Why it matters
It is a required check on any PR touching src/fl/codec/mp3* or the third-party decoder trees, so it fails those PRs on a metric unrelated to the change under review. It cost #4105 two reds.
Suggested direction
The ledger's own prose already says the acceptance gate is the other metric:
The 2 KiB acceptance gate uses the compiler-derived, optimized decoder callgraph
and describes the watermark as "a conservative observation that includes the audit call boundary and its 256-byte safety guard". check_ledger does not reflect that — it applies the same 2% hard gate to both. #4105 demotes stack-watermark-observed to informational (still measured, still required to be present in the ledger, no longer regression-gated) so the deterministic budget keeps enforcing and the non-reproducible number stops blocking.
That is a stopgap. The real fix is one of:
- host-key the memory ledger the way
codec_cpu_trend.jsonhost-keys its baselines, failing closed on unknown hosts; or - make the measurement itself reproducible — instrument the minimum stack pointer reached rather than inferring it from a paint pattern, which removes the "anything else touched this" failure mode entirely.
Note that helix disappears with #4056, but minimp3's row is measured by the same code and is exposed to the same mechanism, so deleting helix does not resolve this.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(ci): stop regression-gating a stack watermark that is not reprodu…
feat(mp3): fixed-point minimp3 DSP path (#4054) (#4105)
fix(mp3): make the decode stack watermark reproducible (FastLED#4106) (…