Skip to content

chore(mp3): re-baseline the CPU audit onto the fixed-point decoder #4110

Closed

Description

@zackees

Context

Carve-out from #4056, which deleted the Helix backend and made the fixed-point minimp3 build the production MP3 decoder.

ci/codec_cpu/audit.py still audits minimp3-float, and only that. That is deliberate, not an oversight: codec_cpu_trend.json's host baselines are keyed by the float build's Callgrind symbols and instruction counts, so pointing the driver at the fixed build would invalidate every baseline in the file at the same moment it changed what is being measured. #4055 already demonstrated what a symbol rename alone does to that file. Both the driver (ci/codec_cpu/driver.cpp) and the object it links (ci/codec_memory/minimp3_audit.cpp) now pin MINIMP3_FLOAT_POINT explicitly so the header's new fixed-point default cannot silently swap the measured decoder.

So today the shipping decoder has no CPU trend row.

What is and is not covered right now

  • Covered: the fixed build's SIMD kernels are gated on being bit-identical to its own scalar path, and on being no slower than it, by tests/fl/codec/mp3_fixed_point.hpp (asserting only under __OPTIMIZE__).
  • Covered: the fixed build's memory and stack footprint, by codec_memory_ledger.md (minimp3-fixed rows, including the gated compiler-derived stack-callgraph figure).
  • Not covered: per-stage operation counts, cycle/IPC medians, Callgrind function attribution, and cross-target codegen for the fixed build — everything codec_cpu_trend.json records.

Proposal

Add minimp3-fixed as a second audited backend rather than replacing minimp3-float, so the float reference build keeps its history and the comparison between the two stays available.

Acceptance criteria

  • ci/codec_cpu/driver.cpp can decode with either variant. The two cannot share a translation unit, so this needs a second namespaced instantiation (MINIMP3_NAMESPACE) or a second driver binary — tests/profile/mp3_memory_audit.cpp has the working pattern for the former.
  • BACKENDS becomes ("minimp3-float", "minimp3-fixed"); _FUSED_STAGES, _operation_stage, and the codegen kernel needles gain fixed-build entries.
  • The operation instrumentation counts integer arithmetic. The existing fmul/fadd taint analysis in instrument_llvm_ir finds nothing in an integer pipeline, and the deleted Helix MULSHIFT32 path is not reusable — the fixed decoder inlines its multiplies rather than routing them through a named helper.
  • New host baselines for minimp3-fixed in codec_cpu_trend.json, generated on the CI host, with the SIMD variant pinned (the vector kernels are the point of measuring it).
  • ci/tests/test_codec_cpu_audit.py covers the new backend's instrumentation the way it covers the float one.

Refs #4056, #4055, FastLED/license#14

Activity

  1. zackees commented on Sep 1, 2026

    @zackees
    MemberAuthor

    One concrete blocker found while wiring #4056, recorded here because this issue is where it will bite.

    fl/stl/stdint.h publishes global uint8_t/int8_t, uint16_t/int16_t, uint32_t/int32_t, size_t, uintptr_t, intptr_t, ptrdiff_t — but for the 64-bit pair it emits:

    typedef fl::u64 u64;
    typedef fl::i64 i64;

    u64/i64, not uint64_t/int64_t. That is why ci/codec_cpu/minimp3_codegen.cpp has had to hand-write typedef fl::u64 uint64_t; since it was created.

    The fixed-point decoder uses int64_t throughout (mp3d_sat64, mp3d_mulshift, mp3d_narrow_q30, the pow43/gain arithmetic), so in a translation unit whose only include path is -I src, the fixed build does not compile:

    minimp3.h:2541:37: error: 'int64_t' was not declared in this scope
     static mp3d_sample_t mp3d_scale_pcm(int64_t sample) FL_NO_EXCEPT
    minimp3.h:2554:5: error: 'int64_t' was not declared in this scope
         int64_t a;
    

    That is real output from xtensa-esp32-elf-g++ on this audit's own TU, from the CI run that caught the missed pin.

    It is not currently a shipping problem: every real platform build reaches <stdint.h> transitively through Arduino/IDF/newlib headers, and the fixed decoder compiles and passes everywhere — including natively here in the same -I src-only configuration, where clang does pull it in. It is specifically the Xtensa cross-compile with a bare include path that exposes the gap, which is exactly the configuration this issue's codegen row needs.

    So whoever picks this up should expect to choose between:

    • adding typedef fl::u64 uint64_t; typedef fl::i64 int64_t; to fl/stl/stdint.h — which is the obvious fix but carries the conflicting-typedef risk that file's own header comment documents at length, since fl::i64's base type has to match the platform's exactly; or
    • converting the fixed-point path in minimp3.h to fl::i64, which is contained to one file, typedef-identical so codegen does not move, and cannot conflict with a system header.

    The second is narrower and is probably the right call for this issue's scope.

  2. moved this from Triage to Done in FastLED Trackeron Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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