Repository navigation
Description
Slim-bridge conversion moved to meta issue #4580 (2026-09-24)
The directive to convert every legacy addLeds<> controller (clockless and clocked, all platforms) to the slim bridge now lives in #4580. That issue has the evidence, the gap register, the testing plan, the exhaustive inventory, and 18 sub-issues (#4581-#4598). It is linked here as a sub-issue.
Summary
Successor to #2773, which shipped Batches 1+2 (~30 KB default-mode + ~22-43 KB opt-in via FASTLED_LOG_VERBOSITY=0 and FASTLED_RMT_STATIC_ALLOCATION=1). The cumulative #2773 work brought the ESP32-S3 NEOPIXEL Blink baseline from 673 KB → ~595-620 KB.
This issue scopes the next architectural round: items that #2773's closing comment classified as "structural to the post-#2420 ChannelManager/RMT architecture and won't close without deeper redesign." Each is bigger and riskier than a Batch 1/2 item, so they get their own issue.
Methodology change vs #2773. The local PIO toolchain proved fragile (cache wipe during disk cleanup left xtensa-esp32s3-elf-g++ + esptool.py missing). For this round, audit via CI artifacts instead of local builds:
- Push a branch with the candidate change.
- Open a PR that triggers the existing
compile-manymatrix. - Extract
firmware.bin/firmware.mapfrom the CI artifact bundle. - Compare against a same-SHA baseline build (no change) on the same matrix entry.
FastLED/fbuild#417 would make this push-button.
Tracking matrix
| Item | Est. savings | Mechanism preventing auto tree-shake | Status | PR |
|---|---|---|---|---|
3.1 Channel::showPixels Level B — template-trait static dispatch |
~3-4 KB | Linker drops whole functions only; need per-instantiation specialization | not started | — |
3.2 fl::sstream operator<< → printf-style log backend |
~5-10 KB | Each FL_WARN/FL_LOG_RMT site instantiates a fresh sstream operator chain; printf path is one shared TU | not started | — |
3.3 ChannelManager static-bind path for boot-time addLeds<>() |
~5-10 KB | Dynamic vtable dispatch through BusTraits<Bus::X>::instancePtr(); static path can pre-bind |
not started | — |
| 3.4 RMT5 encoder dedup across chipsets | ~2-5 KB | Each chipset gets its own encoder instantiation; multi-chipset sketches rare | not started | — |
3.5 fl::result<T, E> → status code for internal-only APIs |
~1-2 KB | Discriminator + payload struct ABI vs single-register return | not started | — |
3.6 fl::vector<ChannelAllocation> → fixed-size array under static-allocation |
~1 KB | Runtime vector carries growth machinery even when count is bounded | not started | — |
Batch 3 post-merge projection: ~17-32 KB additional on top of Batch 2.
Realistic post-everything baseline: ~565-605 KB (vs 3.10.3 baseline of 344 KB).
Items
3.1 Level B template-trait refactor of Channel::showPixels — ~3-4 KB
Carry-over from #2773 item 2.5 Level A → Level B (RFC posted there). Level A shipped as the FASTLED_RMT_STATIC_ALLOCATION opt-in macro (#2846). Level B replaces the macro with template-trait detection so the --gc-sections linker proves at link time which specialization is reachable, no user opt-in required.
Action: Make ChannelEngineRMTImpl<bool kStatic> a class template. Static specialization uses a slim allocateTxStatic + slim createChannel; dynamic specialization keeps current behavior. A kIsStaticInit thread-local flips false after setup() returns or first removeLeds() / late addLeds(). Static specialization is safe only before the flip; both specializations are emitted and the linker drops whichever the sketch doesn't reach.
Risk: Touches template instantiation in every example. Needs careful audit of test fixtures and mock peripheral injections (the #ifdef FASTLED_STUB_IMPL paths in channel_driver_rmt.cpp.hpp are already heavily #ifdef'd).
3.2 Printf-style log backend for FL_WARN / FL_LOG_RMT — ~5-10 KB
Every FL_WARN(X) call site at FASTLED_LOG_VERBOSITY=1 (the default) instantiates:
fl::println((fl::sstream() << ... << X).c_str())Each operator<< chain compiles to a fresh sequence of fl::sstream::operator<<(...) calls per type. Across hundreds of FL_WARN sites in FastLED's libraries the operator<< specializations don't merge — they're per-translation-unit.
Action: Add a parallel fl::printf("fmt", args...) API and migrate the highest-density FL_WARN/FL_LOG_RMT sites. The format string lives in rodata once, the runtime decoder is one TU, and the call-site code shrinks to a single function call + arg push.
Caveat: fl::printf would need to route through fl::println (no link to libc printf) so we don't reintroduce the _svfprintf_r bloat killed in #2773 item 1.1.
Where to start: RMT5 channel_driver_rmt.cpp.hpp has ~20 FL_WARN/FL_LOG_RMT call sites with multi-line operator<< chains. That alone is plausibly ~2-3 KB.
3.3 Static-bind path for boot-time addLeds<>() — ~5-10 KB
The post-#2428 Channel<Bus, Chipset> API uses dynamic dispatch through BusTraits<Bus::X>::instancePtr(). For the common static-init scenario (one or two addLeds<>() calls in setup(), no later removal), the vtable indirection is dead weight.
Action: Re-add the legacy pre-#2428 pre-bind path as the default for addLeds<>() calls made before setup() returns. The dynamic API stays the path for late-bound add/remove. Same kIsStaticInit thread-local from #3.1 gates the choice at runtime; the linker drops the unused branch when only one is reachable per chipset×bus instantiation.
Risk: Large blast radius — every example uses addLeds<>(). Need to audit the test matrix carefully.
3.4 RMT5 encoder dedup across chipsets — ~2-5 KB
Each chipset (WS2812, WS2811, SK6812, APA102, …) gets its own encoder instantiation via mPeripheral.createEncoder(timing, FASTLED_RMT5_CLOCK_HZ). The body is small but the per-chipset instantiation is duplicated — and the timing struct varies only by a handful of uint16_ts.
Action: Move the encoder body to a single non-template function taking (const ChipsetTiming&, uint32_t clock_hz). The current call site already passes those args; the change is mostly removing template syntax sugar.
Audit risk: Need to verify the encoder isn't relying on type-level distinctions anywhere downstream (it shouldn't — the RMT peripheral takes a void* encoder handle).
3.5 fl::result<T, E> → status code for internal-only APIs — ~1-2 KB
result<size_t, RmtMemoryError> is a sum-type with a discriminator + the payload. For internal-only APIs (e.g. RmtMemoryManager::allocateTx is called only from ChannelEngineRMT::createChannel), the ABI cost is real: 2 registers in/out vs 1, extra branch on the discriminator at each call site.
Action: Add an internal-API overload returning size_t with sentinel value (0 = failed). Keep the public result<> API stable. Wire createChannel through the new internal path.
Risk: Low. The result<> API is well-tested; the internal overload would be a thin wrapper.
3.6 Fixed-size allocation ledger under FASTLED_RMT_STATIC_ALLOCATION — ~1 KB
When FASTLED_RMT_STATIC_ALLOCATION=1 (#2846), the user has asserted "one fixed strip, boot-time init, no dynamic add/remove." Under that contract, fl::vector<ChannelAllocation> allocations is overkill — a single ChannelAllocation field would do. The vector pulls its growth machinery (reserve, push_back, erase) into the static binary even when only one element is ever stored.
Action: Under FASTLED_RMT_STATIC_ALLOCATION, replace mLedger.allocations with a fl::array<ChannelAllocation, SOC_RMT_TX_CANDIDATES_PER_GROUP> + a count.
Caveat: Less reach than #3.5; the savings depend on whether vector's machinery is already shared with other vector instantiations in the binary.
Methodology — how to audit Batch 3 PRs
Local builds are unreliable (toolchain cache fragile). Run the audit via CI artifacts:
# 1. Push the candidate change to a branch.
git push -u origin feat/2818-3.1-channel-static-dispatch
# 2. Trigger compile-many via PR; let CI run.
gh pr create --base master --title "..." --body "..."
# 3. After CI completes, fetch the firmware.bin artifact.
RUN=$(gh run list --branch feat/2818-3.1-channel-static-dispatch --workflow build --limit 1 --json databaseId --jq '.[0].databaseId')
gh run download $RUN --name esp32s3-firmware --dir /tmp/audit
# 4. Same for a same-SHA baseline build.
# (Either compare against master's last successful build artifact,
# or push an empty commit on the branch and compare side-by-side.)A future fbuild audit-esp32s3-blink subcommand (FastLED/fbuild#417) would make this push-button.
Related issues / prior work
- Meta: ESP32-S3 binary-size reduction — Batch 1 (~26 KB) + Batch 2 (~26–50 KB) (supersedes #2771) #2773 — Batch 1+2 (closed; this issue's parent)
- ESP32-S3 binary size: 657 KB on master vs 344 KB on 3.10.3 — remaining +313 KB delta breakdown #2473 — Master tracking issue (+313 KB delta vs 3.10.3)
- Meta: ESP32-S3 binary-size reduction — SUPERSEDED by #2773 (see comment for details) #2771 — Original (corrected) version of Meta: ESP32-S3 binary-size reduction — Batch 1 (~26 KB) + Batch 2 (~26–50 KB) (supersedes #2771) #2773
- feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428 — ChannelManager refactor (the architectural source of much of the remaining ~250 KB delta)
- Symbol/size analysis: detect or prevent map-file 0x00000000 false positives (~95 KB phantom-bloat reported on FastLED#2473) fbuild#417 — push-button binary-size audit subcommand
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
zackees commentedon Jun 6, 2026
/clud-pr status update
Working through this meta. The clud-pr skill's "one PR per task" rule conflicts with a meta covering 6 architecturally-independent items, so the split chosen is: ship every item that fits in a single PR immediately as its own PR; defer multi-day items to dedicated follow-ups.
Shipped (open PRs)
FASTLED_RMT_STATIC_ALLOCATIONfree()/freeDMA()become no-ops under the macro, killingfl::vector_inlined::erase+ diagnosticFL_LOG_RMT/FL_WARNoperator<< chainstryAllocateTx/tryAllocateRxstatus-code variantsresult<size_t, RmtMemoryError>ABI at the 4 internal callers; publicresult<>-bearing API retainedAlready done before #2856 was filed
IRMT5Peripheral::createEncoder(const ChipsetTiming&, u32), not templated per-chipset. The byte estimate in the original tracking matrix doesn't apply.Deferred to dedicated PRs
These each need their own multi-day PR with its own scoping pass — landing speculative scaffolding under a /clud-pr would be wrong:
Channel::showPixelsChannelEngineRMTImpl<bool kStatic>template + akIsStaticInitthread-local + careful audit of every example'saddLeds<>instantiation. Multi-day.fl::printfAPI surface (not present today; can't reuse libcprintfwithout re-pulling_svfprintf_rkilled by #2773 item 1.1). Then bulk migration of ~hundreds of FL_WARN/FL_LOG_RMT sites. Multi-day.addLeds<>()Each of these warrants its own focused issue rather than living under this meta.
Recommendation
After #2861 and #2862 land, close this meta and re-open 3.1, 3.2, 3.3 as three standalone issues so each one's design discussion happens in isolation. The meta as currently scoped is partially redundant (item 3.4 was a misread of current state) and contains items at incompatible scales (3.5/3.6 are PR-sized; 3.1/3.2/3.3 are sprint-sized).
perf(rmt5): no-op free()/freeDMA() under FASTLED_RMT_STATIC_ALLOCATION (
perf(rmt5): tryAllocateTx/tryAllocateRx status-code variants (FastLED…
perf(rmt5/log): combined meta FastLED#2856 items 3.1 + 3.2 + 3.3 + 3.5
docs(esp32): close out #2886 Stages 4 + 5 — audited / no action (#2902)
docs(esp32): add CONFIG_NEWLIB_NANO_FORMAT=y to Stage 3 sdkconfig ove…
zackees commentedon Jun 16, 2026
Triage pass:
No progress since filing — all 5 tracking-matrix items (3.1 template-trait static dispatch / 3.2 sstream→printf / 3.3 ChannelManager static bind / 3.4 RMT5 encoder dedup / 3.5 partial) show "not started" with no PR.
Each is genuinely architectural work — not the knob-flip / sdkconfig variety of #2773's first two batches. Estimated savings per item are 2-10 KB; cumulative if all five ship would be ~20-40 KB on top of #2773's already-shipped 50-80 KB.
Recommendation: the work is still relevant in principle, but "not started" 10 days after filing suggests it's a backlog rather than an active workstream. Two options:
Standing by — happy to pick up 3.4 (RMT5 encoder dedup) as an off-bench piece if you confirm it doesn't overlap with the bloat band work in #2974.
zackees commentedon Jun 16, 2026
B3 of meta #3122 investigation:
Looked at the actual code.
Rmt5EncoderImpl::create(ChipsetTiming, resolution_hz)insrc/platforms/esp/32/drivers/rmt/rmt_5/rmt5_peripheral_esp.cpp.hpp:556is already runtime-parameterized byChipsetTiming— there's no per-chipset encoder template instantiation to dedup at the encoder level.The 58 KB per-chipset symbol from #2886's top-25 (
fl::ClocklessIdf5<3, WS2812_800KHZ, GRB, 0, false, 280>::ClocklessIdf5()) comes from the outerClocklessIdf5<DATA_PIN, TIMING, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>template — specifically the transitive FL_WARN/FL_LOG closure pulled in by the ctor (75 sites inchannel_driver_rmt.cpp.hpp, 59 inrmt_memory_manager.cpp.hpp). Stage 1 of #2886 (FASTLED_LOG_VERBOSITY=0) already addresses the lion's share of that.Item 3.4 as stated is essentially complete — the encoder isn't duplicated per chipset; what looked like duplication is the FL_WARN cluster, which #2886's Stage 1 handled.
Recommendation: ✅ close item 3.4 as superseded by #2886 Stage 1 (#2890). If multi-chipset sketches are still showing per-chipset weight after Stage 1 is applied, the duplication is at the outer ClocklessIdf5 template level — a different problem than "encoder dedup" and would need its own focused issue.
(B3 in #3122 ticked accordingly.)
zackees commentedon Jun 16, 2026
Item 3.2 (
fl::sstream operator<<→ printf-style log backend) is now tracked as standalone issue #3158, with the API contract, format-string safety story, NANO-compat audit plan, and call-site migration roadmap. This is the highest-ROI item of #2856 (~5-10 KB on ESP32-S3 Blink) and needed proper scoping rather than rundown-row execution.zackees commentedon Aug 20, 2026
Triaged against current master ad40fd2.
Marking deferred: this meta is not resolved, but its remaining work is architectural and spans independent efforts rather than one bounded fix.
Current evidence:
Restart when the size gate is green under one same-SHA production-representative measurement contract, then split 3.1 and 3.6 into bounded design-backed issues with lifecycle/capacity tests and explicit size targets.
perf(rmt5): fixed one-record allocation ledger under static allocation (
zackees commentedon Sep 24, 2026
Updated the issue description with a directive: all legacy clockless and clocked (SPI)
addLedscontrollers move to the slim bridge format (plainCPixelLEDController+ ownedChannelData, registered withChannelManager, not anfl::Channel). Evidence is draft #4576: ESP32-S3 Blink −22.5 KB, and it passes AutoResearch on an ESP32-C6. The per-controller checklist is at the top of the description.zackees commentedon Sep 24, 2026
Added a Known gaps of the slim bridge register to the description, based on a 7-way code audit of draft #4576. It records regressions, pre-existing gaps and coverage gaps, and each entry is marked verified-in-code or inferred. It is a register, not a fix list. The two highest-impact items:
ClocklessIdf4andClocklessSPInever register withChannelManager, so their data is likely never transmitted today.zackees commentedon Sep 24, 2026
Added a Testing plan section. It maps every gap in the register (A1-A12, B1-B5, C1-C2) to a host unit test. The key prerequisite (T0) is extracting one shared, host-compilable
SlimBridgeControllertemplate, so host tests exercise the same code the ESP32 builds use. Per-platform controllers then become thinDriverTraitsaliases that all run one conformance suite. The acceptance criteria now require passing that suite.zackees commentedon Sep 25, 2026
The directive now covers every platform, not only ESP32. It adds:
fl::Channel), unregistered-slim (the B1 bug class), compliant, or pure legacy;SlimBridgeCheckerlint that fails every non-compliant controller until its platform converts, and is deleted once the inventory is empty.Pure bit-bang targets (AVR, ATtiny and others) would use a manager-free "Direct"
DriverTraits, so the conversion adds no flash there. Whether they convert now or are exempted is left as an open decision.zackees commentedon Sep 25, 2026
The slim-bridge directive, gap register, testing plan and inventory moved to the new meta issue #4580, which is linked as a sub-issue. Tracking uses native sub-issues (#4581-#4598) rather than a checked-in lint, so
masteris never turned red.