Repository navigation
perf(channels): gate addDriver capStr builder behind FASTLED_HAS_DBG (#2773 iter 6) - #2833
Conversation
…2773 iter 6) The capability-string builder in `ChannelManager::addDriver` exists only to feed the trailing `FL_DBG("...caps: " << capStr.c_str() ...)` line. On `FASTLED_HAS_DBG=0` builds (default `SKETCH_HAS_LARGE_MEMORY=0` path AND any `-DFASTLED_LOG_VERBOSITY=0` opt-in) the `FL_DBG` already expands to `do { if (false) {...} } while (0)`, but the `fl::string capStr` allocation, two `if` branches, and an `if (empty) capStr = "NONE"` fallback above it still emitted code — the optimizer wasn't reliably DCE'ing them through the `if (false)` form. Wrapping the whole block in `#if FASTLED_HAS_DBG` makes the elision explicit so the linker drops it without depending on DCE behavior. ## Measured on ESP32-S3 Blink (PlatformIO + IDF 5.4) | Build | `firmware.bin` | Δ | |---|---:|---:| | master (default verbosity) | 661,408 B | — | | this PR (default verbosity) | 661,408 B | **0** | | master + `-DFASTLED_LOG_VERBOSITY=0` | 616,848 B | — | | this PR + `-DFASTLED_LOG_VERBOSITY=0` | 616,384 B | **−464 B** | Zero risk at default (the gate is true when `FASTLED_HAS_DBG=1`, so the inside-the-#if code is identical to today). The −464 B on the opt-in slim build is real because the `fl::string` ops above the FL_DBG were being kept by the compiler even though FL_DBG itself was a no-op. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
Need the big picture first? Review this PR in Change Stack to see what changed before going file by file. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds preprocessor guards around debug-only capability-string construction in ChangesDebug logging guard
Possibly related PRs
Poem
🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The capability-string builder in
ChannelManager::addDriverexists only to feed the trailingFL_DBG(\"...caps: \" << capStr.c_str() ...)line. OnFASTLED_HAS_DBG=0builds (defaultSKETCH_HAS_LARGE_MEMORY=0path AND any-DFASTLED_LOG_VERBOSITY=0opt-in build),FL_DBGitself already expands todo { if (false) {...} } while (0), but thefl::string capStrallocation, twoifbranches, and theif (capStr.empty()) capStr = \"NONE\"fallback above it still emitted code — the optimizer wasn't reliably DCE'ing them through theif (false)form.Wrapping the whole block in
#if FASTLED_HAS_DBGmakes the elision explicit so the linker drops it without depending on DCE behavior. Same approach attempted on a previously-closed parallel PR (#2832); reopening it standalone with a fresh measurement against current master.Measured on ESP32-S3 Blink (PlatformIO + IDF 5.4)
firmware.bin-DFASTLED_LOG_VERBOSITY=0-DFASTLED_LOG_VERBOSITY=0Zero risk at default (the gate is true when
FASTLED_HAS_DBG=1, so the inside-the-#if code is identical to today). The −464 B on the opt-in slim build is real because thefl::stringops above the FL_DBG were being kept by the compiler even though FL_DBG itself was a no-op.Refs: #2773
🤖 Generated with Claude Code
Summary by CodeRabbit