Repository navigation
perf(esp32): gate UCS7604 clockless cases in Channel::showPixels behind FASTLED_DISABLE_UCS7604 - #2921
Conversation
…nd FASTLED_DISABLE_UCS7604 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.
|
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)
📝 WalkthroughWalkthroughThis PR gates UCS7604 encoder handling in ChangesUCS7604 encoder gating
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.
…max_savings (#2934) Closes #2933. Adds coverage for the four opt-in build flags shipped after #2906: - `FASTLED_DISABLE_SPI_CHIPSETS=1` (#2914) — disable_spi config - `FASTLED_DISABLE_UCS7604=1` (#2921) — disable_ucs7604 config - `FASTLED_DISABLE_DYNAMIC_DRIVER=1` (#2927) — disable_dyndriver config - `FASTLED_DISABLE_CHANNEL_EVENTS=1` (#2932) — disable_events config Plus a new `max_savings` config that stacks ALL eight opt-ins (Stages 2 + 3 + 4 + the 4 new gates) — the headline cumulative saving for users who enable everything. Also adds a `slim_row` field to `OptInConfig` and a new `SLIM row` column to the comparison table. The output table now maps 1:1 onto the priority table in `docs/SLIM_ESP32S3.md`, making it copy-pasteable into a follow-up doc-flip PR. ## Files - `tests/measure_esp32s3_opt_ins.py`: - `OptInConfig` gains `slim_row: int | None`. - New module-level `_ALL_OPT_IN_FLAGS` tuple so the `max_savings` config doesn't drift from the per-flag configs. - 4 new configs + `max_savings` added to `CONFIGS`. - `format_table` gains the `SLIM row` column. ## Verification - `bash lint` -> all linters pass (ruff, ty, C++, JS setup). - No FastLED runtime change; doesn't affect any build. - The config matrix matches the SLIM doc priority table 1:1. ## Out of scope - Running the measurements. Separate follow-up PR. - Updating SLIM doc rows 📊 → ✅. Requires the measurements. Refs #2886, #2906, #2914, #2921, #2927, #2932.
Closes #2920. Mirrors #2914's SPI dispatch gate for the UCS7604 clockless cases. Opt-in build flag drops ~400-600 B on WS2812-only NEOPIXEL Blink builds. Default behavior unchanged; regression-gate baseline unaffected.
Summary by CodeRabbit
New Features
Documentation