Repository navigation
Description
Background
Per the symbol-bloat analysis of the latest ESP32-S3 Blink build (fbuild, post #2968):
- Total flash: 330,054 B across 3,428 live symbols
- 8 distinct
fl::*functions land in the 1-4 KB band, totaling 13,738 B - ESP-IDF / libc cluster (~28 KB libc printf, ~10 KB ESP-IDF drivers, ~5 KB Arduino HAL) dominates the absolute top, but those are vendor-controlled. The 1-4 KB band is where FastLED has real leverage.
The smoking-gun pattern
Every single 1-4 KB FastLED symbol is dominated by FL_WARN/FL_ERROR/FL_INFO machinery. Verified across all 8:
| Callee shared by all 8 functions | Bytes |
|---|---|
fl::detail::log_emit(log_kind, char const*, int, fl::sstream&) |
222 B |
fl::fastled_file_offset(char const*) |
113 B |
fl::sstream::appendFormatted(long) |
83 B |
fl::sstream::appendFormatted(unsigned long) |
83 B |
fl::string::string() |
30 B |
fl::basic_string::~basic_string() |
30 B |
fl::basic_string::append(char const*) |
27 B |
_Unwind_Resume (C++ exception unwinding) |
156 B |
__stack_chk_fail + __stack_chk_guard |
13 B |
These callees are referenced (so they each cost their full size once). But the per-call-site inline cost is what bloats individual functions:
Per FL_WARN/FL_ERROR call site:
~200-300 B inline (sstream ctor + format << chain + log_emit call)
~100-200 B exception landing pad metadata (string/sstream dtors can throw)
A function with 3-5 log sites ends up with ~1-2 KB of pure logging overhead.
Constraint
Logging must stay enabled — FASTLED_LOG_VERBOSITY=1 (the default for debug + when SKETCH_HAS_LARGE_MEMORY) must continue to produce full log output. Sub-issues that try to no-op log call sites are off-table.
What IS in scope: make the logging infrastructure itself cheaper. Examples:
- Mark string/sstream destructors
noexcept-> eliminate landing pads (saves ~100-200 B per call site) - Push more inline boilerplate into
log_emit-> shrink the per-call-site burst - Consolidate multiple log sites in one function through
expected<>::failure(...)carrying the error info to a single bottom-of-function log - Specialize basic_string hot path so writes from sstream don't pay the variant-storage dispatch
- Extract validation/error paths into
[[gnu::cold]]helpers (out-of-line, doesn't bloat the caller) - Convert dynamic-driver dispatch (which currently inlines multiple writer templates) to virtual dispatch
Sub-issues (will be linked as filed)
Cross-cutting (affects all 8 functions):
- bloat: mark fl::basic_string + fl::sstream dtors noexcept to eliminate per-call-site landing pads #2975 Mark
fl::basic_string+fl::sstreamdestructorsnoexceptto eliminate per-call-site landing pad metadata - bloat: move more FL_WARN/FL_ERROR per-call-site code into log_emit (shrink call-site burst from ~200 B to ~50 B) #2982 Move more of the inline FL_WARN/FL_ERROR per-call-site burst into
log_emit(shrink call-site cost from ~200 B to ~50 B) - bloat: inline-storage fast path in fl::basic_string::write (skip variant dispatch for the common case) #2976 Inline-storage fast path in
fl::basic_string::write(char const*, unsigned int)
Per-function:
- bloat: consolidate error log sites in ChannelEngineRMTImpl::reconfigureForNetwork + createChannel through expected<>::failure #2983
fl::ChannelEngineRMTImpl::reconfigureForNetwork()(2,378 B) +createChannel(...)(2,198 B) — consolidate error paths through single log site viaexpected<>::failure - bloat: virtualize per-chipset writer dispatch in fl::Channel::showPixels (stop inlining 3 writer templates into one symbol) #2981
fl::Channel::showPixels(PixelController<RGB,1,-1>&)(1,884 B) — virtualize dynamic driver dispatch to stop inlining multiple writer templates - bloat: extract addDriver validation + log paths into [[gnu::cold]] helper #2979
fl::ChannelManager::addDriver(int, shared_ptr<IChannelDriver>)(1,756 B) — extract validation/log paths into[[gnu::cold]]helper - bloat: extract RmtMemoryManager::handleAllocateTxFailure format machinery into shared cold helper #2978
fl::RmtMemoryManager::handleAllocateTxFailure(...)(1,710 B) — extract format-and-log machinery into shared cold helper - bloat: consolidate log sites in Rmt5EncoderImpl::initialize + extract esp-idf-error-wrap helper #2977
fl::detail::Rmt5EncoderImpl::initialize(...)(1,466 B) — consolidate multiple log sites + extract encoder-builder error wrapping - bloat: reduce dispatch-loop landing pad count in ChannelEngineRMTImpl::processPendingChannels #2980
fl::ChannelEngineRMTImpl::processPendingChannels()(1,078 B) — reduce dispatch-loop landing pad count
Expected combined savings
If the cross-cutting fixes (A + B + C) land and at least 4 of the per-function fixes ship, we should recover ~6-8 KB of flash on ESP32-S3 Blink — roughly 2% of total flash, but more importantly it removes the pattern that makes every FastLED function pay the logging tax twice (call site + cleanup metadata).
Investigation tooling
- Bloat report:
.build/symbols/esp32s3-fbuild/report.md(3,428 symbols) - Back-reference graphviz sidecars:
.build/symbols/esp32s3-fbuild/graphs/0001..0269.dot - Per-symbol analysis script:
ci/tmp/fl_bloat_investigation.py - Per-function detail:
.build/fl_bloat_investigation.md
Refs
- fl::sstream cost-reduction audit: flip the default so FL_WARN/FL_ERROR are compiled by default #2963 (gamma/sstream audit + Option 3 log_emit context)
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 (the original ESP32-S3 NEOPIXEL bloat audit)
- perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890 (FASTLED_LOG_VERBOSITY release-mode gating — already merged, this issue is the next step)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
zackees commentedon Aug 20, 2026
Triaged against current master 31167ea.
Marking deferred: several children landed, but this meta is not resolved and its remaining work combines architecture with missing logging-enabled measurements.
Current evidence:
Restart when a reproducible logging-enabled bloat report exists. Then resolve/supersede #2982 with representative call-site/disassembly/output-equivalence evidence, handle #2981 as a benchmarked architecture PR, and close this meta only after the refreshed combined target is met.