Skip to content

perf(rmt5): gate handleAllocateTxFailure diagnostic block (#2956) - #2957

Merged
zackees merged 1 commit into
masterfrom
feat/2956-gate-tx-failure-diag
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2956-gate-tx-failure-diag

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Gates the 9-line FL_WARN diagnostic + suggestion block in `handleAllocateTxFailure` on `FASTLED_LOG_RUNTIME_ENABLED`.
  • In release the 4 local-variable initializations (including a `getAvailableWords()` call + 3 `mLedger` reads) + 3 conditional suggestion branches dead-strip alongside the empty FL_WARN bodies.
  • Function's return value preserved unconditionally; only the diagnostic side-effect is gated.

Test plan

  • `bash lint --cpp` passes.
  • Bloat regression gate passes with positive saving (projected ~50-300 B).

Closes #2956. Refs #2886.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Optimized diagnostic logging behavior for production builds to reduce overhead while maintaining functionality.

The 9-line FL_WARN diagnostic+suggestion block at the end of
RmtMemoryManager::handleAllocateTxFailure feeds 4 local variables —
including a getAvailableWords() call + 3 mLedger reads — and runs
3 conditional suggestion branches.

In release builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per #2890)
all 9 FL_WARN bodies collapse to do-while-0, but the locals + the
3 condition tests still execute. Gate the whole block on
FASTLED_LOG_RUNTIME_ENABLED so the unrendered diagnostic doesn't
cost flash bytes.

The return-failure at the end of the function is preserved
unconditionally.

Same pattern as #2917 (sibling cold-helpers emitRecoveryWarning /
emitAllocationFailureError) and #2950 / #2952.

Closes #2956. 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

The PR adds compile-time conditional gating to the diagnostic block in RmtMemoryManager::handleAllocateTxFailure, wrapping the detailed warning messages and suggestion logic behind #if FASTLED_LOG_RUNTIME_ENABLED. This eliminates unnecessary variable initialization and conditional evaluation in release builds while preserving debug diagnostics.

Changes

Diagnostic logging gate in handleAllocateTxFailure

Layer / File(s) Summary
Gate diagnostic block on FASTLED_LOG_RUNTIME_ENABLED
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
The diagnostic-only block (local variables, FL_WARN messages, and conditional suggestion paths) is wrapped with #if FASTLED_LOG_RUNTIME_ENABLED / #endif. The unconditional failure return below the block is preserved. Comment explains logging-stage behavior and that variables are still evaluated even when warning bodies collapse in release builds.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

  • #2956: Directly addresses the issue objective to gate handleAllocateTxFailure's diagnostic-only locals and suggestion blocks behind FASTLED_LOG_RUNTIME_ENABLED to reduce bloat in release builds.

Possibly related PRs

  • FastLED/FastLED#2918: Applies the same #if FASTLED_LOG_RUNTIME_ENABLED gating strategy to cold-path diagnostic functions emitRecoveryWarning and emitAllocationFailureError in the ESP32 RMT5 stack.
  • FastLED/FastLED#2840: Extracted the handleAllocateTxFailure method that now receives the preprocessor gating in this PR.

Poem

A rabbit hops through logs with care,
Gating warnings, trim and spare—
When release calls, less bloat to bear,
Debug still chirps its warnings fair,
Binary shrinks: a win to share! 🐰✨

🚥 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 change: gating a diagnostic block in handleAllocateTxFailure behind a compilation flag for performance optimization.
Linked Issues check ✅ Passed The PR fully implements the coding requirement from issue #2956: wrapping the diagnostic-only block in #if FASTLED_LOG_RUNTIME_ENABLED while preserving the unconditional failure return.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #2956: the single file modification gates only the diagnostic block as specified, with no unrelated alterations.

✏️ 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/2956-gate-tx-failure-diag

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 (2)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp (2)

481-481: 💤 Low value

Optional: Add trailing comment to #endif for readability.

The conditional block spans ~26 lines. Adding a trailing comment to the #endif (e.g., #endif // FASTLED_LOG_RUNTIME_ENABLED) would clarify what is being closed, especially if future edits insert additional preprocessor directives nearby.

♻️ Proposed improvement
-#endif
+#endif  // FASTLED_LOG_RUNTIME_ENABLED
🤖 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/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp` at line
481, Add a trailing comment to the closing preprocessor directive to clarify
what block is being ended: update the lone `#endif` at the end of the
conditional block guarding FASTLED logging to `#endif //
FASTLED_LOG_RUNTIME_ENABLED` (or similar) so readers can immediately see the
macro being closed; locate the `#endif` that pairs with the `#if`/`#ifdef` for
FASTLED_LOG_RUNTIME_ENABLED in rmt_memory_manager.cpp.hpp and append the
comment.

506-527: ⚖️ Poor tradeoff

Consider similar gating in allocateRx for consistency (future work).

The allocateRx method's diagnostic block (lines 506–527) follows the same pattern as the now-gated handleAllocateTxFailure block: it computes diagnostic-only locals (total, allocated, reserved, available) and emits conditional FL_WARN messages. Applying the same #if FASTLED_LOG_RUNTIME_ENABLED gate here would yield similar bloat savings in release builds and maintain consistency across allocation failure paths.

