Repository navigation
perf(rmt5): split allocateTx fail-path into cold helper (#2773 item 2.5) - #2840
Conversation
|
Worried about impact? Review this PR in Change Stack to explore blast radius before you approve or request changes. 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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughallocateTx now delegates insufficient TX allocation handling to a new cold helper, handleAllocateTxFailure, which performs progressive 1× buffering fallback, updates the ledger on recovered allocations, and emits consolidated diagnostics on final failure. ChangesTX Allocation Failure Handler Refactoring
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 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
🤖 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`:
- Line 432: Replace emoji prefixes in the diagnostic log strings with text-based
prefixes: locate the FL_LOG_RMT calls in rmt_memory_manager.cpp.hpp (e.g., the
line that logs "✓ Fallback successful: allocated ..." and the line that logs "✗
..." around the fallback logic) and change the emoji to readable text prefixes
such as "[OK]" for success and "[FAIL]" or "[ERROR]" for failure, preserving the
rest of the message and formatting.
🪄 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: 8175c1e0-d6f3-47ff-b4d2-671dfd9abba7
📒 Files selected for processing (2)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hppsrc/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h
…NLINE cold helper (#2773 item 2.5 — easy share) Same cold-helper pattern that worked for #2773 items 2.1 (PR #2830) and 2.2 (PR #2838). Hot path of allocateTx (initial tryAllocateWords succeeds — the common Blink boot case where there's plenty of TX memory) was bloated by the single-buffer fallback retry + 4 FL_WARN diagnostic lines + 3 conditional suggestion blocks, all of which reach for fl::sstream operator<< chains. Extract them into handleAllocateTxFailure(), an FL_NO_INLINE member helper. Hot path now ends at: if (!tryAllocateWords(words_needed, true)) { return handleAllocateTxFailure(channel_id, mem_blocks, words_needed, networkActive); } Cold path is behaviorally unchanged. This captures the easy share of #2773 item 2.5's ~3-4 KB target. The full template-trait refactor (skip the runtime planner entirely when addLeds<> is called exactly once with a known length) is still TODO but is a multi-day effort with template-instantiation risk.
846900f to
df55878
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h (1)
450-452: ⚡ Quick winAdd
FL_NO_INLINEto the declaration to match the implementation.The implementation in
rmt_memory_manager.cpp.hpp(line 409) hasFL_NO_INLINEbefore the return type, but the declaration here omits it. Since preventing inlining is central to the performance goal of this PR (#2773item 2.5), the declaration should include the attribute for consistency and to document the performance-critical nature of this cold-path helper.♻️ Proposed fix to add FL_NO_INLINE
/// `@brief` Cold-path fallback + diagnostic for failed TX allocations. /// Extracted from allocateTx so the hot path (initial tryAllocateWords /// succeeds — the common Blink boot case) doesn't inline the single-buffer /// retry block, the FL_WARN diagnostic strings, or the suggestion /// messages. Returns the recovered allocation size on success, or a /// failure result on hard failure. See `#2773` item 2.5. - result<size_t, RmtMemoryError> handleAllocateTxFailure( + FL_NO_INLINE result<size_t, RmtMemoryError> handleAllocateTxFailure( u8 channel_id, size_t mem_blocks, size_t words_needed, bool networkActive) FL_NOEXCEPT;🤖 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.h` around lines 450 - 452, The declaration of the cold-path helper handleAllocateTxFailure(u8 channel_id, size_t mem_blocks, size_t words_needed, bool networkActive) omits the FL_NO_INLINE attribute that the implementation uses; update the function prototype for handleAllocateTxFailure in the header to include FL_NO_INLINE before the return type so the declaration matches the implementation (and documents/prevents inlining for this performance-critical helper).
🤖 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.
Nitpick comments:
In `@src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h`:
- Around line 450-452: The declaration of the cold-path helper
handleAllocateTxFailure(u8 channel_id, size_t mem_blocks, size_t words_needed,
bool networkActive) omits the FL_NO_INLINE attribute that the implementation
uses; update the function prototype for handleAllocateTxFailure in the header to
include FL_NO_INLINE before the return type so the declaration matches the
implementation (and documents/prevents inlining for this performance-critical
helper).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f69bfc85-e107-4f42-aad4-b2391e18b152
📒 Files selected for processing (2)
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hppsrc/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h
🚧 Files skipped from review as they are similar to previous changes (1)
- src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
… (CR feedback on #2840)
Summary
Same cold-helper pattern that worked for #2773 items 2.1 (PR #2830) and 2.2 (PR #2838). Applied here to
RmtMemoryManager::allocateTx.Hot path was bloated by the single-buffer fallback retry + 4 `FL_WARN` diagnostic lines + 3 conditional suggestion blocks — all of which reach for `fl::sstream operator<<` chains. The hot path (initial `tryAllocateWords` succeeds — the common Blink boot case where there's plenty of TX memory) now ends at a single conditional helper call:
```cpp
if (!tryAllocateWords(words_needed, true)) {
return handleAllocateTxFailure(channel_id, mem_blocks,
words_needed, networkActive);
}
```
Cold path is behaviorally unchanged.
This captures the easy share of #2773 item 2.5's ~3-4 KB target. The full template-trait refactor (skip the runtime planner entirely when `addLeds<>` is called exactly once with a known length) is still TODO but is a multi-day effort with template-instantiation risk.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit