Skip to content

Gate emitDisabledDriverError diagnostic chain in release builds (~300-800 B) #2950

Closed

Description

@zackees

Goal

Gate the "silent-drop" diagnostic in `fl::Channel::showPixels` on `FASTLED_LOG_RUNTIME_ENABLED` so the helper, the `exclusiveDriverName()` call, and the supporting string temporaries 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

`src/fl/channels/channel.cpp.hpp:634-650` runs every frame:

```cpp
fl::string driverName = driver->getName();
auto status = ChannelManager::instance().driverStatus(driverName);
if (status == ChannelManager::DriverStatus::STATUS_DISABLED) {
if (!mDisabledDriverWarned) {
emitDisabledDriverError(
mName, driverName,
ChannelManager::instance().exclusiveDriverName());
mDisabledDriverWarned = true;
}
return;
} else if (status == ChannelManager::DriverStatus::STATUS_ENABLED) {
mDisabledDriverWarned = false;
}
```

`emitDisabledDriverError` (`channel.cpp.hpp:130-146`) is a `FL_NO_INLINE` cold helper whose entire body is two `FL_ERROR(...)` sites — a 5-line `fl::sstream` chain and a 4-line one. In release builds (NDEBUG → `FASTLED_LOG_VERBOSITY=0` per #2890) both `FL_ERROR` calls collapse to `do { } while(0)`, leaving an empty function — but the linker can't dead-strip it because the call site at `channel.cpp.hpp:638` is still live.

The call-site overhead in release builds today:

  • The empty `emitDisabledDriverError` body (a 3-string-arg function, returned by ABI).
  • The `ChannelManager::instance().exclusiveDriverName()` call — only reachable from this site, so dead-strip cascades into the `exclusiveDriverName` getter + the string return + the `mExclusiveDriverName` field reads.
  • A 3-argument `fl::string` pass-by-const-ref chain.
  • The `mDisabledDriverWarned` reads/writes (single bool but still emits SDB code).

Deliverable

`src/fl/channels/channel.cpp.hpp` — gate the diagnostic call site

```cpp
if (status == ChannelManager::DriverStatus::STATUS_DISABLED) {
#if FASTLED_LOG_RUNTIME_ENABLED
if (!mDisabledDriverWarned) {
emitDisabledDriverError(
mName, driverName,
ChannelManager::instance().exclusiveDriverName());
mDisabledDriverWarned = true;
}
#endif
return;
} else if (status == ChannelManager::DriverStatus::STATUS_ENABLED) {
#if FASTLED_LOG_RUNTIME_ENABLED
mDisabledDriverWarned = false;
#endif
}
```

The `return` on STATUS_DISABLED is preserved unconditionally — release builds still skip the enqueue for disabled drivers (matches current behaviour). Only the diagnostic emission and the one-shot latch maintenance get gated.

Behavior matrix

Build status Behaviour
Debug (`FASTLED_LOG_VERBOSITY=1`) DISABLED One-shot `FL_ERROR` emitted; frame dropped.
Debug ENABLED Latch reset; frame enqueued normally.
Release (`FASTLED_LOG_VERBOSITY=0`) DISABLED Frame dropped silently — user accepts the loss when they disable diagnostics.
Release ENABLED Frame enqueued normally.

Existing public API unchanged. `driverStatus` check remains live in both builds because the STATUS_DISABLED → `return` matters for correctness.

Acceptance

  1. `bash lint --cpp` passes.
  2. Behaviour preserved in debug builds.
  3. `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 ~300-800 B. The dead-strip cascade pattern from #2918 (−2,235 B vs projected 800), #2925 (−3,937 B vs projected 1-2 KB), #2943 (−1,845 B vs projected 100-300 B) suggests this may exceed projection if `exclusiveDriverName()` was reachable only from this site.

Out of scope

  • Removing `mDisabledDriverWarned` entirely from the class. Cost is 1 byte (fits in existing padding) and keeping the field makes the conditional code symmetrical between debug/release.
  • Gating the `fl::string driverName = driver->getName()` call at line 634 — `driverName` is also used by `driverStatus()` immediately below and (debug-only) by the FL_ERROR call.

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions