Repository navigation
perf(channel): skip auto-naming in release builds (#2942) - #2943
Conversation
`Channel::makeName(id)` synthesizes `"Channel_<id>"` when no explicit
config name is provided. The resulting name is only consumed by
`FL_WARN` / `FL_ERROR` sites that collapse to `do { } while(0)` when
`FASTLED_LOG_VERBOSITY=0` (the NDEBUG default since #2890), so the
string + `fl::to_string<i64>` instantiation + heap concat run for
nothing in release.
Gate the auto-naming branch on `FASTLED_LOG_RUNTIME_ENABLED`:
- Debug: `"Channel_<id>"` (unchanged).
- Release with no explicit name: empty string.
- Release with explicit name: explicit name (unchanged).
Empty mName in release is fine because the only read sites are
diagnostic. Public API (`Channel::getName()`) preserved.
Refs #2886.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthrough
ChangesChannel diagnostic naming optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/fl/channels/channel.cpp.hpp (1)
160-165: 💤 Low valueComment should reflect the full FASTLED_LOG_RUNTIME_ENABLED contract.
The comment mentions "NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1" but doesn't mention that
FASTLED_LOG_RUNTIME_ENABLEDalso requiresSKETCH_HAS_LARGE_MEMORYto be true. The upstream contract (log.h:96-105) shows logging is disabled if EITHER condition is false:(SKETCH_HAS_LARGE_MEMORY && FASTLED_LOG_VERBOSITY >= 1).Consider updating the comment to reflect both gates for clarity.
📝 Suggested comment revision
- // Auto-naming `"Channel_<id>"` only matters for diagnostics — in release - // builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) every FL_WARN / - // FL_ERROR site that reads mName collapses to `do { } while(0)`, so the - // string and the supporting `fl::to_string` + `operator+` chain go - // unused. Empty in release saves the `fl::to_string<i64>` instantiation - // plus the heap allocation per Channel ctor. See `#2942` / `#2886`. + // Auto-naming `"Channel_<id>"` only matters for diagnostics — when + // FASTLED_LOG_RUNTIME_ENABLED is false (small-memory platforms OR + // FASTLED_LOG_VERBOSITY=0 in release builds per `#2890`), every FL_WARN / + // FL_ERROR site that reads mName collapses to `do { } while(0)`, so the + // string and supporting `fl::to_string` + `operator+` chain go unused. + // Empty in release saves the `fl::to_string<i64>` instantiation plus + // heap allocation per Channel ctor. See `#2942` / `#2886`.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/fl/channels/channel.cpp.hpp` around lines 160 - 165, The current comment around Channel auto-naming incorrectly implies the only gate is NDEBUG→FASTLED_LOG_VERBOSITY=0; update it to state the full FASTLED_LOG_RUNTIME_ENABLED contract: logging is enabled only when (SKETCH_HAS_LARGE_MEMORY && FASTLED_LOG_VERBOSITY >= 1), so the empty mName optimization in the Channel ctor is valid when either SKETCH_HAS_LARGE_MEMORY is false or FASTLED_LOG_VERBOSITY < 1 (or NDEBUG sets verbosity to 0). Mention the symbols FASTLED_LOG_RUNTIME_ENABLED, SKETCH_HAS_LARGE_MEMORY, FASTLED_LOG_VERBOSITY, and Channel/mName so readers can locate the related logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Around line 166-171: Update the docs to note that Channel::makeName() returns
an empty string when FASTLED_LOG_RUNTIME_ENABLED is disabled, and change the
event-listener example in src/fl/channels/README.md to either check
ch.name().empty() before printing or show using ChannelConfig::mName to set a
stable name; specifically mention Channel::makeName(), ch.name(), and
ChannelConfig::mName so readers know to provide mName when stable names are
required in release builds without logging enabled.
---
Nitpick comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Around line 160-165: The current comment around Channel auto-naming
incorrectly implies the only gate is NDEBUG→FASTLED_LOG_VERBOSITY=0; update it
to state the full FASTLED_LOG_RUNTIME_ENABLED contract: logging is enabled only
when (SKETCH_HAS_LARGE_MEMORY && FASTLED_LOG_VERBOSITY >= 1), so the empty mName
optimization in the Channel ctor is valid when either SKETCH_HAS_LARGE_MEMORY is
false or FASTLED_LOG_VERBOSITY < 1 (or NDEBUG sets verbosity to 0). Mention the
symbols FASTLED_LOG_RUNTIME_ENABLED, SKETCH_HAS_LARGE_MEMORY,
FASTLED_LOG_VERBOSITY, and Channel/mName so readers can locate the related
logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: eb078529-abde-4206-9c20-4821574cc735
📒 Files selected for processing (1)
src/fl/channels/channel.cpp.hpp
| #if FASTLED_LOG_RUNTIME_ENABLED | ||
| return "Channel_" + fl::to_string(static_cast<i64>(id)); | ||
| #else | ||
| (void)id; | ||
| return {}; | ||
| #endif |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if documentation mentions the release-build empty-name behavior
# Search for documentation mentioning channel names, event listeners, or release behavior
rg -i -C5 'channelcreated|channelenqueued|ch\.name\(\)|release.*name|auto.*nam' \
--glob '*.md' --glob '!**/node_modules/**'
# Also check for any warnings about FASTLED_LOG_RUNTIME_ENABLED affecting names
rg -i 'FASTLED_LOG_RUNTIME_ENABLED' --glob '*.md'Repository: FastLED/FastLED
Length of output: 16458
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Inspect the exact code around the reported snippet
echo "=== channel.cpp.hpp around lines 150-190 ==="
nl -ba src/fl/channels/channel.cpp.hpp | sed -n '140,200p'
# 2) Check whether docs mention FASTLED_LOG_RUNTIME_ENABLED or the empty-name behavior
echo
echo "=== Search docs for FASTLED_LOG_RUNTIME_ENABLED mentions ==="
rg -n 'FASTLED_LOG_RUNTIME_ENABLED' --glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Search docs for channel name / empty name / auto-name release behavior ==="
rg -n -i 'channel.*(name|named)|ch\.name\(\)|empty.*name|auto.*name|runtime.*name|log_runtime_enabled' \
--glob '*.md' --glob '!**/node_modules/**'
echo
echo "=== Search for release notes mentioning name behavior ==="
rg -n -i 'release_notes.*(name|named)|.*(name|named).*release' release_notes.md --glob '*.md' || trueRepository: FastLED/FastLED
Length of output: 165
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== channel.cpp.hpp around lines 150-190 (line-numbered via awk) ==="
awk 'NR>=150 && NR<=190 {printf "%d:%s\n", NR, $0}' src/fl/channels/channel.cpp.hpp
echo
echo "=== Docs: FASTLED_LOG_RUNTIME_ENABLED mentions ==="
rg -n 'FASTLED_LOG_RUNTIME_ENABLED' --glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: channel name / ch.name() / empty/auto naming mentions ==="
rg -n -i 'channel.*(name|named)|ch\.name\(\)|empty.*name|auto.*name|runtime.*name|log_runtime_enabled' \
--glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: migration/release notes about channel name behavior ==="
rg -n -i '(migration|migrat|release|breaking).*?(name|named|channel)' --glob '*.md' --glob '!**/node_modules/**' || trueRepository: FastLED/FastLED
Length of output: 11517
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== channel.cpp.hpp around lines 150-190 (line-numbered via awk) ==="
awk 'NR>=150 && NR<=190 {printf "%d:%s\n", NR, $0}' src/fl/channels/channel.cpp.hpp
echo
echo "=== Docs: FASTLED_LOG_RUNTIME_ENABLED mentions ==="
rg -n 'FASTLED_LOG_RUNTIME_ENABLED' --glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: channel name / ch.name() / empty/auto naming mentions ==="
rg -n -i 'channel.*(name|named)|ch\.name\(\)|empty.*name|auto.*name|runtime.*name|log_runtime_enabled' \
--glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: migration/release notes about channel name behavior ==="
rg -n -i '(migration|migrat|release|breaking).*?(name|named|channel)' --glob '*.md' --glob '!**/node_modules/**' || trueRepository: FastLED/FastLED
Length of output: 11517
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== channel.cpp.hpp around lines 150-190 (line-numbered via awk) ==="
awk 'NR>=150 && NR<=190 {printf "%d:%s\n", NR, $0}' src/fl/channels/channel.cpp.hpp
echo
echo "=== Docs: FASTLED_LOG_RUNTIME_ENABLED mentions ==="
rg -n 'FASTLED_LOG_RUNTIME_ENABLED' --glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: channel name / ch.name() / empty/auto naming mentions ==="
rg -n -i 'channel.*(name|named)|ch\.name\(\)|empty.*name|auto.*name|runtime.*name|log_runtime_enabled' \
--glob '*.md' --glob '!**/node_modules/**' || true
echo
echo "=== Docs: migration/release notes about channel name behavior ==="
rg -n -i '(migration|migrat|release|breaking).*?(name|named|channel)' --glob '*.md' --glob '!**/node_modules/**' || trueRepository: FastLED/FastLED
Length of output: 11517
Document empty ch.name() in release builds when FASTLED_LOG_RUNTIME_ENABLED is off.
Channel::makeName() returns {} in that build mode (so auto-named channels don’t provide "Channel_<id>"), but src/fl/channels/README.md’s event-listener example prints ch.name().c_str() without warning it may be empty; update the docs and recommend setting ChannelConfig::mName when stable names are needed.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/fl/channels/channel.cpp.hpp` around lines 166 - 171, Update the docs to
note that Channel::makeName() returns an empty string when
FASTLED_LOG_RUNTIME_ENABLED is disabled, and change the event-listener example
in src/fl/channels/README.md to either check ch.name().empty() before printing
or show using ChannelConfig::mName to set a stable name; specifically mention
Channel::makeName(), ch.name(), and ChannelConfig::mName so readers know to
provide mName when stable names are required in release builds without logging
enabled.
…2949) The Stage-6 regression gate (now operational after the #2945 + #2947 infra fixes) measured total_flash=338,117 B on master @ 56af093 with 1,845 B of headroom against the previous pin. The drop is the cascade saving from #2943 (Channel::makeName release-gate) pulling out fl::to_string<i64> and fl::string::operator+ machinery. Lock in the saving so future regressions up to 1,845 B can't slip past the gate. Closes #2948. Refs #2886. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…2951) The #2517 "silent-drop" diagnostic in `Channel::showPixels` exists to help users debug `FastLED.setExclusiveDriver<>` flows where a bound driver is currently disabled and the frame would be silently dropped. In release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per #2890) every FL_ERROR site inside `emitDisabledDriverError` collapses to `do { } while(0)`, leaving an empty function body — but the call site is still live, so the linker keeps: - the empty `emitDisabledDriverError` body (3 fl::string&-args), - the `ChannelManager::instance().exclusiveDriverName()` getter (only reachable from this site), - the 3-argument fl::string pass-by-const-ref chain at the call site, - the `mDisabledDriverWarned` reads/writes. Gate the diagnostic emission and the one-shot latch maintenance on `FASTLED_LOG_RUNTIME_ENABLED`. The unconditional `return` on STATUS_DISABLED is preserved — release still drops the frame, just silently (the user accepted that constraint by disabling logs). Same dead-strip cascade pattern as #2918 / #2925 / #2943. Refs #2886. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
… (#2953) resolveDynamicDriver runs per-frame for non-pre-bound channels. The diagnostic block at channel.cpp.hpp:414-438 includes: - the per-frame `driver->getName() != busKey` virtual-call + fl::string compare (deciding silent-miss vs. diagnosed-miss), - the silent `ChannelManager::findDriverByName(busKey)` probe (used only to differentiate the FL_ERROR message), - mBusWarned reads/writes, - the empty `if (!driver) {}` branch with the no-compatible-driver FL_ERROR. In release builds the FL_ERROR bodies collapse to do-while-0, but the surrounding code still runs — burning cycles + flash bytes for an unrendered diagnostic. Gate the whole block on FASTLED_LOG_RUNTIME_ENABLED. The functional `return driver` is preserved unconditionally; only the diagnostic side-effect is gated. Same dead-strip cascade pattern as #2918 / #2925 / #2929 / #2943 / #2950. Closes #2952. Refs #2886. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Companion fix to #2943: mirrors the Channel::makeName release-gate on RxChannel::makeName. The auto-naming branch synthesizes `"RxChannel_<id>"` only for diagnostic consumption; in release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per #2890) every read site collapses to do-while-0, so the string + `fl::to_string<i64>` + heap concat run for nothing. User-provided names (config.name non-empty) are unchanged in both debug and release. Closes #2954. Refs #2886. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Channel::makeName's"Channel_<id>"auto-naming branch onFASTLED_LOG_RUNTIME_ENABLED.FASTLED_LOG_VERBOSITY=0per perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890), every FL_WARN/FL_ERROR site that readsmNamecollapses todo { } while(0), so the synthesized name +fl::to_string<i64>instantiation + heap concat run for nothing.ChannelConfig::mName.has_value()) are unaffected in both debug and release.Behavior matrix
"Channel_<id>"""(empty)Test plan
bash lint --cpppassestests/measure_esp32s3_opt_ins.py --config baselinerecords new total; if positive, ratchettests/data/esp32s3_bloat_baseline.txtCloses #2942. Refs #2886.
🤖 Generated with Claude Code
Summary by CodeRabbit