Skip to content

perf(esp32): gate emit* cold helpers on FASTLED_LOG_RUNTIME_ENABLED (~800 B) - #2918

Merged
zackees merged 1 commit into
masterfrom
feat/2917-gate-emit-helpers
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2917-gate-emit-helpers

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

perf(esp32): gate emitRecoveryWarning + emitAllocationFailureError bodies on FASTLED_LOG_RUNTIME_ENABLED

Closes #2917.

Wraps the bodies of the two FL_NO_INLINE cold-path emit helpers in
fl::ChannelEngineRMTImpl with #if FASTLED_LOG_RUNTIME_ENABLED. In
release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the
helpers collapse to ~5 B function bodies (parameters cast to (void),
single ret), down from ~410-418 B each.

Why the existing FL_NO_INLINE + FL_WARN pattern wasn't enough

FL_NO_INLINE void emitRecoveryWarning(...) FL_NOEXCEPT {
    fl::sstream msg;                          // [1] constructed unconditionally
    msg << "..." << ... << external_words;    // [2] 15 operator<< calls fire
    FL_WARN(msg.str());                       // [3] expands to no-op in release
}

In release builds:

  • FL_WARN(X) expands to do { if (false) { ... << X; } } while(0) —
    optimizer DCEs the inner block (msg.str() call elided).
  • But fl::sstream msg; at [1] and msg << ... at [2] are outside
    the if (false) block. They have observable side effects on msg's
    internal buffer (heap allocation, sequential writes), so the optimizer
    keeps the constructor + all 15 operator<< calls live in the function
    body.

Result: the FL_NO_INLINE pulled the diagnostic chain out of the
function it was hoisted from (createChannel) — into its own symbol
— but the bytes stayed in the binary.

Measured baseline (post-#2916 ELF, master @ 5ca722e379)

Symbol Size
fl::ChannelEngineRMTImpl::emitAllocationFailureError ($isra$0) 418 B
fl::ChannelEngineRMTImpl::emitRecoveryWarning ($isra$0) 410 B
Total in scope ~828 B

Both symbols collapse to ~5 B after this PR.

Behavior preserved

  • Debug builds (FASTLED_LOG_VERBOSITY=1, default for non-NDEBUG):
    the diagnostic emits exactly as before. Users debugging RMT
    allocation failures still see the multi-line action-required
    message.
  • Release builds (FASTLED_LOG_VERBOSITY=0, NDEBUG default since
    perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890):
    the helper bodies become empty; the callers in
    attemptAllocationRecovery still call them (the call overhead is
    ~5 B / site), but the bodies cost nothing.

The FL_WARN macro itself was always a no-op in release; this PR makes
the body that built the message match the macro's release-build
behavior.

Other emit helpers — audit notes

  • attemptAllocationRecovery (315 B total): contains its own FL_WARN
    and FL_LOG_RMT calls plus actual retry-loop arithmetic. The
    diagnostic calls go through the standard FL_WARN macro which is
    already do { if (false) { ... } } while(0) in release — the
    optimizer DCEs the inline chain. The 315 B is the retry-loop body
    • Rmt5ChannelConfig retry_config(...) construction; NOT the
      diagnostic emission. Leaving as-is.
  • handleAllocateTxFailure (63 B): already a FL_NO_INLINE cold
    helper at 63 B post-Stage-1 — almost entirely the fallback retry
    body. No further gating needed.

Out of scope

  • Removing the FL_WARN calls from the source. They're useful in debug
    builds; the gate keeps them debug-build-active.
  • Auditing every FL_WARN call site in the RMT5 driver — the inline
    ones inside hot function bodies are already collapsed correctly by
    the if (false) DCE.

Verification

  • bash lint --cpp → all C++ linting checks pass.
  • Behavior preserved by construction: the gate is on a build-time
    define that defaults to "diagnostics on" in debug builds.
  • Measured saving validated on this PR's CI run via the Stage 6
    regression gate. Expected: total_flash drops by ~700-800 B from
    the current baseline of 347,004 B. A follow-up commit ratchets
    the baseline file in the same PR.

Refs #2886, #2917, #2908, #2911, #2914.

Summary by CodeRabbit

  • Refactor
    • Optimized ESP32 driver diagnostics to reduce overhead when logging is disabled, improving performance on resource-constrained devices.

…dies on FASTLED_LOG_RUNTIME_ENABLED

Closes #2917.

Wraps the bodies of the two `FL_NO_INLINE` cold-path emit helpers in
`fl::ChannelEngineRMTImpl` with `#if FASTLED_LOG_RUNTIME_ENABLED`. In
release builds (NDEBUG → `FASTLED_LOG_VERBOSITY=0` per Stage 1) the
helpers collapse to ~5 B function bodies (parameters cast to `(void)`,
single `ret`), down from ~410-418 B each.

## Why the existing FL_NO_INLINE + FL_WARN pattern wasn't enough

```cpp
FL_NO_INLINE void emitRecoveryWarning(...) FL_NOEXCEPT {
    fl::sstream msg;                          // [1] constructed unconditionally
    msg << "..." << ... << external_words;    // [2] 15 operator<< calls fire
    FL_WARN(msg.str());                       // [3] expands to no-op in release
}
```

In release builds:
- `FL_WARN(X)` expands to `do { if (false) { ... << X; } } while(0)` —
  optimizer DCEs the inner block (`msg.str()` call elided).
- But `fl::sstream msg;` at [1] and `msg << ...` at [2] are **outside**
  the `if (false)` block. They have observable side effects on `msg`'s
  internal buffer (heap allocation, sequential writes), so the optimizer
  keeps the constructor + all 15 `operator<<` calls live in the function
  body.

Result: the FL_NO_INLINE pulled the diagnostic chain out of the
function it was hoisted from (`createChannel`) — into its own symbol
— but the bytes stayed in the binary.

## Measured baseline (post-#2916 ELF, `master @ 5ca722e`)

| Symbol | Size |
|---|---:|
| `fl::ChannelEngineRMTImpl::emitAllocationFailureError` (`$isra$0`) | 418 B |
| `fl::ChannelEngineRMTImpl::emitRecoveryWarning` (`$isra$0`) | 410 B |
| **Total in scope** | **~828 B** |

Both symbols collapse to ~5 B after this PR.

## Behavior preserved

- **Debug builds (`FASTLED_LOG_VERBOSITY=1`, default for non-NDEBUG):**
  the diagnostic emits exactly as before. Users debugging RMT
  allocation failures still see the multi-line action-required
  message.
- **Release builds (`FASTLED_LOG_VERBOSITY=0`, NDEBUG default since
  #2890):** the helper bodies become empty; the callers in
  `attemptAllocationRecovery` still call them (the call overhead is
  ~5 B / site), but the bodies cost nothing.

The FL_WARN macro itself was always a no-op in release; this PR makes
the body that *built the message* match the macro's release-build
behavior.

## Other emit helpers — audit notes

- `attemptAllocationRecovery` (315 B total): contains its own FL_WARN
  and FL_LOG_RMT calls plus actual retry-loop arithmetic. The
  diagnostic calls go through the standard `FL_WARN` macro which is
  already `do { if (false) { ... } } while(0)` in release — the
  optimizer DCEs the inline chain. The 315 B is the retry-loop body
  + `Rmt5ChannelConfig retry_config(...)` construction; NOT the
  diagnostic emission. Leaving as-is.
- `handleAllocateTxFailure` (63 B): already a `FL_NO_INLINE` cold
  helper at 63 B post-Stage-1 — almost entirely the fallback retry
  body. No further gating needed.

## Out of scope

- Removing the FL_WARN calls from the source. They're useful in debug
  builds; the gate keeps them debug-build-active.
- Auditing every FL_WARN call site in the RMT5 driver — the inline
  ones inside hot function bodies are already collapsed correctly by
  the `if (false)` DCE.

## Verification

- `bash lint --cpp` → all C++ linting checks pass.
- Behavior preserved by construction: the gate is on a build-time
  define that defaults to "diagnostics on" in debug builds.
- Measured saving validated on this PR's CI run via the Stage 6
  regression gate. Expected: `total_flash` drops by ~700-800 B from
  the current baseline of `347,004 B`. A follow-up commit ratchets
  the baseline file in the same PR.

Refs #2886, #2917, #2908, #2911, #2914.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87b3bf4b-fac9-4a84-b67c-13b16f3b8d84

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca722e and 081e745.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp

📝 Walkthrough

Walkthrough

The PR gates two cold-path diagnostic helpers in the RMT5 driver (emitRecoveryWarning and emitAllocationFailureError) behind #if FASTLED_LOG_RUNTIME_ENABLED compile-time checks. When runtime logging is disabled, the functions become parameter-discarding stubs, eliminating ~828 B of dead log-formatting code from release builds.

Changes

Cold-path diagnostic gating

Layer / File(s) Summary
Gate emitRecoveryWarning and emitAllocationFailureError
src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
emitRecoveryWarning and emitAllocationFailureError wrap their fl::sstream construction and logging chains in #if FASTLED_LOG_RUNTIME_ENABLED, with #else branches that cast all parameters to (void) to silence unused-parameter warnings and prevent dead log-formatting code from being emitted in release builds.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

  • FastLED/FastLED#2886: This PR is part of the parent meta issue defining the bloat-reduction strategy and algorithmic targets; PR #2918 implements the exact Stage 5 reduction outlined in #2886 for the RMT5 diagnostic helpers.

Possibly related PRs

  • FastLED/FastLED#2791: The main PR updates RMT channel diagnostic helpers to no-op their fl::sstream logging when FASTLED_LOG_RUNTIME_ENABLED is false, directly leveraging the logging gate introduced in the retrieved PR.
  • FastLED/FastLED#2863: Both PRs modify rmt_5/channel_driver_rmt.cpp.hpp's cold-path diagnostic logging to reduce fl::sstream/operator<< work when runtime logging is disabled—main PR via #if FASTLED_LOG_RUNTIME_ENABLED gating, retrieved PR via the new FL_WARN_LIT/FL_LOG_LIT macros and migrating a warning to the literal path.
  • FastLED/FastLED#2826: The main PR extends the already-extracted emitRecoveryWarning(...) and emitAllocationFailureError(...) helpers (from the RMT5 createChannel refactor) by adding #if FASTLED_LOG_RUNTIME_ENABLED compile-time gating around their fl::sstream construction/emission.

Poem

🐰 With a gate at compile time so tight,
Cold logs fade from the build, oh what a sight!
Eight hundred bytes dancing away,
Release builds trimmer—hooray, hooray!
FastLED's RMT driver runs lean and mean.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2917-gate-emit-helpers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit fcf51c5 into master Jun 7, 2026
5 of 7 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
zackees added a commit that referenced this pull request Jun 7, 2026
#2919)

Measured against `master @ fcf51c5` (PR #2918 just merged):

    Total flash: 344,769 B  (3,615 sized flash symbols).  RAM: 37,389 B.
    (was: 347,004 B / 3,621 symbols on master @ f090358)

Delta: -2,235 B flash / -6 symbols.

Notably, the `fl::ClocklessIdf5<...>::ClocklessIdf5()` map-derived
attribution dropped from 48,694 B → 47,916 B (-778 B). This is the
first PR in the #2886 audit cycle to visibly shrink the top-1
symbol's reported size — the supporting `fl::sstream` operator<<
machinery that was only reachable via emitRecoveryWarning and
emitAllocationFailureError dead-stripped along with the gated bodies.

Refs #2886, #2917, #2918.
zackees added a commit that referenced this pull request Jun 7, 2026
…nd FASTLED_DISABLE_UCS7604 (#2921)

Closes #2920.

Mirrors the pattern shipped in #2914 (SPI dispatch gate). For
WS2812-only sketches the UCS7604 cases in the clockless switch in
`fl::Channel::showPixels` are dynamically unreachable, but the
`writeUCS7604(...)` reference inside is statically reachable, keeping
the encoder bodies linked. Setting `-DFASTLED_DISABLE_UCS7604=1`
removes the case at preprocess time and lets the linker dead-strip
the encoder templates plus the wrapper.

## Measured baseline (post-#2918 ELF, master @ ded5eea)

UCS7604-only symbols currently linked into NEOPIXEL Blink:

| Symbol | Size |
|---|---:|
| fl::encodeUCS7604_16bit_RGBW<ScaledPixelIteratorRGBW, ...> | 184 B |
| fl::encodeUCS7604_16bit_RGB<ScaledPixelIteratorRGB, ...>   | 152 B |
| writeUCS7604(...) wrapper (anon-ns, size est.)             | ~100-200 B |
| **Estimated total**                                        | **~400-500 B** |

Plus the inline switch-case footprint (3 case labels + dispatch).

Projected saving with the flag set: **~400-600 B** on NEOPIXEL Blink.

## Behavior

- Flag unset (default): No change.
- Flag set: UCS7604 cases removed; calling showPixels() on a UCS7604
  channel silently emits nothing. User opts in with the understanding
  that they're not using UCS7604.

## Files

- src/fl/channels/channel.cpp.hpp — wraps the UCS7604 cases in
  `#if !defined(FASTLED_DISABLE_UCS7604) || !FASTLED_DISABLE_UCS7604`.
  The gate's rationale documented inline.
- docs/SLIM_ESP32S3.md — adds row 7 to the priority table.

## Verification

- bash lint --cpp -> all C++ linting checks pass.
- Default behavior unchanged; regression-gate baseline unaffected.

Refs #2886, #2920, #2914, #2918.
zackees added a commit that referenced this pull request Jun 7, 2026
…ABLED (#2924)

Closes #2923.

Wraps the body of `FASTLED_ASSERT(x, MSG)` in `src/platforms/esp/esp_assert.h`
with `#if FASTLED_LOG_RUNTIME_ENABLED`. In release builds (NDEBUG ->
`FASTLED_LOG_VERBOSITY=0` per Stage 1 / #2890) the per-call-site
`fl::sstream() << "FASTLED ASSERT FAILED: " << MSG` chain + `fl::println`
call is replaced with a `sizeof((x), (MSG), 0)` syntax-only check.

This matches standard C `<assert.h>` semantics under NDEBUG: the macro
becomes `((void)0)`, condition not evaluated. Sketches must not put
side effects in assertion conditions (already best practice).

## Why this is bloat

Each of the 65 FASTLED_ASSERT call sites in `src/` builds a per-site
`fl::sstream` operator<< instantiation with the MSG literal. The
optimizer leaves these live because:

1. The assertion failure branch is conditional on a runtime value
   (`(x)`), not a constant — can't be DCE'd.
2. The sstream's operator<< calls have observable side effects on the
   sstream's internal buffer — can't be DCE'd by side-effect analysis
   even if the optimizer knew the branch was cold.

Cross-platform fallback at `src/platforms/assert_defs.h:100-114` already
uses an `if (false)` + `fl::detail::AssertSink() << MSG` pattern that
DCEs correctly. WASM at `src/platforms/wasm/js_assert.h:11-17` uses
`FL_WARN(MSG)` which is already gated. Only the ESP32 variant lacked
the gate.

## Files

- `src/platforms/esp/esp_assert.h` — gate added; the only platform
  variant that emitted unconditional sstream chains.

## Verification

- `bash lint --cpp` -> all C++ linting checks pass.
- Behavior preserved in debug builds: assertion failures still print
  the message via `fl::println`. Debug-only diagnostic infrastructure
  unchanged.
- Behavior in release: matches C `<assert.h>` under NDEBUG (no eval,
  no diagnostic) — semantic change vs. previous release behavior, but
  matches the established convention.

## Expected savings

Projected: ~1-2 KB measured on ESP32-S3 NEOPIXEL Blink. Variance
reflects how many of the 65 src/ assert sites are in the Blink
transitive closure. Measured saving validated on this PR's CI run via
the Stage 6 regression gate; baseline ratchets in a follow-up if
positive.

Refs #2886, #2923, #2918.
zackees added a commit that referenced this pull request Jun 7, 2026
…44769 -> 340832 (#2925)

PR #2924 wrapped the FASTLED_ASSERT body on FASTLED_LOG_RUNTIME_ENABLED
but used `sizeof((void)(MSG), 0)` as the release no-op. That broke the
build because MSG is typically an `fl::sstream` operator<< chain like
`"text " << i`, which is only valid as the RHS of `sstream.operator<<`
— it has no streamable LHS in isolation.

Fix: use the canonical `((void)0)` no-op matching standard C `<assert.h>`
under NDEBUG. The MSG expression is not validated at compile time, but
this matches the cassert convention. Sketches that have typos in MSG
will see them in debug builds where the diagnostic chain still emits.

## Measured against `master @ 669d199` (the pre-fix #2924 merge)

Build now succeeds. `bash bloat esp32s3 --top 5`:

    Total flash: 340,832 B  (was: 344,769 B)
    fl::ClocklessIdf5<...>::ClocklessIdf5() (top-1): 47,288 B
        (was: 47,916 B — drops -628 B on the top symbol)

Delta: -3,937 B flash. -628 B on the ClocklessIdf5 attribution
specifically (second ever drop on the top-1 symbol after #2918).

This exceeds the 1-2 KB projection in #2923 because the FASTLED_ASSERT
diagnostic-chain bloat was more concentrated in the ClocklessIdf5
transitive closure than I'd estimated. The 65 src/ assert sites
include 4 in `basic_vector` (used by every fl::vector instantiation
in the RMT5 driver) and ~6 in flat_map/unordered_map (used by
ChannelManager). The dead-strip cascade picked up the supporting
sstream operator<< template instantiations only reachable from those
sites.

Refs #2886, #2923, #2924.
zackees added a commit that referenced this pull request Jun 7, 2026
…ABLE_DYNAMIC_DRIVER (#2927)

Closes #2926.

Adds opt-in build flag `FASTLED_DISABLE_DYNAMIC_DRIVER=1` that gates
out `Channel::resolveDynamicDriver()`. For every legacy `addLeds<>`
flavor (including `addLeds<NEOPIXEL>` -> ClocklessIdf5), `mDriverPreBound`
is true after ctor and the else branch in `Channel::showPixels` is
dead at runtime — but the compiler can't prove it, so the linker
keeps the call chain (`resolveDynamicDriver` + `ChannelManager::
findDriverByName` + `selectDriverForChannel`) live.

Mirrors the pattern from #2914 (SPI gate) and #2921 (UCS7604 gate):
opt-in build flag, no default behavior change, projected ~400-900 B
on stock NEOPIXEL Blink with the flag set.

## Behavior

- **Flag unset (default):** No change. Dynamic-driver lookup runs as
  before for channels created via `Channel::create(cfg)` without
  pre-binding.
- **Flag set:**
  - `addLeds<NEOPIXEL>` / `addLeds<...>` flow: unchanged. They
    pre-bind their driver in the ctor.
  - `Channel::create(cfg)` without pre-binding: `showPixels()` returns
    silently. User accepts the constraint by setting the flag.

## Files

- `src/fl/channels/channel.cpp.hpp`:
  - `Channel::showPixels` else branch wrapped in `#if !defined(FASTLED_DISABLE_DYNAMIC_DRIVER) || !FASTLED_DISABLE_DYNAMIC_DRIVER`.
  - `Channel::resolveDynamicDriver` body excluded when the flag is set
    (returns empty shared_ptr). Lets the linker dead-strip the
    `findDriverByName` / `selectDriverForChannel` chain.
- `docs/SLIM_ESP32S3.md`: row 8 added to the priority table.

## Verification

- `bash lint --cpp` -> all C++ linting checks pass.
- Default behavior unchanged; regression-gate baseline unaffected.

## Expected savings

Projected ~400-900 B on stock NEOPIXEL Blink with the flag set.
Dead-strip cascade may push it higher (see #2918 and #2925 precedents
where collapsing one cold-path symbol cascaded into 3-4x the
single-symbol projection).

Refs #2886, #2926, #2914, #2918, #2921, #2925.
zackees added a commit that referenced this pull request Jun 7, 2026
…_EVENTS (#2932)

Closes #2931.

Adds opt-in build flag `FASTLED_DISABLE_CHANNEL_EVENTS=1` that
replaces `fl::ChannelEvents`'s 7 `fl::function_list<...>` event-slot
members with a no-op fallback (`detail::NoOpChannelEvent`) that
accepts `operator()(Args&&...)`, `add(F, priority=0)`, and `remove(id)`
but does nothing. The 18 internal call sites across `src/` need no
changes — `events.onChannelXxx(args)` resolves to the no-op at
compile time.

Mirrors the opt-in pattern from #2914 / #2921 / #2927.

## Why this is a win

`fl::ChannelEvents::ChannelEvents()` ctor is 395 B (×2 C1+C2 = 790 B)
in the post-#2929 baseline. The ctor initializes 7 unique
`fl::function_list<...>` template instantiations, each of which pulls
its own storage, iteration, and `call()` machinery. For stock
`addLeds<NEOPIXEL>` sketches with no registered callbacks, every
event-fire (e.g. `events.onChannelDataEncoded(...)` from every
`Channel::showPixels` frame) is a no-op iteration over an empty list
— but the linker keeps all the supporting machinery alive.

Replacing the slots with a single `NoOpChannelEvent` type drops the
ctor body, the 7 unique `fl::function_list` instantiations, and the
`fl::Singleton<ChannelEvents>::instance()` chain. Projected ~1-2 KB
on stock NEOPIXEL Blink with the flag set.

## Behavior

| Flag | Code path | User registers callback | Behavior |
|---|---|---|---|
| unset (default) | real `fl::function_list` | yes | Callback fires as expected. |
| unset (default) | real `fl::function_list` | no | call() iterates empty list. |
| set | `detail::NoOpChannelEvent` | yes | Registration compiles (returns -1) but never fires. |
| set | `detail::NoOpChannelEvent` | no | Same as default — nothing happens. |

## Files

- src/fl/channels/channel_events.h: add `#if FASTLED_DISABLE_CHANNEL_EVENTS`
  branch with the no-op fallback class. Keep the original full
  implementation under `#else`.
- src/fl/channels/channel_events.cpp.hpp: gate the out-of-line
  `instance()` definition so the inline header version in the no-op
  branch is the only definition.
- docs/SLIM_ESP32S3.md: row 9 added to the priority table.

## Verification

- bash lint --cpp -> all C++ linting checks pass.
- Default behavior unchanged; regression-gate baseline unaffected.

## Expected savings

Projected ~1-2 KB on stock NEOPIXEL Blink with the flag set. The
dead-strip cascade hypothesis (per #2918 / #2925 / #2929) suggests
the actual saving may exceed projection.

Refs #2886, #2931, #2914, #2921, #2927, #2929.
zackees added a commit that referenced this pull request Jun 7, 2026
…) (#2937)

Closes #2935 (partial — 4 configs failed silently during the
measurement; the 6 successful configs flip the rows below).

Ran `tests/measure_esp32s3_opt_ins.py --config all` end-to-end against
`master @ f43f767`. The script's comparison table:

| Config | SLIM row | total_flash | Δ vs baseline |
|---|:---:|---:|---:|
| baseline | 1 | 339,962 B | +0 B |
| stage3 (sdkconfig overlay) | 2 | **280,738 B** | **−59,224 B** |
| stage4 (FASTLED_RMT_STATIC_ALLOCATION) | 3 | 339,054 B | −908 B |
| disable_ucs7604 | 7 | 336,158 B | **−3,804 B** |
| disable_dyndriver | 8 | 339,025 B | −937 B |
| disable_events | 9 | 331,928 B | **−8,034 B** |

## Headlines

- **Stage 3 alone hits the #2886 end-goal.** The
  `tools/sdkconfig_for_smallest_fastled.defaults` overlay drops
  total_flash to 280,738 B — within 738 B of the 280,000 B target.
  Adding `CONFIG_NEWLIB_NANO_FORMAT=y` to the overlay in #2916 was
  the dominant lever (~30-45 KB of the saving).
- **Three opt-in flags vastly exceeded projection** — `disable_events`
  delivered 4-8× projection (−8,034 B vs ~1-2 KB), `disable_ucs7604`
  delivered 6-9× (−3,804 B vs ~400-600 B). The dead-strip cascade
  pattern (see #2918 / #2925 / #2929 precedents) consistently
  delivers above projection when collapsing template-heavy machinery.

## What flipped 📊 → ✅

- Row 2 (overlay): −59,224 B measured. **Hits end-goal.**
- Row 3 (FASTLED_RMT_STATIC_ALLOCATION): −908 B measured (well
  below projection — the static-allocation path is mostly
  already-optimal post-Stage-1).
- Row 7 (FASTLED_DISABLE_UCS7604): −3,804 B measured.
- Row 8 (FASTLED_DISABLE_DYNAMIC_DRIVER): −937 B measured.
- Row 9 (FASTLED_DISABLE_CHANNEL_EVENTS): −8,034 B measured.

## What's still 📊

- Row 4 (FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT): the config
  failed silently during the measurement run — see follow-up.
- Row 5 (CONFIG_BT_ENABLED=n): no opt-in path in the current overlay
  (it's commented out per the user-side opt-in design).
- Row 6 (FASTLED_DISABLE_SPI_CHIPSETS): also failed silently.

The 4 missing configs (`stage2`, `stack`, `disable_spi`,
`max_savings`) need a separate troubleshooting pass. The output
redirection in the original measurement command discarded the
per-build error messages so the failure cause isn't visible. A
follow-up issue will rerun those with full output capture.

## Files

- docs/SLIM_ESP32S3.md:
  - Baseline table updated with the new measured default-flag number
    (339,962 B) and a callout that Stage 3 alone hits the end-goal.
  - Rows 2 / 3 / 7 / 8 / 9 flip 📊 → ✅ with measured deltas inline.

## Verification

- bash lint --cpp -> all C++ linting checks pass.
- The measured numbers in the doc are word-for-word the script's
  table output.

Refs #2886, #2935, #2906, #2934, #2916.
zackees added a commit that referenced this pull request Jun 7, 2026
….py (#2939)

* docs(esp32): flip SLIM rows 2/3/7/8/9 to ✅ with measured numbers (#2935)

Closes #2935 (partial — 4 configs failed silently during the
measurement; the 6 successful configs flip the rows below).

Ran `tests/measure_esp32s3_opt_ins.py --config all` end-to-end against
`master @ f43f767`. The script's comparison table:

| Config | SLIM row | total_flash | Δ vs baseline |
|---|:---:|---:|---:|
| baseline | 1 | 339,962 B | +0 B |
| stage3 (sdkconfig overlay) | 2 | **280,738 B** | **−59,224 B** |
| stage4 (FASTLED_RMT_STATIC_ALLOCATION) | 3 | 339,054 B | −908 B |
| disable_ucs7604 | 7 | 336,158 B | **−3,804 B** |
| disable_dyndriver | 8 | 339,025 B | −937 B |
| disable_events | 9 | 331,928 B | **−8,034 B** |

## Headlines

- **Stage 3 alone hits the #2886 end-goal.** The
  `tools/sdkconfig_for_smallest_fastled.defaults` overlay drops
  total_flash to 280,738 B — within 738 B of the 280,000 B target.
  Adding `CONFIG_NEWLIB_NANO_FORMAT=y` to the overlay in #2916 was
  the dominant lever (~30-45 KB of the saving).
- **Three opt-in flags vastly exceeded projection** — `disable_events`
  delivered 4-8× projection (−8,034 B vs ~1-2 KB), `disable_ucs7604`
  delivered 6-9× (−3,804 B vs ~400-600 B). The dead-strip cascade
  pattern (see #2918 / #2925 / #2929 precedents) consistently
  delivers above projection when collapsing template-heavy machinery.

## What flipped 📊 → ✅

- Row 2 (overlay): −59,224 B measured. **Hits end-goal.**
- Row 3 (FASTLED_RMT_STATIC_ALLOCATION): −908 B measured (well
  below projection — the static-allocation path is mostly
  already-optimal post-Stage-1).
- Row 7 (FASTLED_DISABLE_UCS7604): −3,804 B measured.
- Row 8 (FASTLED_DISABLE_DYNAMIC_DRIVER): −937 B measured.
- Row 9 (FASTLED_DISABLE_CHANNEL_EVENTS): −8,034 B measured.

## What's still 📊

- Row 4 (FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT): the config
  failed silently during the measurement run — see follow-up.
- Row 5 (CONFIG_BT_ENABLED=n): no opt-in path in the current overlay
  (it's commented out per the user-side opt-in design).
- Row 6 (FASTLED_DISABLE_SPI_CHIPSETS): also failed silently.

The 4 missing configs (`stage2`, `stack`, `disable_spi`,
`max_savings`) need a separate troubleshooting pass. The output
redirection in the original measurement command discarded the
per-build error messages so the failure cause isn't visible. A
follow-up issue will rerun those with full output capture.

## Files

- docs/SLIM_ESP32S3.md:
  - Baseline table updated with the new measured default-flag number
    (339,962 B) and a callout that Stage 3 alone hits the end-goal.
  - Rows 2 / 3 / 7 / 8 / 9 flip 📊 → ✅ with measured deltas inline.

## Verification

- bash lint --cpp -> all C++ linting checks pass.
- The measured numbers in the doc are word-for-word the script's
  table output.

Refs #2886, #2935, #2906, #2934, #2916.

* feat(bloat): capture per-config build logs in measure_esp32s3_opt_ins.py

Closes #2938 (partial — script side).

Pre-#2938 the script ran `bash compile` / `bash bloat` for each config
and discarded the per-build stdout/stderr. When a config crashed
(see #2935 — 4 of 10 configs crashed on Windows with `extras+.cpp.o`
exit 3221225794), the failure cause was invisible. Without that
information, debugging required manual single-config reruns.

This PR routes every config's compile and bloat output through a
new `_run_with_log()` helper that writes to `.build/measure-logs/
<config>-{compile,bloat}.log` while tee'ing the same stream to the
operator's terminal. On any future crash the log file is the
diagnosable artifact.

## Files

- tests/measure_esp32s3_opt_ins.py:
  - New `_LOG_DIR` constant (`.build/measure-logs`).
  - New `_run_with_log(cmd, log_name)` helper that does combined
    stdout+stderr capture via subprocess.Popen + chunked read.
  - `run_compile` and `run_bloat` take a `config_name` parameter and
    delegate to `_run_with_log`.
  - `measure_one` passes `cfg.name` to both.

## Verification

- bash lint -> all linters pass (ruff, ty, C++, JS setup).
- Smoke test (`--config baseline`) produces a log file pair at
  `.build/measure-logs/baseline-compile.log` and
  `.build/measure-logs/baseline-bloat.log`.

## Known follow-up

The smoke test surfaced a separate issue: when consecutive runs use
the same build_flags + sdkconfig, PIO returns a cached ELF from a
prior run (potentially with different config). This is a build-cache
hygiene problem orthogonal to the log capture. To be addressed in a
future PR — possibly via `bash compile --clean` between configs or
an explicit invalidation of `.build/pio/esp32s3/.pio/build/`.

Refs #2886, #2938, #2935, #2906.
zackees added a commit that referenced this pull request Jun 7, 2026
…2951)

The #2517 "silent-drop" diagnostic in `Channel::showPixels` exists
to help users debug `FastLED.setExclusiveDriver<>` flows where a
bound driver is currently disabled and the frame would be silently
dropped. In release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per
#2890) every FL_ERROR site inside `emitDisabledDriverError` collapses
to `do { } while(0)`, leaving an empty function body — but the call
site is still live, so the linker keeps:

  - the empty `emitDisabledDriverError` body (3 fl::string&-args),
  - the `ChannelManager::instance().exclusiveDriverName()` getter
    (only reachable from this site),
  - the 3-argument fl::string pass-by-const-ref chain at the call
    site,
  - the `mDisabledDriverWarned` reads/writes.

Gate the diagnostic emission and the one-shot latch maintenance on
`FASTLED_LOG_RUNTIME_ENABLED`. The unconditional `return` on
STATUS_DISABLED is preserved — release still drops the frame, just
silently (the user accepted that constraint by disabling logs).

Same dead-strip cascade pattern as #2918 / #2925 / #2943.

Refs #2886.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 7, 2026
… (#2953)

resolveDynamicDriver runs per-frame for non-pre-bound channels. The
diagnostic block at channel.cpp.hpp:414-438 includes:

  - the per-frame `driver->getName() != busKey` virtual-call +
    fl::string compare (deciding silent-miss vs. diagnosed-miss),
  - the silent `ChannelManager::findDriverByName(busKey)` probe (used
    only to differentiate the FL_ERROR message),
  - mBusWarned reads/writes,
  - the empty `if (!driver) {}` branch with the no-compatible-driver
    FL_ERROR.

In release builds the FL_ERROR bodies collapse to do-while-0, but the
surrounding code still runs — burning cycles + flash bytes for an
unrendered diagnostic.

Gate the whole block on FASTLED_LOG_RUNTIME_ENABLED. The functional
`return driver` is preserved unconditionally; only the diagnostic
side-effect is gated.

Same dead-strip cascade pattern as #2918 / #2925 / #2929 / #2943 /
#2950.

Closes #2952. Refs #2886.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/2917-gate-emit-helpers branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Cut ClocklessIdf5 bloat by gating cold-path emit helpers' sstream chains (~800 B) (#2886)

1 participant