Skip to content

perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) - #2890

Merged
zackees merged 2 commits into
masterfrom
feat/2886-stage1-log-verbosity-default
Jun 7, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/2886-stage1-log-verbosity-default

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1)

Flips the unset default of FASTLED_LOG_VERBOSITY from 1 to 0 when
NDEBUG is defined (i.e. release builds). Test builds (FASTLED_TESTING)
and debug builds (no NDEBUG) still default to 1, so FL_WARN and
FL_ERROR stay live by default whenever you are not on a release build —
which is what the user-facing experience demands.

Resolution order:

Users on release builds who explicitly want FL_WARN/FL_LOG back set
-DFASTLED_LOG_VERBOSITY=1 in their build flags, or #define FASTLED_LOG_VERBOSITY 1 before #include <FastLED.h>. The
per-channel logging defines (FASTLED_LOG_RMT_ENABLED,
FASTLED_LOG_SPI_ENABLED, etc.) keep their existing gates — only the
verbosity floor changes here.

This is Stage 1 of the multi-stage ESP32-S3 bloat-reduction plan tracked
in #2886. The projected savings of ~55 KB collapse the per-call-site
rodata pools attributed to the 75 FL_WARN/FL_LOG sites in
channel_driver_rmt.cpp.hpp, the 59 sites in rmt_memory_manager.cpp.hpp,
the 6 sites in manager.cpp.hpp, and the 5 sites in channel.cpp.hpp —
all reachable from the ClocklessIdf5 ctor transitive closure that
currently anchors 58,770 B of the 388,380 B Blink binary.

No public API changes. The FASTLED_LOG_VERBOSITY macro and its three
levels remain stable (introduced in #2791); only the unset default flips.

Refs #2886, #2791, #2773.

Summary by CodeRabbit

  • Chores
    • Adjusted logging verbosity defaults so testing and debug builds are verbose by default, while release builds default to quiet; user overrides remain supported.
  • Documentation
    • Added guidance and review rules to ensure warning/error visibility remains enabled by default on non-release builds and to enforce the new logging default behavior.

…tage 1)

Flips the unset default of `FASTLED_LOG_VERBOSITY` from `1` to `0` when
`NDEBUG` is defined (i.e. release builds). Test builds (`FASTLED_TESTING`)
and debug builds (no `NDEBUG`) still default to `1`, so `FL_WARN` and
`FL_ERROR` stay live by default whenever you are not on a release build —
which is what the user-facing experience demands.

Resolution order:

  - FASTLED_TESTING is set     → 1 (host unit tests need full diagnostics)
  - NDEBUG is set (release)    → 0 (drops ~55 KB of FL_WARN/FL_LOG strings
                                    on ESP32-S3 NEOPIXEL Blink; see #2886
                                    "Stage 1" projection)
  - otherwise (debug builds)   → 1 (preserves current behavior)

Users on release builds who explicitly want FL_WARN/FL_LOG back set
`-DFASTLED_LOG_VERBOSITY=1` in their build flags, or `#define
FASTLED_LOG_VERBOSITY 1` before `#include <FastLED.h>`. The
per-channel logging defines (`FASTLED_LOG_RMT_ENABLED`,
`FASTLED_LOG_SPI_ENABLED`, etc.) keep their existing gates — only the
verbosity floor changes here.

This is Stage 1 of the multi-stage ESP32-S3 bloat-reduction plan tracked
in #2886. The projected savings of ~55 KB collapse the per-call-site
rodata pools attributed to the 75 FL_WARN/FL_LOG sites in
`channel_driver_rmt.cpp.hpp`, the 59 sites in `rmt_memory_manager.cpp.hpp`,
the 6 sites in `manager.cpp.hpp`, and the 5 sites in `channel.cpp.hpp` —
all reachable from the ClocklessIdf5 ctor transitive closure that
currently anchors 58,770 B of the 388,380 B Blink binary.

