Repository navigation
perf(channels): gate fl::ChannelEvents behind FASTLED_DISABLE_CHANNEL_EVENTS - #2932
Conversation
…_EVENTS 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.
|
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 (3)
📝 WalkthroughWalkthroughThis PR implements an opt-in build flag ChangesChannel Events Conditional Compilation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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 |
…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 #2931. Opt-in build flag replaces 7 fl::function_list event slots with NoOpChannelEvent. Projected ~1-2 KB on stock NEOPIXEL Blink. Refs #2886.
Summary by CodeRabbit
New Features
-DFASTLED_DISABLE_CHANNEL_EVENTS=1build flag to reduce flash memory usage (~1-2 KB) on memory-constrained devices. When enabled, channel event listeners compile but callbacks are silently skipped.Documentation