Repository navigation
Description
What
#4056 replaced libhelix_mp3 with minimp3 on licensing grounds (RPSL/RCSL → CC0). The swap was validated on correctness and on memory. Its speed was never compared against Helix.
It has been now. Median of 30 runs, pinned to one core, the same five-file corpus / __builtin_readcyclecounter / FNV-1a checksum as ci/codec_cpu/driver.cpp, all decoding 892 frames:
| backend | audit flags | vs Helix | production flags | vs Helix |
|---|---|---|---|---|
| minimp3-float | 163,146,708 | 0.60x | 39,078,828 | 0.60x |
| minimp3-fixed | 660,438,396 | 2.41x | 102,928,770 | 1.59x |
| helix | 274,149,774 | 1.00x | 64,732,068 | 1.00x |
Audit flags = audit.py's -O1 -fno-inline -DMINIMP3_NO_SIMD. Production = -O2, inlining and SIMD on. -fno-inline inflates the gap from 1.59x to 2.41x but does not create it.
minimp3-fixed is what ships on every embedded target — the choice is made in minimp3.h, not by a build flag. So MP3 decoding on microcontrollers got roughly 59% slower, while the float build (hosts only) got 40% faster.
On an ESP32-C6 at 160 MHz, via bash autoresearch esp32c6 --mp3:
decode 155810 us for 235101 us of audio -> 1.51x real time
One stereo 44.1 kHz stream eats two thirds of a core. Extrapolating, Helix would have been near 2.4x. That delta is the headroom for LED output, network and UI.
Two things worse than the number
1. The shipping build is not gated on host CPU. codec_cpu_trend.json's host_baselines contains only minimp3-float, on all three CI hosts. audit.py declares BACKENDS = ("minimp3-float", "minimp3-fixed") and measures both, so minimp3-fixed produces host cycle and Callgrind figures every run with nothing recorded to compare them against. It can regress indefinitely without tripping anything. Helix had full baselines; they were deleted with the backend.
2. codec_cpu_ledger.md has never existed, though .github/workflows/mp3_cpu_audit.yml path-filters on it. I first concluded "Helix was never profiled" by grepping that file — grep -c on a missing file returns 0 and I read it as evidence of absence. The real store is codec_cpu_trend.json, which had Helix's full Callgrind and cross-target codegen all along.
Recovered Helix baselines
From git show 6990cdc3e4^:codec_cpu_trend.json — Callgrind, AMD EPYC 7763, clang 18:
| backend | instructions | branches | branch misses |
|---|---|---|---|
| helix | 461,845,281 | 8,294,798 | 453,948 |
| minimp3-float | 261,532,799 | 22,461,967 | 555,920 |
Helix hot functions: Subband 301,950,654 · PolyphaseStereo 192,621,420 · IMDCT 101,035,762 · MADD64 96,979,680 · IMDCT36 81,616,669.
Note minimp3-float executes fewer instructions but 2.7x the branches (22.5M vs 8.3M) and more branch misses. That is a lead in itself.
Where to look
Synthesis is the hot kernel in both. minimp3-fixed does 26,434,368 multiplies there against 6,014,848 in the IMDCT; Helix spends 301M instructions in Subband plus 192M in PolyphaseStereo — the same stage.
Per-frame host medians, and the most concrete lead: the fixed build's huffman stage is 12,134 ns/frame against the float build's 7,373, despite huffman being integer work in both. That is not explained by fixed-point DSP and is worth understanding first.
Tasks
- Record a
minimp3-fixedhost baseline incodec_cpu_trend.jsonso the shipping build is actually gated - Either create
codec_cpu_ledger.mdor drop it from the workflow's path filters - Explain the huffman regression (12,134 vs 7,373 ns/frame) — integer work in both builds
- Profile synthesis/polyphase in the fixed build against Helix's
Subband+PolyphaseStereo - Re-measure on a 32-bit target: fix(mp3): signed overflow (UB) in fixed-point mp3d_synth_pair on malformed input #4133 cost +78% on armv7m/riscv32/i386 and 0% on x86-64, so host ratios may understate the embedded gap
- Decide whether the fixed-point path needs SIMD kernels on the targets that have them
- Upstream whatever comes out of this to lieff/minimp3 — the fixed-point port is a FastLED fork and these findings are of general interest
Caveats
- Host x86-64, not embedded. 32-bit targets behave very differently for this decoder.
- Helix ships hand-written ARM assembly (
real/arm/asmpoly_gcc.S) that does not participate on x86. On a Cortex-M the Helix side would likely be better, widening the gap. - Helix was not restored to the tree and must not be. Reproducible from git history; the RPSL/RCSL obligations are why it was removed.
Full method, recovered data and reproduction steps: agents/docs/mp3-decoder-performance.md.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 1, 2026
Correction: the numbers above were measured on a loaded machine
I have to walk back the headline figure. The measurements in the issue body were taken while several Teensy/ESP32 compiles were running — load average 12. Re-measured on a quiet machine with
audit.py's own affinity pinning and 30-run medians, three consecutive trials:minimp3-fixed is ~1.18x Helix at audit flags, not 2.41x. Every absolute number in the original run was inflated ~3x, including for binaries I never rebuilt, which is the tell I should have caught at the time.
Production flags (
-O2, inlining, SIMD) are still noisy on this host — three trials gave 1.405x, 1.447x and 1.232x, with one Helix baseline landing at 108M against 64M for the other two. So the production figure is somewhere around 1.2–1.45x and needs a genuinely idle machine to pin down. My reported 1.59x came from the same loaded run and should not be relied on.What survives
The direction holds and the ranking is unchanged:
So the shipping fixed-point build is still slower than the decoder it replaced, and the float build is still much faster. But ~18% is a materially different problem from ~59%, and the acceptance criteria in #4139 were written against the wrong number.
What does not survive
"minimp3-fixed is 59% slower" — withdrawn.
The two structural findings are unaffected, since they are not measurements:
codec_cpu_trend.json'shost_baselinesstill contains onlyminimp3-float, so the shipping build has nothing to compare against.codec_cpu_ledger.mdstill does not exist despite the workflow path-filtering on it.Method fix
The audit now builds Helix as a third backend and prints the ratio on every run, so this stops depending on someone remembering to measure by hand:
Lesson worth recording: I compared numbers from two separate runs without checking that the machine state matched between them. The 3x shift in binaries I had not touched was visible in the data and I read past it.
perf(mp3): find the gap with Callgrind -- saturation is 24% of the de…
zackees commentedon Sep 1, 2026
Clarification on the ratio direction. The tables above report
backend / helixin instructions executed, so higher is worse.1.59xmeans minimp3-fixed does 59% more work than Helix — it is the slower one. Written as a bare multiplier that reads naturally as "1.59x faster", which is the opposite of what it says.The audit now prints the direction with the number (
sense=slower:pct=59) so this cannot be misread from CI output.perf(mp3): drop the DCT/IMDCT butterfly clamp -- 28% faster on the C6
perf(mp3): force-inline the hot leaf helpers -- 50% faster on the C6
perf(mp3): route mp3d_mulshift through fl::math::mul_shift_round32
perf(mp3): unsaturated narrow and a mono polyphase; add the measureme…
perf(mp3): restructure the polyphase lane loop -- 12% faster on the C6
perf(mp3): fixed-point decoder is 3.5x faster on an ESP32-C6
zackees commentedon Sep 3, 2026
Concrete CI evidence that this is now failing on
master, not just a latent perf concern.#4140 was merged with its
auditcheck red, and the same check is red on every branch cut from master since. The failing assertion is the SIMD-not-slower-than-scalar gate infl_codec:Job step is literally named "Verify the fixed-point SIMD is not slower than scalar" (
bash test fl_codec --cpp --build-mode release), so on theubuntu-24.04x86-64 runner the fixed-point SIMD path is 6.5% slower than its own scalar path. Observed on PR #4141's run — a PR whose only change is a one-line dependency cap inpyproject.toml, so it cannot be the cause.Accuracy in the same run is fine, for what it is worth:
Per
CLAUDE.md, host and device have disagreed on this in both direction and magnitude, so0.935xon a GitHub runner is not the device number and should not be read as one. The reportable part is narrower and does not depend on host-vs-device: master is red onauditand stays red until either the SIMD path gets faster than scalar on x86-64 or the gate is changed to reflect what it is actually meant to assert.There is a second, separate red check from the same merge — see my note on the bloat baseline (
esp32s3is +198 B overtests/data/esp32s3_bloat_baseline.txt). Both should be resolved before the next PR merges, or reviewers get trained to merge through red.fix(ci): the RunningProcess migration broke three tools; measure, don…
test: accept TM1908 encoder flash cost
chore(mp3): re-baseline the fixed-point codegen bounds after the DCT-…
zackees commentedon Sep 3, 2026
The
MP3 CPU auditworkflow is green on master again as of #4148 (d1da8f3). Two stale baselines were behind the red check, both left over from #4140: the cross-compiled codegen bounds, and the primary host Callgrind profile forminimp3-fixed(659M instructions recorded vs 330M now). The latter only tripped on runners that gate the fixed backend, which is why it surfaced after the first fix. Nothing about the fixed-vs-Helix gap itself changed; this comment is only about the gate.zackees commentedon Sep 5, 2026
Closing as completed. The problem this issue reports is fixed and the shipping build is now gated.
codec_cpu_trend.jsonnow carries a Callgrind, cross-target codegen and exact-operation baseline forminimp3-fixed, re-baselined in chore(mp3): re-baseline the fixed-point codegen bounds after the DCT-32 rework #4148 and green on master. Thehost_baselinessection still lists only float, but since test(mp3): CPU trend gates cycle counts at 5%, which is below the runner pool's own variance #4130 that section holds only ungated cycle figures, so it no longer matters.agents/docs/mp3-decoder-performance.md, and perf(mp3): integer SIMD for the fixed-point decoder (#4055) #4107 / perf(mp3): vectorise the fixed-point IMDCT twiddle loop (#4109) #4118 for the SIMD kernels.Three tasks from the list were not done and are moved to #4155 so they are not lost: the
codec_cpu_ledger.mdpath filter in the audit workflow, the unexplained huffman-stage difference between the fixed and float builds, and upstreaming the findings to lieff/minimp3.🤖 Generated with Claude Code
https://claude.ai/code/session_01XQyTuAVs4tK9pDcxAZVqVe