Skip to content

Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886

Open

Description

@zackees

Goal

Take ESP32-S3 NEOPIXEL Blink from 388,380 B flash baseline (master 2026-05) toward ≤ 280,000 B (-28%) via knob flips, default changes, and dead-code suppression. No public API changes.

Single source of truth: docs/SLIM_ESP32S3.md is the live tracker for every shipped + projected flag and its measured savings. This issue mirrors it as a coordinated checkpoint; for the per-flag detail (mechanism, constraint, measured bytes, owning PR) read SLIM.

Tool used to generate every number / file path / line citation in this issue:

bash bloat esp32s3 --top 25
# → .build/symbols/esp32s3/{report.json, report.md}

Background analysis lives in agents/docs/binary-size-analysis.md. This issue supersedes #2885.


Current state (mirrors docs/SLIM_ESP32S3.md flag tracker)

Each row is an independently-mergeable knob with a measured-or-projected size impact. Status ✅ = merged + measured; 📊 = merged + projection-only; ⏳ = not started.

# Knob Mechanism Measured / projected Status Owning PR
1 FASTLED_LOG_VERBOSITY=0 Default-on for release (NDEBUG); restore with -DFASTLED_LOG_VERBOSITY=1 −50,391 B (cascade) ✅ #2890
2 tools/sdkconfig_for_smallest_fastled.defaults board_build.sdkconfig_defaults in platformio.ini; bundles CONFIG_NEWLIB_NANO_FORMAT=y −59,224 B ✅ #2896, #2915
3 -DFASTLED_RMT_STATIC_ALLOCATION=1 build_flags; only for sketches that init in setup() and never removeLeds() −908 B (below projection) ✅ #2846
4 -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1 build_flags; strong-overrides the Arduino-ESP32 weak shouldPrintChipDebugReport() ~3 KB 📊 #2894
5 CONFIG_BT_ENABLED=n Uncomment the situational block in tools/sdkconfig_for_smallest_fastled.defaults ~15 KB (if currently on) 📊 —
6 -DFASTLED_DISABLE_SPI_CHIPSETS=1 build_flags; drops SPI dispatch branch in Channel::showPixels. Constraint: clockless-only sketches ~1.0-1.2 KB 📊 #2913
7 -DFASTLED_DISABLE_UCS7604=1 build_flags; drops UCS7604 cases in Channel::showPixels's clockless switch −3,804 B (6-9× projection) ✅ #2920
8 -DFASTLED_DISABLE_DYNAMIC_DRIVER=1 build_flags; gates out Channel::resolveDynamicDriver() lookup chain −937 B ✅ #2926
9 -DFASTLED_DISABLE_CHANNEL_EVENTS=1 build_flags; replaces 7 fl::function_list event slots with no-op fallbacks −8,034 B (4-8× projection) ✅ #2931

Cumulative measured progress on default sketch: 388,380 B → 338,117 B (-50,263 B / -13%). Achievable by enabling all 📊 rows above is an estimated additional ~20-25 KB, putting us within the 280 KB target window assuming Row 5 (BT disable) is acceptable for the sketch.


Remaining open work (after the SLIM tracker)

Items that don't fit the per-flag mould — they're code-change interventions that need their own PR rather than a build_flags toggle:

Stage 4 — Cold-helper audit of remaining FastLED hot paths (~3-5 KB)

