Repository navigation
Description
Background
Carved out from the closeout of #2773 (ESP32-S3 binary-size meta). Level A of item 2.5 (FASTLED_RMT_STATIC_ALLOCATION opt-in macro) shipped in #2846; the bulk of the FL_LOG_RMT/FL_WARN rodata was already collapsed by item 2.3 (FASTLED_LOG_VERBOSITY=0, #2791). What remains is the automatic (non-opt-in) tree-shake of the runtime memory planner — Level B of the RFC at #2773 (comment).
This issue tracks Level B as its own multi-day design pass so the parent meta can close.
Goal
Let the linker prove which planner specialization a sketch needs and drop the other, without requiring the user to define a macro.
Estimated win on stock ESP32-S3 NEOPIXEL Blink: ~3–4 KB code on top of everything already shipped under #2773.
Why Level A doesn't cover this
Level A (#2846) requires the user to define FASTLED_RMT_STATIC_ALLOCATION=1 before including <FastLED.h>. That captures the ~70 % of users who actively tune binary size, but does nothing for the default build. The functions still on the live binary's hit list:
RmtMemoryManager::calculateMemoryBlocks(bool)— memory-pressure detection loop, network/idle strategy selection, platform-cap enforcement.RmtMemoryManager::allocateTx(...)hot path — DMA-vs-non-DMA branch,tryAllocateWords, ledger push.RmtMemoryManager::freeDMA(u8, bool)— small but unconditionally reachable from~ChannelEngineRMTImpl.
The reason these can't be tree-shaken today is that the destructor at channel_driver_rmt.cpp.hpp:142 unconditionally calls memMgr.freeDMA(...) and memMgr.free(...), which pulls the whole planner ledger machinery in via instance-singleton + allocations vector reachability.
Proposed design
Make ChannelEngineRMTImpl<bool kStatic> a class template:
kStatic = truespecialization (default at startup before any otheraddLeds<>is seen): slimcreateChannelthat calls a separateallocateTxStaticmember — singletryAllocateWords+ ledger push, no planner, no diagnostics.kStatic = falsespecialization: current behavior (full planner, network-coex, recovery).
Detection happens through a bool kIsStaticInit thread-local that flips to false after setup() returns or the first removeLeds() / late addLeds() is observed. The static specialization is only safe before that flip; both specializations are generated and the linker drops whichever the sketch doesn't reach.
Risks
- Blast radius — touches template instantiation in every example sketch that uses ESP32 RMT5.
- Test fixtures / mock peripheral injection — needs careful audit so unit tests still resolve the right specialization.
- Maintenance cost — two specializations means two code paths to keep in sync for any future RMT5 change. Counter: the static one is much simpler, so divergence is bounded.
- Detection edge case — defining "setup() has returned" portably without an explicit user hook. May need a
static int kInitDepthguard inaddLeds<>that's incremented/decremented around the call, with the flip happening once depth returns to 0 after the first non-zero entry.
Out of scope
- Any new opt-in macros (Level A already covers macro-driven users).
- API-level changes to
addLeds<>(e.g. carrying length at compile time via NTTP). Those are useful but are a separate design. - Anything from the parent meta that already shipped under Meta: ESP32-S3 binary-size reduction — Batch 1 (~26 KB) + Batch 2 (~26–50 KB) (supersedes #2771) #2773.
Acceptance criteria
- Stock ESP32-S3
examples/Blink/Blink.inobuild drops by ≥3 KB infirmware.bin(no user macros set) vs current master. - All in-tree examples that use ESP32 RMT5 still compile.
-
bash test --cppgreen. - No regression on builds that set
FASTLED_RMT_STATIC_ALLOCATION=1(feat(rmt5): FASTLED_RMT_STATIC_ALLOCATION opt-in macro (#2773 item 2.5 Level A) #2846 path still works the same way). - No regression on builds that exercise the dynamic path (
removeLeds()or lateaddLeds()).
References
- Parent meta: Meta: ESP32-S3 binary-size reduction — Batch 1 (~26 KB) + Batch 2 (~26–50 KB) (supersedes #2771) #2773
- Level A (shipped): feat(rmt5): FASTLED_RMT_STATIC_ALLOCATION opt-in macro (#2773 item 2.5 Level A) #2846
- Level B RFC (original): Meta: ESP32-S3 binary-size reduction — Batch 1 (~26 KB) + Batch 2 (~26–50 KB) (supersedes #2771) #2773 (comment)
- Easy-share cold split: perf(rmt5): split allocateTx fail-path into cold helper (#2773 item 2.5) #2840
- Verbosity knob (collapses the rodata side): feat(log): FASTLED_LOG_VERBOSITY release knob — opt-in −43 KB on ESP32-S3 (#2773 item 2.3) #2791
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
zackees commentedon Aug 20, 2026
Triaged against current master ad40fd2.
Marking deferred: the requested automatic no-macro ChannelEngineRMTImpl static specialization has not landed and remains a speculative cross-layer redesign, not a bounded fix.
Current evidence:
Restart with a fresh same-toolchain A/B symbol audit. Continue only if the target is still evidence-backed, then revise the RFC around a truly compile-time factory boundary and add focused static/dynamic lifecycle tests plus S3/C3/C6/H2/P4 validation.