Repository navigation
perf(rmt5): gate handleAllocateTxFailure diagnostic block (#2956) - #2957
Conversation
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]>
📝 WalkthroughWalkthroughThe PR adds compile-time conditional gating to the diagnostic block in ChangesDiagnostic logging gate in handleAllocateTxFailure
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
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 (2)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp (2)
481-481: 💤 Low valueOptional: Add trailing comment to
#endiffor 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 tradeoffConsider similar gating in
allocateRxfor consistency (future work).The
allocateRxmethod's diagnostic block (lines 506–527) follows the same pattern as the now-gatedhandleAllocateTxFailureblock: it computes diagnostic-only locals (total,allocated,reserved,available) and emits conditionalFL_WARNmessages. Applying the same#if FASTLED_LOG_RUNTIME_ENABLEDgate 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
handleAllocateTxFailureper#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
📒 Files selected for processing (1)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
| // 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. |
There was a problem hiding this comment.
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.
| // 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.
…) (#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]>
Summary
Test plan
Closes #2956. Refs #2886.
🤖 Generated with Claude Code
Summary by CodeRabbit