Repository navigation
Description
Goal
Gate the bus-miss diagnostic probe in `fl::Channel::resolveDynamicDriver` (`src/fl/channels/channel.cpp.hpp:414-438`) on `FASTLED_LOG_RUNTIME_ENABLED` so the diagnostic-only `findDriverByName(busKey)` probe + string-comparison + empty FL_ERROR setup dead-strip from release builds.
Parent: #2886 — tactical bloat win, same dead-strip cascade pattern as #2918 / #2925 / #2943.
Why this is a real win
`resolveDynamicDriver()` runs on every frame for channels that don't pre-bind a driver. The post-lookup diagnostic block at `channel.cpp.hpp:414-438`:
```cpp
if (mBus != Bus::AUTO && !mBusWarned &&
(!driver || driver->getName() != busKey)) {
auto busDriver = ChannelManager::instance().findDriverByName(busKey);
if (!busDriver) {
FL_ERROR("Channel '" << mName << "': Driver '" << busKey
<< "' wasn't instantiated. Resolve with: ...");
} else {
FL_ERROR("Channel '" << mName << "': Driver '" << busKey
<< "' is registered but cannot handle this channel's chipset ...");
}
mBusWarned = true;
}
if (!driver) {
FL_ERROR("Channel '" << mName << "': No compatible driver found - cannot transmit");
}
```
In release builds (NDEBUG → `FASTLED_LOG_VERBOSITY=0` per #2890) every `FL_ERROR` body collapses to `do {} while(0)`, but the surrounding code still runs:
- `driver->getName()` virtual call + `fl::string != fl::string` comparison (the per-frame branch test that selects "silent miss vs.diagnosed miss").
- `ChannelManager::instance().findDriverByName(busKey)` — a silent-on-miss probe that exists ONLY to differentiate between "driver not instantiated" and "driver rejected canHandle()" in the diagnostic message.
- `mBusWarned` reads/writes.
- The empty `if (!driver) {}` test at the end.
None of those operations affect runtime behavior in release — they only feed the diagnostic message that no longer renders.
Deliverable
`src/fl/channels/channel.cpp.hpp:414-438` — gate the diagnostic block
```cpp
fl::shared_ptr driver =
ChannelManager::instance().selectDriverForChannel(mChannelData, busKey);
mDriver = driver;
#if FASTLED_LOG_RUNTIME_ENABLED
if (mBus != Bus::AUTO && !mBusWarned &&
(!driver || driver->getName() != busKey)) {
auto busDriver = ChannelManager::instance().findDriverByName(busKey);
if (!busDriver) {
FL_ERROR("Channel '" << mName << "': Driver '" << busKey
<< "' wasn't instantiated. Resolve with: "
<< "(1) fl::enableDrivers<fl::Bus::" << busKey << ">() "
<< "(links only this driver), "
<< "(2) FastLED.enableAllDrivers() (links every driver), or "
<< "(3) FastLED.addLeds<..., fl::Bus::" << busKey << ">(...) "
<< "(legacy API; pins Bus + triggers linker keep-alive). "
<< "Defaulting to AUTO/priority dispatch.");
} else {
FL_ERROR("Channel '" << mName << "': Driver '" << busKey
<< "' is registered but cannot handle this channel's chipset "
<< "(bus/chipset mismatch). Defaulting to AUTO/priority dispatch.");
}
mBusWarned = true;
}
if (!driver) {
FL_ERROR("Channel '" << mName << "': No compatible driver found - cannot transmit");
}
#endif
return driver;
```
Behavior matrix
| Build | Bus | Driver registered? | Behaviour |
|---|---|---|---|
| Debug | typed | no | One-shot FL_ERROR with remediation hint |
| Debug | typed | yes (canHandle=no) | One-shot FL_ERROR with bus/chipset mismatch hint |
| Debug | AUTO | n/a | Silent (no diagnostic ever) |
| Release | typed | no | Silently falls through to nullptr; caller's `if (!driver) return;` skips the frame. |
| Release | typed | yes (canHandle=no) | Same as above. |
| Release | AUTO | n/a | Same as debug. |
The functional return value (`fl::shared_ptr driver`) is preserved unconditionally in both builds. Only the diagnostic side-effect is gated.
Acceptance
- `bash lint --cpp` passes.
- Behaviour preserved in debug builds.
- `bloat regression esp32s3` on the PR passes (any positive saving lowers `tests/data/esp32s3_bloat_baseline.txt` in a follow-up ratchet).
Expected savings
Projected ~150-600 B. The cascade could exceed projection if `findDriverByName`'s remaining callers (`ChannelManager::getDriverByName`, `ChannelManager::selectDriverForChannel`) also get `-DFASTLED_DISABLE_DYNAMIC_DRIVER=1`'d in default release — but #2926's gate is opt-in not default, so the dead-strip cascade likely won't trigger here. Realistic savings: ~150-300 B from the empty FL_ERROR bodies + the per-frame branch test + `mBusWarned` machinery.
Out of scope
- Removing `mBusWarned` from the class. Cost is 1 byte and keeping the field makes the conditional code symmetrical.
- Gating `busKey = fl::string::from_literal(busName(mBus))` at line 401-403. `busKey` is still passed to `selectDriverForChannel` as a functional argument and can't be elided.
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 this gate piggybacks on).
- Gate Channel::resolveDynamicDriver behind FASTLED_DISABLE_DYNAMIC_DRIVER (~400-900 B) (#2886) #2926 — companion lever (`FASTLED_DISABLE_DYNAMIC_DRIVER=1` opt-in flag that gates the whole function).
- 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 — gating patterns for diagnostic-only paths.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(channel): gate bus-miss diagnostic probe in release builds (#2952)…
perf(rmt5): gate handleAllocateTxFailure diagnostic block (#2956) (#2957