Repository navigation
Description
Goal
Gate the diagnostic-only local-variable initializations + suggestion-block FL_WARN chains in `RmtMemoryManager::handleAllocateTxFailure` on `FASTLED_LOG_RUNTIME_ENABLED`. The FL_WARN bodies already collapse to `do {} while(0)` in release builds per Stage 1 (#2890), but the locals they feed (`total`, `allocated`, `reserved`, `available`) still get initialized — including a `getAvailableWords(true)` call.
Parent: #2886 — pattern consistency with #2918 / #2925 / #2929 / #2943 / #2950 / #2952.
Why this is a real win
`src/fl/channels/.../rmt_memory_manager.cpp.hpp:450-474`:
```cpp
// Fallback failed or not attempted - provide detailed diagnostic message
size_t total = mLedger.is_global_pool ? mLedger.total_words : mLedger.total_tx_words;
size_t allocated = mLedger.is_global_pool ? mLedger.allocated_words : mLedger.allocated_tx_words;
size_t reserved = mLedger.reserved_tx_words;
size_t available = getAvailableWords(true);
FL_WARN("RMT TX allocation failed for channel " << static_cast(channel_id));
FL_WARN(" Requested: " << words_needed << " words (...)");
FL_WARN(" Available: " << available << " words");
FL_WARN(" Memory breakdown: Total=" << total << ", Allocated=" << allocated
<< ", Reserved=" << reserved << " (external RMT usage)");
if (reserved > 0) {
FL_WARN(" Suggestion: " << reserved << " words reserved by external RMT usage ...");
FL_WARN(" Consider using DMA channels (use_dma=true) to bypass on-chip memory");
}
if (allocated > 0) {
FL_WARN(" Suggestion: " << allocated << " words already allocated to other channels");
FL_WARN(" Consider reducing LED count or using fewer channels");
}
if (mem_blocks > 2 && networkActive) {
FL_WARN(" Suggestion: Network mode uses 3× buffering ...");
FL_WARN(" Consider disabling network or using DMA channels");
}
```
In release builds: all FL_WARN bodies collapse, but `getAvailableWords(true)` still runs, the 3 `mLedger.*` reads still run, and the 3 conditional suggestion blocks still execute their (no-op) FL_WARN setup. Gating the whole block saves:
- 1 `getAvailableWords(bool)` call
- 3 `mLedger` field reads with ternary expressions
- 3 conditional-branch tests (`if (reserved > 0)`, `if (allocated > 0)`, `if (mem_blocks > 2 && networkActive)`)
- 9 empty FL_WARN body setups
`handleAllocateTxFailure` is the #16 symbol at 1,972 B in the audit. The body is mostly diagnostic-only; gating may cascade.
Deliverable
`src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp` — gate the diagnostic block
```cpp
// Fallback failed or not attempted - provide detailed diagnostic message
#if FASTLED_LOG_RUNTIME_ENABLED
size_t total = mLedger.is_global_pool ? mLedger.total_words : mLedger.total_tx_words;
size_t allocated = mLedger.is_global_pool ? mLedger.allocated_words : mLedger.allocated_tx_words;
size_t reserved = mLedger.reserved_tx_words;
size_t available = getAvailableWords(true);
FL_WARN("RMT TX allocation failed for channel " << static_cast<int>(channel_id));
FL_WARN(" Requested: " << words_needed << " words (" << mem_blocks << "× buffer"
<< (networkActive ? ", Network mode" : "") << ")");
FL_WARN(" Available: " << available << " words");
FL_WARN(" Memory breakdown: Total=" << total << ", Allocated=" << allocated
<< ", Reserved=" << reserved << " (external RMT usage)");
if (reserved > 0) {
FL_WARN(" Suggestion: " << reserved << " words reserved by external RMT usage (e.g., USB CDC)");
FL_WARN(" Consider using DMA channels (use_dma=true) to bypass on-chip memory");
}
if (allocated > 0) {
FL_WARN(" Suggestion: " << allocated << " words already allocated to other channels");
FL_WARN(" Consider reducing LED count or using fewer channels");
}
if (mem_blocks > 2 && networkActive) {
FL_WARN(" Suggestion: Network mode uses 3× buffering (" << (mem_blocks * SOC_RMT_MEM_WORDS_PER_CHANNEL)
<< " words per channel)");
FL_WARN(" Consider disabling network or using DMA channels");
}
#endif
```
The function's actual return value below the gated block (`return result<size_t, RmtMemoryError>::failure(...)`) is preserved unconditionally.
Behavior matrix
| Build | Outcome |
|---|---|
| Debug (`FASTLED_LOG_VERBOSITY=1`) | Full diagnostic + suggestion block emitted |
| Release (`FASTLED_LOG_VERBOSITY=0`) | Silent failure return; user accepted that constraint by disabling diagnostics |
Acceptance
- `bash lint --cpp` passes.
- Behaviour preserved in debug builds.
- Bloat regression gate passes (any positive saving lowers `tests/data/esp32s3_bloat_baseline.txt` in a follow-up ratchet).
Expected savings
Projected ~50-300 B. `getAvailableWords` has 7 other callers, so cascade won't fire on it. The savings are from removing the local-variable initializations + the 3 conditional branch tests + the 9 empty FL_WARN setups. Realistic estimate: small but non-zero.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + audit cycle.
- perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890 — Stage 1 (the `FASTLED_LOG_VERBOSITY=0` default).
- Cut ClocklessIdf5 bloat by gating cold-path emit helpers' sstream chains (~800 B) (#2886) #2917 — companion gate on `emitRecoveryWarning` + `emitAllocationFailureError` (already shipped, sibling cold-helper functions).
- 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 / perf(gamma): simplify Gamma8::getOrCreate to single-entry weak_ptr cache #2929 / perf(channel): skip auto-naming in release builds (#2942) #2943 / Gate emitDisabledDriverError diagnostic chain in release builds (~300-800 B) #2950 / Gate resolveDynamicDriver bus-miss diagnostic probe in release builds #2952 — gating patterns for diagnostic-only paths.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(rmt5): gate handleAllocateTxFailure diagnostic block (FastLED#2956…