Repository navigation
Description
Goal
Cut bytes attributed to fl::ClocklessIdf5<...>::ClocklessIdf5() (top-1 symbol, 48,002 B map-derived) by gating the SPI dispatch branch in fl::Channel::showPixels behind an opt-in build flag FASTLED_DISABLE_SPI_CHIPSETS=1. For NEOPIXEL-only sketches (the stock Blink case), users opt in and the linker dead-strips ~5 PixelIterator SPI encoder methods that are otherwise statically reachable from showPixels.
Parent: #2886 — third algorithmic-bloat reduction targeting symbols reachable from the ClocklessIdf5 static-init closure.
Why this is a real win
fl::Channel::showPixels at src/fl/channels/channel.cpp.hpp:486-557 has two branches gated by runtime mChipset.is<>() checks:
if (mChipset.is<ClocklessChipset>()) {
// 2-case switch: WS2812 or UCS7604
} else if (mChipset.is<SpiChipsetConfig>()) {
// 11-case switch: APA102 / DOTSTAR / SK9822 / WS2801 / WS2803 /
// P9813 / LPD8806 / LPD6803 / SM16716 / HD108 / HD107 / ...
}For a stock NEOPIXEL Blink sketch, mChipset is always ClocklessChipset and the SPI branch is dynamically unreachable, but the compiler can't prove that — every pixelIterator.writeXXX(...) reference in the SPI branch is statically reachable, so the linker keeps the encoder bodies alive.
Measured cost (post-#2911 ELF, master @ f090358d76)
The 4-5 dead-code PixelIterator SPI encoder symbols currently linked into a NEOPIXEL Blink:
| Symbol | Size |
|---|---|
fl::PixelIterator::writeLPD8806<fl::vector_psram<u8>> |
235 B |
fl::PixelIterator::writeSK9822<fl::vector_psram<u8>> |
197 B |
fl::PixelIterator::writeAPA102<fl::vector_psram<u8>> |
197 B |
fl::PixelIterator::writeSM16716<fl::vector_psram<u8>> |
91 B |
| Total | 720 B |
Plus the showPixels body itself shrinks by the switch-table footprint (~300-500 B for an 11-case switch on xtensa).
Conservative projected saving: ~1.0-1.2 KB on NEOPIXEL Blink builds.
writeWS2812 (the live encoder on Blink, 277 B) stays.
Deliverable
src/fl/channels/channel.cpp.hpp — gate the SPI branch
if (mChipset.is<ClocklessChipset>()) {
// ... clockless dispatch unchanged ...
+#if !defined(FASTLED_DISABLE_SPI_CHIPSETS) || !FASTLED_DISABLE_SPI_CHIPSETS
} else if (mChipset.is<SpiChipsetConfig>()) {
// ... SPI 11-case dispatch unchanged ...
+#endif
}The !defined() || !FLAG form keeps the default unchanged for users who haven't set the flag.
Behavior when the flag is set
If a user sketch sets FASTLED_DISABLE_SPI_CHIPSETS=1 AND uses FastLED.addLeds<APA102, ...> (or any SPI chipset), the SPI dispatch is gone — calling showPixels on that channel silently emits nothing. This is the same trade-off as Stage 2's FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT: opt-in, with the user accepting the constraint that they're not using SPI chipsets.
Document the constraint clearly in:
- the macro definition site (a comment block at the gate)
docs/SLIM_ESP32S3.mdpriority table (new row WS2801 Timing issue - Calling FastLED.show() too quickly does not update the LEDs. #6)tools/sdkconfig_for_smallest_fastled.defaults(companion build flag note)
Acceptance
FASTLED_DISABLE_SPI_CHIPSETS=1build flag gates the SPI branch inChannel::showPixels.bash lint --cpppasses.- Default behavior (flag unset) unchanged — existing examples using APA102 / SK9822 / etc. continue to work.
- Measured against the post-perf(gamma): use fl::s16x16::pow for Gamma8 LUT + applyGamma_video; drop __ieee754_pow #2911 ELF baseline (347,004 B), a
-DFASTLED_DISABLE_SPI_CHIPSETS=1build of NEOPIXEL Blink should be ~1.0-1.2 KB lower. Default-flag build should be unchanged within ±50 B. docs/SLIM_ESP32S3.mdpriority table gains a row 6 for the new flag.
Out of scope
- Auto-detecting whether SPI chipsets are used at compile time. That requires the template-trait static dispatch refactor in Meta: ESP32-S3 binary-size reduction — Batch 3 (successor to #2773) #2856 item 3.1, much larger blast radius.
- The clockless UCS7604 branch — that's a different (smaller) opt-in.
- Examples / library.properties advertising the flag — initial scope is the gate + doc.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + audit comments at
#issuecomment-4641413123/#issuecomment-4641538602. - perf(esp32): add fl::sort_small for bounded containers; cut ClocklessIdf5 bloat #2908 / perf(gamma): use fl::s16x16::pow for Gamma8 LUT + applyGamma_video; drop __ieee754_pow #2911 — prior algorithmic-bloat PRs (sort_small, s16x16::pow).
- perf(esp32): suppress Arduino-ESP32 boot banner via build-flag shim (#2886 Stage 2) #2894 — Stage 2 boot-banner shim — pattern reference for an opt-in build-flag gate.
- Meta: ESP32-S3 binary-size reduction — Batch 3 (successor to #2773) #2856 item 3.1 — template-trait static dispatch for showPixels — the structural successor to this tactical gate.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(esp32): gate SPI dispatch in Channel::showPixels behind FASTLED_…