This is beyond the scope of the current PR (which targets only handleAllocateTxFailure per #2956), but may be worth tracking as follow-up work under the parent audit #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/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp` around
lines 506 - 527, The diagnostic-only locals and FL_WARN calls in allocateRx (the
block that computes total, allocated, reserved, available and emits multiple
FL_WARN messages about RMT RX allocation failure and suggestions) should be
wrapped in the same conditional compilation guard used elsewhere (`#if`
FASTLED_LOG_RUNTIME_ENABLED / `#endif`) so these temporary variables and logging
are omitted in non-logging builds; locate the allocateRx function and enclose
the computation of total/allocated/reserved/available and all FL_WARN
invocations in that preprocessor guard to match the gating applied in
handleAllocateTxFailure.
🤖 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/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp`:
- Around line 450-454: The comment incorrectly states "9 FL_WARN bodies" while
the gated block actually contains 10 FL_WARN invocations; update the comment to
"10 FL_WARN bodies" (or otherwise reflect the accurate count) and ensure the
explanatory text around FASTLED_LOG_RUNTIME_ENABLED, getAvailableWords(), and
the mLedger reads remains consistent with that corrected count so readers
understand why the locals still execute in the gated block.

---

Nitpick comments:
In `@src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp`:
- Line 481: Add a trailing comment to the closing preprocessor directive to
clarify what block is being ended: update the lone `#endif` at the end of the
conditional block guarding FASTLED logging to `#endif //
FASTLED_LOG_RUNTIME_ENABLED` (or similar) so readers can immediately see the
macro being closed; locate the `#endif` that pairs with the `#if`/`#ifdef` for
FASTLED_LOG_RUNTIME_ENABLED in rmt_memory_manager.cpp.hpp and append the
comment.
- Around line 506-527: The diagnostic-only locals and FL_WARN calls in
allocateRx (the block that computes total, allocated, reserved, available and
emits multiple FL_WARN messages about RMT RX allocation failure and suggestions)
should be wrapped in the same conditional compilation guard used elsewhere (`#if`
FASTLED_LOG_RUNTIME_ENABLED / `#endif`) so these temporary variables and logging
are omitted in non-logging builds; locate the allocateRx function and enclose
the computation of total/allocated/reserved/available and all FL_WARN
invocations in that preprocessor guard to match the gating applied in
handleAllocateTxFailure.
🪄 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: 2c830e76-0769-4641-a2f6-919de89040a7

📥 Commits

Reviewing files that changed from the base of the PR and between 69e71b7 and 100b4c7.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp

Comment on lines +450 to +454
// Fallback failed or not attempted - provide detailed diagnostic message.
// Gate the entire block on FASTLED_LOG_RUNTIME_ENABLED — in release
// builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the 9 FL_WARN
// bodies collapse to do-while-0, but the locals they feed (including
// the getAvailableWords() call + 3 mLedger reads) still run. See #2956.

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 | ⚡ Quick win

Count discrepancy in comment.

The comment claims "9 FL_WARN bodies" but the gated block contains 10 FL_WARN invocations (lines 461, 462, 464, 465, 469, 470, 473, 474, 477, 479). Update the comment to reflect the accurate count.

📝 Proposed fix
-    // builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the 9 FL_WARN
+    // builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the 10 FL_WARN
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Fallback failed or not attempted - provide detailed diagnostic message.
// Gate the entire block on FASTLED_LOG_RUNTIME_ENABLED — in release
// builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the 9 FL_WARN
// bodies collapse to do-while-0, but the locals they feed (including
// the getAvailableWords() call + 3 mLedger reads) still run. See #2956.
// Fallback failed or not attempted - provide detailed diagnostic message.
// Gate the entire block on FASTLED_LOG_RUNTIME_ENABLED — in release
// builds (NDEBUG → FASTLED_LOG_VERBOSITY=0 per Stage 1) the 10 FL_WARN
// bodies collapse to do-while-0, but the locals they feed (including
// the getAvailableWords() call + 3 mLedger reads) still run. See `#2956`.
🤖 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/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp` around
lines 450 - 454, The comment incorrectly states "9 FL_WARN bodies" while the
gated block actually contains 10 FL_WARN invocations; update the comment to "10
FL_WARN bodies" (or otherwise reflect the accurate count) and ensure the
explanatory text around FASTLED_LOG_RUNTIME_ENABLED, getAvailableWords(), and
the mLedger reads remains consistent with that corrected count so readers
understand why the locals still execute in the gated block.

@zackees
zackees merged commit 78fe4c8 into master Jun 7, 2026
8 of 9 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
…) (#2959)

The SLIM doc Row 1 reading was frozen at the Stage 1 landing
measurement (350,568 B on 824cb5c). Eight follow-on PRs since
then have stacked diagnostic-only cold-helper gates that cascaded
−12,603 B beyond Stage 1, bringing master to 337,989 B (PR #2957).

Refresh Row 1 to reference the current cumulative state, add a
short paragraph explaining the cascade, and ratchet the bloat
regression baseline from 338,117 → 337,989 B (locking in the
128 B headroom #2957 measured).

Closes #2958. Refs #2886.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/2956-gate-tx-failure-diag 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.

Gate handleAllocateTxFailure's diagnostic-only locals + suggestion blocks in release

1 participant