Repository navigation
fix(esp32): correct FASTLED_ASSERT release no-op + ratchet baseline 344769 -> 340832 - #2925
Conversation
…44769 -> 340832 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.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesFASTLED_ASSERT Release-Mode Simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related issues
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…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.
…_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.
…) (#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.
….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.
…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]>
… (#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]>
Fixes the broken release no-op in #2924 (sizeof of an sstream chain doesn't compile outside the sstream context). Replaces with canonical
((void)0)matching C<assert.h>NDEBUG semantics.Measured saving: −3,937 B flash (340,832 vs 344,769). ClocklessIdf5 attribution drops −628 B (47,288 vs 47,916). Baseline ratcheted in the same PR.
Refs #2886, #2923, #2924.
Summary by CodeRabbit