No public API changes. The `FASTLED_LOG_VERBOSITY` macro and its three
levels remain stable (introduced in #2791); only the unset default flips.

Refs #2886, #2791, #2773.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

Warning

Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c60f6e6-12ca-492f-8750-c5f0fb89e4fa

📥 Commits

Reviewing files that changed from the base of the PR and between c7bf1ad and f806491.

📒 Files selected for processing (2)
  • .claude/skills/code-review/review-rules.md
  • .coderabbit.yaml

📝 Walkthrough

Walkthrough

This PR changes the FASTLED logging header to resolve FASTLED_LOG_VERBOSITY by build mode (FASTLED_TESTING → 1, NDEBUG → 0, otherwise 1) and adds review-rule and review-config updates enforcing that FL_WARN/FL_ERROR remain visible by default on non-release builds.

Changes

Logging Verbosity Default Resolution

Layer / File(s) Summary
Verbosity default selection policy and implementation
src/fl/log/log.h
Documentation updated to describe the new default-selection hierarchy: FASTLED_TESTING forces 1, NDEBUG forces 0, otherwise 1. Preprocessor logic now sets FASTLED_LOG_VERBOSITY to 0 under NDEBUG and 1 otherwise when not user-specified.
Review-rule and review config for logging visibility
.claude/skills/code-review/review-rules.md, .coderabbit.yaml
Adds a review-rule and coderabbit path instruction for src/fl/log/** requiring FL_WARN/FL_ERROR remain enabled by default on non-release builds and referencing the header's resolution order.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • FastLED/FastLED#2791: Modifies logging gating logic that interacts with the verbosity default changed here.
  • FastLED/FastLED#2863: Adds literal logging macros whose enabled behavior depends on FASTLED_LOG_VERBOSITY defaults.
  • FastLED/FastLED#2833: Contains debug-gated code paths that may compile differently under the revised verbosity defaults.

Poem

🐰 I nibble at macros, hop through the code,
Testing turns on the chatter on my road.
Release keeps quiet, debug speaks bright—
Warnings and errors stay visible by night.
A small rabbit cheers the compiler's light.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: setting FASTLED_LOG_VERBOSITY default to 0 in release builds. It is specific, directly related to the changeset, and avoids vague terms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2886-stage1-log-verbosity-default

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.

Add the invariant "FL_WARN and FL_ERROR remain active by default on
NON-release builds" to two review surfaces so the rule is enforced on
every future PR:

1. `.claude/skills/code-review/review-rules.md` — local code-review
   agent (run via `/code-review`) gets a new "FL_WARN/FL_ERROR
   default-visibility invariant" section. Reviews flag any change that
   adds an outer guard requiring opt-in on debug builds, lowers the
   non-release default of `FASTLED_LOG_VERBOSITY` below 1, or
   introduces a new logging knob that suppresses warnings/errors by
   default on non-release builds.

2. `.coderabbit.yaml` — two `path_instructions` entries:
   - `src/fl/log/**` — the verbosity-default contract is stated with
     the resolution order from log.h (FASTLED_TESTING → 1, NDEBUG →
     0, otherwise → 1) and the rationale (developers depend on
     warnings firing during development).
   - `src/**/*.{h,hpp,cpp,cpp.hpp,impl.hpp}` — broader call-site
     rule: PRs are flagged only when they wrap existing or new FL_WARN
     / FL_ERROR sites in additional `#if !defined(...)` blocks that
     would suppress them on non-release builds by default. New
     FL_WARN/FL_ERROR call sites are fine because they inherit the
     correct default from the verbosity gate already.

Release builds (NDEBUG defined) intentionally default to 0; that is
the savings the bloat-reduction work in #2886 Stage 1 delivers.

Refs #2886, #2890.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fl/log/log.h`:
- Around line 68-71: Replace the Unicode arrow characters used in the comment
block describing FASTLED_TESTING/NDEBUG behavior in log.h (the three bullet
lines mentioning FASTLED_TESTING, NDEBUG, and debug builds) with ASCII-only
arrows by changing every `→` to `->`; ensure the edited comment contains no
other non-ASCII punctuation so the log.h comments remain strictly ASCII-safe.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09882289-4c0a-4072-8b83-8e50b5dacd97

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2fe50 and c7bf1ad.

📒 Files selected for processing (1)
  • src/fl/log/log.h

Comment thread src/fl/log/log.h
Comment on lines +68 to +71
// * `FASTLED_TESTING` is set → 1 (host unit tests need full diagnostics)
// * `NDEBUG` is set (release) → 0 (drop ~55 KB of FL_WARN/FL_LOG strings
// on ESP32-S3 NEOPIXEL Blink; see #2886)
// * otherwise (debug builds) → 1 (preserve current behavior)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use ASCII-only arrows in the newly edited comment block.

The new bullet lines use Unicode →; replace them with ASCII -> to keep log.h edits ASCII-safe.

Suggested patch
-//   * `FASTLED_TESTING` is set     → 1 (host unit tests need full diagnostics)
-//   * `NDEBUG` is set (release)    → 0 (drop ~55 KB of FL_WARN/FL_LOG strings
+//   * `FASTLED_TESTING` is set     -> 1 (host unit tests need full diagnostics)
+//   * `NDEBUG` is set (release)    -> 0 (drop ~55 KB of FL_WARN/FL_LOG strings
 //                                      on ESP32-S3 NEOPIXEL Blink; see `#2886`)
-//   * otherwise (debug builds)     → 1 (preserve current behavior)
+//   * otherwise (debug builds)     -> 1 (preserve current behavior)

As per coding guidelines, “keep any edits to log.h/comments strictly ASCII-only (no Unicode punctuation/glyphs/emojis) to avoid toolchain/grep/lint failures.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// * `FASTLED_TESTING` is set → 1 (host unit tests need full diagnostics)
// * `NDEBUG` is set (release) → 0 (drop ~55 KB of FL_WARN/FL_LOG strings
// on ESP32-S3 NEOPIXEL Blink; see #2886)
// * otherwise (debug builds) → 1 (preserve current behavior)
// * `FASTLED_TESTING` is set -> 1 (host unit tests need full diagnostics)
// * `NDEBUG` is set (release) -> 0 (drop ~55 KB of FL_WARN/FL_LOG strings
// on ESP32-S3 NEOPIXEL Blink; see `#2886`)
// * otherwise (debug builds) -> 1 (preserve current behavior)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/log/log.h` around lines 68 - 71, Replace the Unicode arrow characters
used in the comment block describing FASTLED_TESTING/NDEBUG behavior in log.h
(the three bullet lines mentioning FASTLED_TESTING, NDEBUG, and debug builds)
with ASCII-only arrows by changing every `→` to `->`; ensure the edited comment
contains no other non-ASCII punctuation so the log.h comments remain strictly
ASCII-safe.

Source: Coding guidelines

@zackees
zackees merged commit 0674ccd into master Jun 7, 2026
5 of 6 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
@zackees
zackees deleted the feat/2886-stage1-log-verbosity-default branch June 7, 2026 01:30
zackees added a commit that referenced this pull request Jun 7, 2026
…rlay (#2886 Stage 3) (#2896)

Closes #2895.

Adds a documented, opt-in ESP-IDF sdkconfig overlay that users plug into
`board_build.sdkconfig_defaults`. Drops ~10-15 KB of release-build flash
on a typical ESP32 LED installation by disabling IDF components that a
deployed strip never uses:

| Knob | Eliminates | Savings |
|---|---|---:|
| `CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n` | libespcoredump (top-25 rows #18 + #25, ~3 KB symbols + ~5 KB tail) | ~8 KB |
| `CONFIG_LOG_DEFAULT_LEVEL=ESP_LOG_NONE`  | libesp_diagnostics + IDF log strings (top-25 row #19) | ~3 KB |
| `CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y`     | bootloader-stage UART chatter | ~1 KB |
| `CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y`   | panic-time backtrace formatter | ~1-2 KB |

`CONFIG_BT_ENABLED=n` is shipped commented-out (~15 KB extra when the
project currently has BT on) — users uncomment when they know their
sketch doesn't touch BLE/BT.

## Files

- `tools/sdkconfig_for_smallest_fastled.defaults` — the overlay
  itself, with inline per-knob comments grounding each line in the
  #2886 top-25 attribution.
- `agents/docs/binary-size-analysis.md` — adds a "Release-build flash
  savers (in order of impact)" table that lists this overlay
  alongside the FASTLED_LOG_VERBOSITY default (#2890), the boot-banner
  shim (#2894), and FASTLED_RMT_STATIC_ALLOCATION (#2846). Single
  reference point for what knobs exist and how to enable them.

## Why a user-side overlay, not a library-side default

`sdkconfig` is consumed by the ESP-IDF build before any FastLED TU is
compiled. FastLED cannot mutate IDF defaults from a library; the
deliverable here is therefore a *shippable overlay file* the user
points `board_build.sdkconfig_defaults` at, plus documentation that
tells them which lines map to which savings.

## User integration

```
[env:esp32s3]
board_build.sdkconfig_defaults =
    sdkconfig.defaults
    ${platformio.packages_dir}/framework-arduinoespressif32/tools/sdkconfig.defaults.esp32s3
    ${PROJECT_LIBDEPS_DIR}/${PIOENV}/FastLED/tools/sdkconfig_for_smallest_fastled.defaults
```

(See the file's header for the full snippet; `PROJECT_LIBDEPS_DIR`
resolution varies by PIO project layout.)

## Verification

- `bash lint --cpp` → C++ linting passes (this PR is docs-only;
  pre-existing PlatformIO-internal-usage warnings unchanged).
- Per-project flash deltas are user-side measurements; the projection
  table in `binary-size-analysis.md` cites the #2886 top-25 baseline
  attribution for each line.

Refs #2886, #2895.
zackees added a commit that referenced this pull request Jun 7, 2026
…tage 0) (#2898)

Closes #2897.

Adds a user-facing reference page that consolidates every release-build
flash-saver FastLED currently ships into a single discoverable
location. End users no longer have to grep across PRs and meta-issues
to find the knobs.

Sections:

1. **TL;DR** — a drop-in `platformio.ini` snippet that stacks Stages
   1+2+3 and `FASTLED_RMT_STATIC_ALLOCATION` in one place.
2. **Baseline & how to measure** — pre-#2886 NEOPIXEL Blink baseline
   (388,380 B), Stage 6 target (≤ 280,000 B), `bash bloat esp32s3`
   pointer.
3. **Release-build flash savers (in priority order)** — five-row
   table with how-to-enable, savings, status (✅ measured vs.
   📊 projected), and PR cross-link for each knob.
4. **Per-stage detail** — one section per shipped stage with the
   mechanism, file path, and integration snippet:
   - Stage 1 (`FASTLED_LOG_VERBOSITY=0`, now NDEBUG default) — #2890
   - Stage 2 (`FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1` build
     flag → strong override of vendor weak `shouldPrintChipDebugReport()`)
     — #2894
   - Stage 3 (`tools/sdkconfig_for_smallest_fastled.defaults` overlay
     applied via `board_build.sdkconfig_defaults`) — #2896
   - `FASTLED_RMT_STATIC_ALLOCATION=1` — #2846 (pre-existing)
5. **Situational notes** — Stage stacking, sdkconfig integration
   gotchas, `PROJECT_LIBDEPS_DIR` fallback.
6. **Measuring your build** — `bash bloat esp32s3` quickstart + diff
   pointer.
7. **Roadmap** — Stages 4 (cold-helper audit), 5 (basic_string::write
   simplification), 6 (CI regression gate). The ✅/📊 status flags on
   the priority table flip to ✅ when Stage 6 records measured deltas.

Also adds a cross-reference from
`agents/docs/binary-size-analysis.md` (the agent-facing reference
shipped in #2896) to the new user-facing doc, with a maintenance note
that future knobs must update both surfaces.

## Honesty about projections

Every savings figure in this PR is marked 📊 (projected from the
#2886 top-25 attribution). The ✅ status gets unlocked when Stage 6
of #2886 wires the regression-gate run that records measured baselines.
The Roadmap section calls this out explicitly so readers know which
numbers carry empirical weight.

## Verification

- `bash lint --cpp` → all C++ linting checks pass; this PR adds no
  C++ code.
- Doc references (`tools/sdkconfig_for_smallest_fastled.defaults`,
  `src/extras/suppress_arduino_chip_debug_report.cpp.hpp`,
  `src/fl/log/log.h:66-92`) verified against the post-#2896 tree.

Refs #2886, #2897.
zackees added a commit that referenced this pull request Jun 7, 2026
Closes #2901.

Updates the Roadmap section of `docs/SLIM_ESP32S3.md` to reflect what
re-auditing Stages 4 and 5 against the post-Stage-1 tree actually
found: nothing further to recover.

The #2886 Stage 4 + Stage 5 byte projections (~3-5 KB and ~0.5-1 KB
respectively) were authored before Stage 1 (#2890) flipped
`FASTLED_LOG_VERBOSITY` to default 0 on release builds. That single
change collapsed the FL_WARN / FL_LOG_RMT string pools that
dominated the pre-Stage-1 byte attribution for each named target. The
residual code bytes in every audit target are essential:

- **Stage 4 — `Channel::showPixels`** — the `has_no_runtime_scaling_v<>`
  trait the issue named does not exist in the codebase. Actual
  dispatch is a 3-way runtime branch against compact 5-line encoders
  in `src/fl/chipsets/encoders/ws2812.h:35-96` — too small to gate.
- **Stage 4 — `ChannelEngineRMTImpl::reconfigureForNetwork`** — 8 of
  10 diagnostics are FL_DBG (already gated by `FASTLED_HAS_DBG`); the
  remaining 2 FL_WARNs are no-op'd by Stage 1. Residual bytes are
  essential peripheral teardown.
- **Stage 4 — `ChannelManager::addDriver`** — `capStr` block at
  `src/fl/channels/manager.cpp.hpp:117-132` is already wrapped in
  `#if FASTLED_HAS_DBG`. Verification only; no fix needed.
- **Stage 4 — `RmtMemoryManager::handleAllocateTxFailure`** — already
  a `FL_NO_INLINE` cold helper at `src/platforms/.../rmt_memory_manager.cpp.hpp:417`.
  Diagnostics no-op'd by Stage 1; the size_t precomputations are
  DCE'd by the optimizer once the FL_WARN expansions are empty.
- **Stage 5 — `fl::basic_string::write`** — body at
  `src/fl/stl/basic_string.cpp.hpp:193-283` is the COW + inline-vs-heap
  storage state machine. No formatted-stream machinery to drop.

The doc now also points readers at **#2856** (Batch 3 structural
meta) as the next round of *real* multi-KB savings, since the
knob/audit work of #2886 is now genuinely complete. The Stage 6
regression-gate baseline at `tests/data/esp32s3_bloat_baseline.txt`
will only ratchet down further if a #2856 item lands measurable
savings; the projections from Stages 4 + 5 are removed from the
roadmap so users don't wait for phantom savings.

## Files

- `docs/SLIM_ESP32S3.md` — Roadmap section rewritten: every Stage's
  status reflected, Stages 4 + 5 marked audited / no action with
  file:line citations, pointer added to #2856 for the next round of
  structural savings.

## Verification

- `bash lint --cpp` → C++ linting passes (this PR is docs-only).
- File:line citations verified against post-#2900 master.

Refs #2886, #2901.
zackees added a commit that referenced this pull request Jun 7, 2026
… ✅ measured (#2904)

Closes #2903.

Lands the two follow-ups proposed in the 2026-06-06 audit comment on
the parent meta (see
#2886 (comment)).

## What changes

1. **`tests/data/esp32s3_bloat_baseline.txt`** — `388380` → `350568`.

   The previous baseline was the pre-Stage-1 number; with that pin,
   any PR that regressed anywhere between today's measured 350,568 B
   and 388,380 B silently passed the Stage 6 gate. Tightening to the
   measured post-Stage-1 number reclaims that ~38 KB of headroom and
   makes the gate enforce the actual current budget.

2. **`docs/SLIM_ESP32S3.md`** — flip row 1 of the priority table from
   📊 to ✅ with the measured delta inline, add a new "Current
   (Stage 1 only, no opt-in flags)" row to the baseline table, and
   update the per-knob caveat under the table so users know exactly
   which rows are measured vs. still projected.

## What stays 📊

- **Row 2** (`tools/sdkconfig_for_smallest_fastled.defaults`)
- **Row 3** (`-DFASTLED_RMT_STATIC_ALLOCATION=1`)
- **Row 4** (`-DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1`)
- **Row 5** (`CONFIG_BT_ENABLED=n`)

These require their respective build flag / overlay to be exercised in
a measured build before they can flip — that's a separate follow-up.

## Measurement provenance

- ELF: `master @ 824cb5c` (the merge-commit of PR #2902, "Stages 4
  + 5 close-out").
- Build mode: PIO release default (`NDEBUG` defined, so Stage 1's
  `FASTLED_LOG_VERBOSITY=0` default fires per #2890). No Stage 2 or 3
  flag set; no Stage 3 overlay applied.
- Toolchain: `xtensa-esp32s3-elf-nm` from
  `~/.platformio/packages/toolchain-xtensa-esp-elf/bin/`.
- Result: `total_flash = 350,568 B` (4,530 sized flash symbols).
- Artifacts: `.build/symbols/esp32s3/report.json` + `report.md` on the
  measuring host.

## Why this PR is safe

The Stage 6 gate at `.github/workflows/bloat_regression_esp32s3.yml`
will run on this PR with the NEW (`350568`) baseline. The build it
measures is essentially `824cb5c0e3 + this PR's docs/data-only diff`,
which has the same `total_flash` as `824cb5c0e3` because nothing in
this PR touches `src/`. Expected gate result: PASS with
`headroom = 0 B`.

If a future PR regresses past 350,568 B, the gate fails fast and the
PR author either lands a saving in the same change or explicitly
raises the baseline file in the same PR with justification.

Refs #2886, #2903, #2898, #2900, #2902.
zackees added a commit that referenced this pull request Jun 7, 2026
…dies on FASTLED_LOG_RUNTIME_ENABLED (#2918)

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.
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
`Channel::makeName(id)` synthesizes `"Channel_<id>"` when no explicit
config name is provided. The resulting name is only consumed by
`FL_WARN` / `FL_ERROR` sites that collapse to `do { } while(0)` when
`FASTLED_LOG_VERBOSITY=0` (the NDEBUG default since #2890), so the
string + `fl::to_string<i64>` instantiation + heap concat run for
nothing in release.

Gate the auto-naming branch on `FASTLED_LOG_RUNTIME_ENABLED`:
- Debug: `"Channel_<id>"` (unchanged).
- Release with no explicit name: empty string.
- Release with explicit name: explicit name (unchanged).

Empty mName in release is fine because the only read sites are
diagnostic. Public API (`Channel::getName()`) preserved.

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
…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
Companion fix to #2943: mirrors the Channel::makeName release-gate
on RxChannel::makeName. The auto-naming branch synthesizes
`"RxChannel_<id>"` only for diagnostic consumption; in release
builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per #2890) every read
site collapses to do-while-0, so the string + `fl::to_string<i64>`
+ heap concat run for nothing.

User-provided names (config.name non-empty) are unchanged in both
debug and release.

Closes #2954. 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
)

The 9-line FL_WARN diagnostic+suggestion block at the end of
RmtMemoryManager::handleAllocateTxFailure feeds 4 local variables —
including a getAvailableWords() call + 3 mLedger reads — and runs
3 conditional suggestion branches.

In release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per #2890)
all 9 FL_WARN bodies collapse to do-while-0, but the locals + the
3 condition tests still execute. Gate the whole block on
FASTLED_LOG_RUNTIME_ENABLED so the unrendered diagnostic doesn't
cost flash bytes.

The return-failure at the end of the function is preserved
unconditionally.

Same pattern as #2917 (sibling cold-helpers emitRecoveryWarning /
emitAllocationFailureError) and #2950 / #2952.

Closes #2956. Refs #2886.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant