Repository navigation
Description
Follow-up to #4138 and #4139, which are closed: the fixed-point decoder went from 3.99x Helix on an ESP32-C6 to 1.13x (#4140, #4150), and the shipping backend is now gated on a Callgrind, codegen and exact-operation baseline in codec_cpu_trend.json (#4148). Three items from those issues were never done and are collected here so they do not get lost.
1. codec_cpu_ledger.md does not exist but the workflow path-filters on it
.github/workflows/mp3_cpu_audit.yml lists codec_cpu_ledger.md in both its push and pull_request path filters (lines 19 and 34). The file has never existed; the real store is codec_cpu_trend.json. Either drop the two entries or create the file. Dropping is the simpler fix.
2. The fixed build's huffman stage is unexplained
Per-frame host medians recorded in agents/docs/mp3-decoder-performance.md:
| stage | float | fixed |
|---|---|---|
| huffman | 7,373 ns | 12,134 ns |
Huffman is integer work in both builds, so the fixed-point DSP does not explain a 1.6x difference there. Worth a Callgrind diff of L3_huffman between the two builds. It may be scratch-clearing or inlining differences rather than the decoder itself; ecb3d0588d already trimmed the scratch clear, so re-measure before assuming the number in the doc is current.
3. Nothing has gone upstream to lieff/minimp3
The fixed-point port is a FastLED fork. The findings that are of general interest and not FastLED-specific:
mp3d_sat64on every polyphase intermediate is redundant on conformant input (zero clamps across 82.5M calls on real music; all 4,609 clamps in the ISO suite come froml3-nonstandard-big-iscf).mp3d_mulshift_kfor constant coefficients on targets without a single-register 64-bit product.- The int64-heavy arithmetic is roughly free on x86-64 and 4x on a 32-bit RISC-V core, so host ratios understate the embedded gap.
Open an issue or PR against https://github.com/lieff/minimp3 pointing at the relevant commits.
Not in scope
- A Fast/HQ mode split. perf(mp3): add a fast fixed-point mode at Helix parity, keeping today's decoder as HQ #4139 concluded it is unnecessary; the gap was saturation cost, not a precision trade.
- The 16-bit MAC path. Measured at 44.37 dB (perf(mp3): ESP32-S3 PIE kernels for the fixed-point polyphase and DCT-32 #4108), below the ISO floor. Do not re-run.
- Chasing the remaining 1.13x to the 1.1x stretch goal. Fine to do, but it is optimisation work, not housekeeping, and
bash mp3measureis the tool.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
fix(autoresearch): make BLE bring-up name the board that actually ans…
zackees commentedon Sep 7, 2026
The first item here — the dead
codec_cpu_ledger.mdpath filter — is done. It landed in #4176, which carried the identical two-line deletion alongside its own changes, so #4175 was closed as already applied (rebasing it ontomasterdrops the commit with "patch contents already upstream").The other two items in this issue are untouched.
One thing surfaced while chasing #4175's red CI that is worth recording here, since it lives in the same workflow. The MP3 SIMD-vs-scalar gate is runner-dependent: it measures 1.080x on some GitHub runners and 0.904–0.945x on others, a 19% spread across a fleet that is not one machine. It is not noise and it is not a straightforward regression — the kernel is genuinely faster on some GHA silicon and genuinely slower on other. It takes
masterred at random.That is tracked separately in #4183, and #4192 has landed the diagnostics (the ratio, whether it was enforced, and the runner CPU are now recorded on passing runs too). Mentioning it here only because anyone picking up the remaining
mp3_cpu_audit.ymlwork will run into it.docs(mp3): the huffman lead was stale and its premise was wrong (#4155)…
fix(mp3): the SIMD gate measures the runner fleet, not the kernel (#4183
zackees commentedon Sep 10, 2026
Item 2 is done as well — closed in #4254, and the answer was "no"
Following the triage comment above, which left items 2 and 3 open. Item 2 is no longer one of them; it was resolved on 2026-09-09 in #4254 (
a75d510573) and recorded inagents/docs/mp3-decoder-performance.md, but nothing said so here.This issue asked for a Callgrind diff of
L3_huffman. That diff was not run, deliberately, because the two premises behind it both failed the re-measurement this issue itself asked for:The number was stale. The 12,134 ns in the table came from before
ecb3d0588dtrimmed the scratch clear. Re-measured it is 9,127 ns, a 1.24x ratio rather than 1.65x. What makes that believable rather than machine drift is the float side: it reproduces its old 7,373 to within 0.5% on the same host, so only the fixed side moved.And the premise was wrong. The issue's reasoning was "huffman is integer work in both builds, so the fixed-point DSP does not explain the difference". It is not integer-only work —
audit.pydeclaresdequantfused intohuffmanfor both minimp3 backends, which is why thedequantrow reads 0.0 ns. minimp3 dequantises inline as it decodes, and the two builds differ there by construction:A mantissa/exponent dequant call against one float multiply per coefficient. So the residual 1.24x is the arithmetic doing exactly what it was changed to do, not an anomaly. The Callgrind diff would have shown that and nothing else.
Where the time actually goes, from the same table: IMDCT 3.05x, stereo 2.77x, antialias 2.58x — all genuine DSP stages, all larger multiples than huffman ever was.
What is left
Only item 3, upstreaming to lieff/minimp3. I have not done it: it means opening an issue or PR on a third-party project under your GitHub identity, which is not something I will do without you saying so explicitly. The three findings are written up and ready if you want them filed — say the word and I will draft the upstream issue text here for you to post, or post it myself if you would rather.
zackees commentedon Sep 10, 2026
Two of the three are already done; the third is the only one left, and it is not mine to send
Checked each item against the tree rather than against the issue text.
1. Ledger path filter — done, incidentally
mp3_cpu_audit.ymlno longer path-filters oncodec_cpu_ledger.md. Bothpushandpull_requestnow listcodec_cpu_trend.json, the store that actually exists:It went out in #4176 (
git log -S "codec_cpu_ledger.md"shows it added by #4064 and removed there) — not as part of this issue, which is why it was never marked. Every path the workflow filters on now resolves; I checked them individually, so there is no second instance of the same bug hiding in the list.2. Huffman — done, and the premise was wrong
agents/docs/mp3-decoder-performance.mdcarries a section named for this issue ("The huffman stage is not the lead it looked like"). Both halves of the item failed:ecb3d0588dtrimmed the scratch clear between the measurements — exactly the "re-measure before assuming the number is current" this issue warned about, and it was the right warning.audit.pyfusesdequantintohuffmanfor both minimp3 backends, because minimp3 dequantises inline as it decodes. So the stage differs by construction: one float multiply per coefficient (g_pow43[idx]*one) against a mantissa/exponentmp3d_dequantcall. A residual 1.24x is the arithmetic doing what it was changed to do.The doc states plainly that the Callgrind diff this issue asked for "would have shown this and nothing else, which is why it was not run" — a defensible reason not to run a measurement, since the attribution was already decided by
audit.py's own stage fusion. The real weight is IMDCT 3.05x, stereo 2.77x, antialias 2.58x.3. Upstreaming to lieff/minimp3 — outstanding, and deliberately not done here
This is the only item left. I have not opened it, because filing an issue or PR on a third-party repository is an outward-facing action under someone else's name and a maintainer's call, not a housekeeping step I should take on my own. The three findings are ready to send as written:
mp3d_sat64on every polyphase intermediate is redundant on conformant input — zero clamps across 82.5M calls on real music; all 4,609 in the ISO suite come froml3-nonstandard-big-iscf.mp3d_mulshift_kfor constant coefficients on targets without a single-register 64-bit product.Say the word and I will draft it against https://github.com/lieff/minimp3 with links to the relevant commits.
So this issue reduces to item 3. Items 1 and 2 can be struck.
docs(mp3): the ledger path filter is gone; stop saying it is there (#…
zackees commentedon Sep 12, 2026
Item 1 is done — and most of it turned out to be already done.
The workflow no longer path-filters on
codec_cpu_ledger.md; both itspushandpull_requestfilters listcodec_cpu_trend.jsonalone, and the name appears nowhere under.github/. What was left wasagents/docs/mp3-decoder-performance.md, which still described the filter as present:Corrected in #4389. The warning that paragraph exists for — do not conclude "Helix was never profiled" from
grep -con a missing file — is kept, since that is the mistake the whole note is guarding against.Item 2 may be reachable locally after all
Worth recording before anyone else is put off. My working notes said Callgrind is unusable on this host, which is true of
ci/codec_cpu/audit.py --check: it passes--instr-atstart=no, and NixOS valgrind 3.26.0 then writestotals: 0— one value for five events — soparse_callgrinddies withzip() argument 2 is shorter.But
ci/codec_cpu/callgrind.pypasses--instr-atstart=yes(line 311), which is the case that does not trip it. So theL3_huffmanfloat-vs-fixed diff this item asks for is probably runnable here, and "Callgrind does not work on this machine" is too broad a conclusion to carry forward.Also still true, per the issue:
ecb3d0588dtrimmed the scratch clear after those medians were recorded, so the 7,373 / 12,134 ns figures want re-measuring before anything is inferred from the 1.6x.Item 3 unchanged
Opening an issue or PR against
lieff/minimp3is outward-facing. That needs a maintainer's go-ahead rather than an agent's, so it stays open.zackees commentedon Sep 12, 2026
Item 2 is resolved, and I can now confirm empirically the one claim its resolution makes without evidence.
agents/docs/mp3-decoder-performance.mdalready carries the answer under "The huffman stage is not the lead it looked like": the 12,134 ns figure was stale (re-measured at 9,127, a 1.24x ratio), and the premise was wrong becauseaudit.pyfusesdequantintohuffmanfor both minimp3 backends — minimp3 dequantises inline as it decodes, so the row was never integer-only work.That section ends with:
I ran it, and that is right.
L3_huffmanhas no separate symbol to diff:callgrind_annotateat a 99.99% threshold lists every minimp3 symbol in the binary, andL3_huffmanis not among them — it is inlined intomp3dec_decode_frame_r. The only "huffman" string anywhere in the profile is the stage-name array itself.So the diff would have returned nothing, exactly as claimed. What it does show is
mp3dec_decode_frame_rat 44.9M against 26.5M instructions, a ratio of 1.69 — close to the 1.65x the old stage timer reported, which is consistent with that timer bracketing a region Callgrind sees as one inlined function containing huffman, dequant, stereo and reorder together.Worth correcting in my previous comment
I said above that Callgrind was "probably runnable here" because
callgrind.pypasses--instr-atstart=yes. That is confirmed — it ran clean, both decoders, no parser failure. Thetotals: 0problem is specific toaudit.py --checkand its--instr-atstart=no.Remaining
Only item 3, opening an issue or PR against
lieff/minimp3. That is outward-facing and wants a maintainer's decision rather than an agent's, so I am leaving this issue open on that alone.