After Stage 1 collapsed the FL_WARN strings, residual code bytes are what's left. Audit targets:

  • fl::ChannelManager::addDriver and friends — file:line refs in the Top 25 table below.
  • fl::Channel::resolveDynamicDriver (already gated by Row 8 above but the gated-off path could shrink further).
  • Rmt5EncoderImpl::initialize warn-cluster — projected ~1 KB once the printf-style log backend lands (sibling Meta: ESP32-S3 binary-size reduction — Batch 3 (successor to #2773) #2856 item 3.2).

Status: ⏳ not started.

Stage 5 — fl::basic_string::write simplification (~0.5-1 KB)

src/fl/stl/basic_string.cpp.hpp:193 defines three write(const char*, fl::size) overloads (lines 193, 198, 200) that share most of their machinery with formatted-stream code paths. Simplification should consolidate them.

Status: ⏳ not started.

Stage 6 — Verification gate

CI bloat regression gate with ratcheting baseline. Status: ✅ shipped in #2900 (#2949 ratchet, #2906/#2936/#2959 doc updates).


Top 25 symbols (flash) — historical reference

The original size analysis is preserved here for reference; the file:line citations remain valid even after the staged shipments above.

firmware.bin (pre-Stage-1) = 388,380 B flash + 37,460 B RAM; 3,685 sized flash symbols.

Top archives (pre-Stage-1)

Bytes % Archive
87,271 22.5 % libFastLED.a
60,254 15.5 % (sketch) main.cpp.o
54,458 14.0 % libc.a (newlib printf engine)
18,198 4.7 % libesp_hw_support.a
15,743 4.1 % libFrameworkArduino.a
14,091 3.6 % libfreertos.a
13,886 3.6 % libhal.a
13,387 3.4 % libesp_driver_uart.a
11,842 3.1 % libesp_system.a
11,348 2.9 % libspi_flash.a
8,193 2.1 % libespcoredump.a
7,377 1.9 % libnvs_flash.a

Top 25 symbols (pre-Stage-1)

# Bytes Symbol Defined at Where the bytes went
1 58,770 fl::ClocklessIdf5<3, WS2812_800KHZ, GRB, 0, false, 280>::ClocklessIdf5() src/platforms/esp/32/drivers/rmt/rmt_5/idf5_clockless.h:33 75 FL_WARN/FL_LOG sites in channel_driver_rmt.cpp.hpp; 59 in rmt_memory_manager.cpp.hpp; 6 in channels/manager.cpp.hpp; 5 in channels/channel.cpp.hpp. Largely collapsed by Stage 1 (Row 1) — restore with FASTLED_LOG_VERBOSITY=1.
2-7 ~36 KB newlib _vfprintf_r cluster libc.a Replaced by CONFIG_NEWLIB_NANO_FORMAT=y (Stage 3 / Row 2).
15 2,002 fl::ChannelManager::addDriver(int, fl::shared_ptr<IChannelDriver>) src/fl/channels/manager.cpp.hpp:51 FL_WARN/FL_DBG at lines 53, 62, 76, 82, 95, 131. Mostly addressed by Stage 1. Remaining Stage 4 target.
18, 25 1,835 + 1,103 esp_core_dump_* esp-idf libespcoredump.a Disabled by CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n (Stage 3 / Row 2).
19 1,604 diag_log_add esp-idf Disabled by CONFIG_LOG_DEFAULT_LEVEL=ESP_LOG_NONE (Stage 3 / Row 2).
21 1,464 printBeforeSetupInfo() Arduino-ESP32 cores/esp32/chip-debug-report.cpp:292 Suppressed by FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1 (Row 4 / #2894).
23 1,177 fl::Channel::resolveDynamicDriver() src/fl/channels/channel.cpp.hpp Gated by Row 8 / #2926; remaining bytes targetable in Stage 4.
24 1,151 fl::basic_string::write(const char*, fl::size) src/fl/stl/basic_string.cpp.hpp:193 Stage 5 simplification target.

Sibling references

Methodology (preserved from original)

PIO toolchain proved fragile (cache wipe during disk cleanup left compiler missing). For this round, audit via CI artifacts:

  1. Push a branch with the candidate change.
  2. Open a PR that triggers the existing compile-many matrix.
  3. Extract firmware.bin / firmware.map from the CI artifact bundle.
  4. Compare against a same-SHA baseline build (no change) on the same matrix entry.

FastLED/fbuild#417 would make step 3-4 push-button.

Activity

  1. zackees commented on Jun 7, 2026

    @zackees
    MemberAuthor

    Stage 1 — DONE ✅

    Landed via PR #2890 (squash-merged at 0674ccdd8e).

    What shipped

    src/fl/log/log.h — the unset default of FASTLED_LOG_VERBOSITY now resolves as:

    Context Default
    FASTLED_TESTING set 1
    NDEBUG set (release) 0
    Otherwise (debug builds) 1

    Release builds (NDEBUG defined) collapse all FL_WARN / FL_INFO / FL_ERROR / FL_PRINT / FL_DBG macros to do {} while(0). Debug builds keep the full diagnostic stream.

    Guard-rails added in the same PR

    To prevent regression of the developer-visibility contract ("FL_WARN/FL_ERROR remain active by default on NON-release builds"), the same PR adds matching enforcement to two review surfaces:

    • .claude/skills/code-review/review-rules.md → new "FL_WARN / FL_ERROR DEFAULT-VISIBILITY INVARIANT" rule for the local code-review agent.
    • .coderabbit.yaml → two new path_instructions entries covering src/fl/log/** (verbosity contract) and src/**/*.{h,hpp,cpp,cpp.hpp,impl.hpp} (call-site wrapping audit).

    Measurement gate

    The projected savings (~55 KB on ESP32-S3 NEOPIXEL Blink) get measured once bash bloat esp32s3 runs against a release build of master post-merge — that re-run belongs in Stage 6 (verification gate) or as a freestanding follow-up. The change itself is correct per the Stage 1 spec in this issue's body.

    Next

    Stage 2: Arduino-ESP32 boot-banner suppression via tools/suppress_arduino_chip_debug_report.cpp shim (~3 KB).

  2. zackees commented on Jun 7, 2026

    @zackees
    MemberAuthor

    Measured bloat audit — post-Stages-0+1+2+3+6, Stages 4+5 audited (2026-06-06)

    Fresh bash bloat esp32s3 --top 25 on master @ 824cb5c0e3 (PR #2902 just merged). Build via bash compile esp32s3 --examples Blink --platformio; release config; NDEBUG defined → Stage 1's FASTLED_LOG_VERBOSITY=0 default fires.

    Important caveat: this build did NOT set -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1 (Stage 2 build flag) and did NOT apply the tools/sdkconfig_for_smallest_fastled.defaults overlay (Stage 3). So the numbers below capture Stage 1's savings only — Stages 2 and 3 are still latent.

    Top-line

    Quantity Pre-Stage-1 baseline Now (Stage 1 only) Delta
    Total flash 388,380 B 350,568 B −37,812 B / −9.7 %
    Total RAM 37,460 B 37,453 B −7 B
    Sized flash symbols 3,685 3,631 −54

    Top-25 deltas (pre-Stage-1 vs post-Stage-1)

    # Symbol Pre-Stage-1 Now Δ
    1 fl::ClocklessIdf5<...> ctor (NEOPIXEL) 58,770 48,694 −10,076
    7 fl::Channel::showPixels 4,761 3,453 −1,308
    — fl::ChannelEngineRMTImpl::createChannel 2,363 out of top-25 ≤ −1.5 KB
    — fl::ChannelEngineRMTImpl::reconfigureForNetwork 2,252 out of top-25 ≤ −1.4 KB
    — fl::ChannelManager::addDriver 2,002 out of top-25 ≤ −1.1 KB
    — fl::RmtMemoryManager::handleAllocateTxFailure 1,972 out of top-25 ≤ −1.1 KB
    — fl::detail::Rmt5EncoderImpl::initialize 1,572 out of top-25 ≤ −0.7 KB
    — fl::Channel::resolveDynamicDriver 1,177 out of top-25 ≤ −0.3 KB

    The six entries that fell off the top-25 entirely are exactly the Stage 4 audit targets that this issue's closing PR (#2902) marked "no action — already addressed by Stage 1." That's the measured confirmation of the audit finding.

    What Stages 2 + 3 will recover (still latent)

    These rows are still on the top-25 in the current measurement because the current build doesn't enable the relevant opt-in:

    # Symbol Bytes Unlocked by
    14 esp_core_dump_do_write_elf_pass 1,835 Stage 3 — CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n
    15 diag_log_add 1,604 Stage 3 — CONFIG_LOG_DEFAULT_LEVEL=ESP_LOG_NONE
    16 printBeforeSetupInfo() 1,464 Stage 2 — -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1
    19 esp_core_dump_get_task_regs_dump 1,103 Stage 3 — CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n

    Projected fully-enabled build (Stages 1 + 2 + 3 all active):

    350,568 (current)
      − 1,464 (printBeforeSetupInfo, Stage 2)
      − 1,835 (esp_core_dump_do_write_elf_pass, Stage 3)
      − 1,103 (esp_core_dump_get_task_regs_dump, Stage 3)
      − 1,604 (diag_log_add, Stage 3)
      − ~5,000 (Stage 3 tail-symbols in libespcoredump.a, libesp_diagnostics)
    ≈ 339,562 B
    

    That's a projected ≈ −48-50 KB / −12.5 % vs the pre-Stage-1 baseline once all three opt-ins are stacked.

    Gap to #2886 end goal

    Milestone Flash Δ vs baseline
    Pre-Stage-1 baseline 388,380 B —
    Now (Stage 1 only) 350,568 B −37,812 B
    Projected (Stages 1 + 2 + 3) ≈ 340 KB −48 KB
    #2886 target 280,000 B −108,380 B
    Remaining gap ≈ 60 KB —

    The remaining ~60 KB lives in the structural items tracked by #2856 (Batch 3) — Channel::showPixels template-trait static dispatch (item 3.1, ~3-4 KB), printf-style log backend (item 3.2, ~5-10 KB), ChannelManager static-bind path (item 3.3, ~5-10 KB), RMT5 encoder dedup (item 3.4, ~2-5 KB), fl::result<T,E> → status code (item 3.5, ~1-2 KB, partly shipped in c8f21579), fixed-size allocation ledger (item 3.6, ~1 KB, shipped in ef6e378e). Plus the newlib printf engine (#2-6 in the table above) accounting for ~42 KB that's IDF/newlib structural, not FastLED-side.

    Stages 4 + 5 audit verdict — confirmed by measurement

    PR #2902 closed Stages 4 + 5 with "audited / no action because Stage 1 already collapsed the relevant byte attributions." The measured drop-off of every Stage 4 target from the top-25 (createChannel, reconfigureForNetwork, addDriver, handleAllocateTxFailure, Rmt5EncoderImpl::initialize, resolveDynamicDriver) is the empirical validation.

    fl::basic_string::write (Stage 5 target) remains in the top-25 at 1,151 B unchanged — it's the COW + inline-vs-heap storage state machine, no formatted-stream machinery to drop. The Stage 5 projection (~0.5-1 KB) overestimated; the audit verdict stands.

    Stage 6 regression-gate baseline ratchet

    The pinned baseline at tests/data/esp32s3_bloat_baseline.txt is currently 388380 (the pre-Stage-1 number). Now that there's a measured post-Stage-1 number, the file should ratchet down to 350568 in a follow-up PR. That tightens the gate by ~38 KB — any PR that regresses past this point will fail CI.

    Doc flip 📊 → ✅

    The docs/SLIM_ESP32S3.md priority table currently marks every row 📊 (projected). After this measurement, rows 1 (FASTLED_LOG_VERBOSITY=0) and 3 (FASTLED_RMT_STATIC_ALLOCATION) can flip to ✅ with the measured numbers attached. Stage 2 and Stage 3 stay 📊 until a build with their flags enabled is also measured. A follow-up PR will land both flips together.

    Artifacts

    🤖 Generated with Claude Code

  3. 38 remaining items

  4. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Triage pass:

    Progress so far (per merged PRs #2900, #2906, #2936, #2949, #2959 all on 2026-06-07):

    Target was 280,000 B (-28%); we're at 338 KB so ~58 KB still to find.

    Stages 2-5 (Arduino-ESP32 boot banner suppress / sdkconfig defaults / cold-helper audit / basic_string::write) project a combined ~14-20 KB on paper — even if all four ship, we'd still miss target by ~38 KB.

    Branch feat/esp32s3-bloat-reduction (last commit f013443) hasn't moved since 2026-06-07. The meta itself has been silent for the same period.

    Three options:

    1. Revive — pick Stage 2 (Arduino-ESP32 boot banner) since it's small + standalone. Quick win to restart momentum.
    2. Rescope — bring the target into line with what Stages 1-5 can actually deliver (~320 KB) and close at that point.
    3. Close as superseded — if subsequent ESP32-S3 work (Reduce per-symbol bloat in the FastLED 1-4KB function band on ESP32-S3 (logging must stay enabled) #2974 sub-issues, etc.) has effectively absorbed the remaining targets.

    No off-bench action from me without an explicit pick. Standing by.

  5. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Update to my prior triage — I missed substantial shipped work:

    Cross-checking against docs/SLIM_ESP32S3.md shows the project has actually shipped 7 of 9 flag-tier interventions documented there (#2890 / #2894 / #2896 / #2915 / #2920 / #2926 / #2931), plus the Stage 6 CI gate (#2900) and Stage 0 docs (#2906 / #2936 / #2949 / #2959). The body's "Stage 2" was already shipped in #2894 — fixed the body to reflect this.

    Effective progress:

    Remaining stages in the body that map to unstarted SLIM rows:

    • Stage 4 (cold-helper audit) — still open work
    • Stage 5 (basic_string::write simplification) — still open work
    • SLIM Row 5 (CONFIG_BT_ENABLED=n situational) — not picked up

    Updated recommendation: the gap between meta body language and the SLIM doc reality means the meta has been doing its job in chunks the body didn't track. Three options:

    1. Update meta body wholesale to mirror the SLIM doc's flag tracker — single source of truth, no more drift.
    2. Close meta + point to SLIM doc as the new tracker — body has served its purpose.
    3. Pick Stage 4 (cold-helper audit) to revive momentum on what's actually left.

    Option 1 is the cleanest documentation outcome; option 3 is the cleanest execution outcome. I retract my prior "stale-ish" framing — work continued in the SLIM doc but stopped updating this meta.

  6. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Meta body rewritten to mirror docs/SLIM_ESP32S3.md as the live tracker (A5 of meta #3122). 7 of 9 flag-tier interventions show as shipped (#2846, #2890, #2894, #2896, #2915, #2920, #2926, #2931); two remain projection-only (Row 4 #2894 measured but not bytes-verified, Row 5 BT-disable not picked up); plus Stage 4 (cold-helper audit) and Stage 5 (basic_string::write) as code-change tracks separate from the flag tier.

    SLIM_ESP32S3.md is now the single source of truth. Update SLIM, not this issue, when a new row ships.

  7. added
    deferred
    on Aug 20, 2026
  8. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Triaged against current master ad40fd2.

    Marking deferred: this is a multi-phase meta tracker. Much of Stages 1-3 shipped, but the strict target is not proven and the remaining work spans measurements plus several structural child issues.

    Current evidence:

    Restart after restoring the red gate and generating a fresh current-toolchain opt-in matrix that defines whether 280 KB applies to default or max-opt-in configuration. Split any remaining execution into bounded children rather than continuing in this meta.

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

    deferred

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions