Repository navigation
Description
Goal
Gate Channel::resolveDynamicDriver() behind an opt-in FASTLED_DISABLE_DYNAMIC_DRIVER=1 build flag, with Channel::showPixels shortcut-returning silently if the driver isn't pre-bound. For stock addLeds<NEOPIXEL> (and every other addLeds<> flavor that calls setDriver(...) in its ctor), the dynamic-driver-lookup path is dead at runtime — but it's statically reachable from showPixels, so the 373 B is pinned in the binary.
Parent: #2886 — eleventh algorithmic-bloat reduction (after sort_small, s16x16::pow, emit-gate, SPI gate, UCS7604 gate, assert-gate, plus the doc/Stage PRs).
Why this is concrete
fl::Channel::showPixels at src/fl/channels/channel.cpp.hpp:459-471:
if (mDriverPreBound) {
driver = mDriver.lock();
if (!driver) { return; }
} else {
driver = resolveDynamicDriver(); // [link target]
if (!driver) { return; }
}mDriverPreBound is set to true by ClocklessIdf5::ClocklessIdf5()'s setDriver(BusTraits<Bus::RMT>::instancePtr()) call. The else branch is dead at runtime for the legacy addLeds<> flow. But the compiler can't prove the runtime value of mDriverPreBound, so it keeps the resolveDynamicDriver() call statically reachable.
Measured baseline (post-#2925 ELF, master @ f8ca3aa715)
| Symbol | Size |
|---|---|
fl::Channel::resolveDynamicDriver() |
373 B |
fl::ChannelManager::findDriverByName(...) (only called from resolveDynamicDriver in this build) |
~100-200 B est. |
fl::ChannelManager::selectDriverForChannel(...) (same caller) |
~150-300 B est. |
| Estimated total | ~600-900 B |
The dead-strip cascade pattern from #2918 and #2925 suggests the actual saving may exceed the headline 373 B once the ChannelManager lookup chain dead-strips with no live caller.
Deliverable
src/fl/channels/channel.cpp.hpp — gate the call site
if (mDriverPreBound) {
driver = mDriver.lock();
if (!driver) { return; }
} else {
+#if !defined(FASTLED_DISABLE_DYNAMIC_DRIVER) || !FASTLED_DISABLE_DYNAMIC_DRIVER
driver = resolveDynamicDriver();
if (!driver) { return; }
+#else
+ // Dynamic-driver lookup gated out via FASTLED_DISABLE_DYNAMIC_DRIVER
+ // (#2926). Channels created via Channel::create(cfg) without a
+ // pre-bound driver silently emit nothing when this flag is set.
+ return;
+#endif
}Also gate resolveDynamicDriver()'s definition itself so the body is excluded from compilation when the flag is set — that's what allows the linker to dead-strip ChannelManager::findDriverByName / selectDriverForChannel.
Behavior when the flag is set
addLeds<NEOPIXEL>(and every legacyaddLeds<>flavor): unchanged. They pre-bind in their ctors.Channel::create(cfg)(manager-based API without pre-binding):showPixelsreturns silently. User accepts the constraint by setting the flag.
Documentation
docs/SLIM_ESP32S3.mdpriority table gains row 9 with the new flag.agents/docs/binary-size-analysis.mdmirrors.
Acceptance
FASTLED_DISABLE_DYNAMIC_DRIVER=1build flag gatesresolveDynamicDriver().bash lint --cpppasses.- Default behavior unchanged.
- Measured saving: projected ~400-900 B on stock NEOPIXEL Blink with the flag set.
docs/SLIM_ESP32S3.mdrow 9 exists.
Out of scope
- Auto-detecting
mDriverPreBound's value at compile time. Would require template-trait static dispatch (Meta: ESP32-S3 binary-size reduction — Batch 3 (successor to #2773) #2856 item 3.1). - Removing the dynamic-driver code entirely. Users of
Channel::create(cfg)still need it without the opt-in.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + audit cycle.
- perf(esp32): gate SPI dispatch in Channel::showPixels behind FASTLED_DISABLE_SPI_CHIPSETS #2914 / perf(esp32): gate UCS7604 clockless cases in Channel::showPixels behind FASTLED_DISABLE_UCS7604 #2921 — prior opt-in gates (the pattern this mirrors).
- perf(esp32): gate emit* cold helpers on FASTLED_LOG_RUNTIME_ENABLED (~800 B) #2918 / fix(esp32): correct FASTLED_ASSERT release no-op + ratchet baseline 344769 -> 340832 #2925 — emit-gate and assert-gate (the dead-strip cascade lesson).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(channels): gate Channel::resolveDynamicDriver behind FASTLED_DIS…