Skip to content

perf(channel): skip auto-naming in release builds (#2942) - #2943

Merged
zackees merged 1 commit into
masterfrom
feat/2942-gate-channel-makename
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2942-gate-channel-makename

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Gates Channel::makeName's "Channel_<id>" auto-naming branch on FASTLED_LOG_RUNTIME_ENABLED.
  • In release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890), every FL_WARN/FL_ERROR site that reads mName collapses to do { } while(0), so the synthesized name + fl::to_string<i64> instantiation + heap concat run for nothing.
  • Explicit user-supplied names (ChannelConfig::mName.has_value()) are unaffected in both debug and release.

Behavior matrix

Build configName set? mName value
Debug yes configName.value()
Debug no "Channel_<id>"
Release yes configName.value()
Release no "" (empty)

Test plan

  • bash lint --cpp passes
  • Post-merge tests/measure_esp32s3_opt_ins.py --config baseline records new total; if positive, ratchet tests/data/esp32s3_bloat_baseline.txt

Closes #2942. Refs #2886.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Modified diagnostic name generation to conditionally process string operations based on runtime logging configuration.

`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]>
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Channel::makeName is conditionally gated on FASTLED_LOG_RUNTIME_ENABLED to skip the "Channel_<id>" string construction work in release builds where the resulting name is consumed only by no-op'd diagnostic macros.

Changes

Channel diagnostic naming optimization

Layer / File(s) Summary
Channel::makeName conditional compilation
src/fl/channels/channel.cpp.hpp
Channel::makeName returns "Channel_<id>" only when FASTLED_LOG_RUNTIME_ENABLED is true; in release builds it returns an empty string, avoiding fl::to_string instantiation and string concatenation overhead. Explicit user-provided names remain unaffected.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • FastLED/FastLED#2914: Modifies the same file with similar conditional compilation patterns based on preprocessor logging configuration.

Poem

🐰 A channel's name, once always made,

Now hides when logging lights do fade,

In builds where silence reigns supreme,

We skip the string—a rabbit's dream! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main optimization: conditional auto-naming in release builds to skip unnecessary work when logging is disabled.
Linked Issues check ✅ Passed The changes fully satisfy #2942 requirements: makeName is gated on FASTLED_LOG_RUNTIME_ENABLED, returning empty string in release builds while preserving user-provided names.
Out of Scope Changes check ✅ Passed All changes directly address the single objective of gating Channel::makeName performance work; no unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2942-gate-channel-makename

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/fl/channels/channel.cpp.hpp (1)

160-165: 💤 Low value

Comment 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_ENABLED also requires SKETCH_HAS_LARGE_MEMORY to 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

📥 Commits

Reviewing files that changed from the base of the PR and between e518aeb and 4560b03.

📒 Files selected for processing (1)
  • src/fl/channels/channel.cpp.hpp

Comment on lines +166 to +171
#if FASTLED_LOG_RUNTIME_ENABLED
return "Channel_" + fl::to_string(static_cast<i64>(id));
#else
(void)id;
return {};
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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' || true

Repository: 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/**' || true

Repository: 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/**' || true

Repository: 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/**' || true

Repository: 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.

@zackees
zackees merged commit 1f00054 into master Jun 7, 2026
8 of 13 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
zackees added a commit that referenced this pull request Jun 7, 2026
…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]>
zackees added a commit that referenced this pull request Jun 7, 2026
…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]>
zackees added a commit that referenced this pull request Jun 7, 2026
… (#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]>
zackees added a commit that referenced this pull request Jun 7, 2026
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]>
@zackees
zackees deleted the feat/2942-gate-channel-makename branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Skip Channel auto-naming in release builds (~100-300 B) (#2886)

1 participant