Skip to content

perf(rmt5): cold-helper split for createChannel recovery loop (#2773 item 2.2) - #2838

Merged
zackees merged 1 commit into
masterfrom
feat/2773-2.2-createchannel-recovery-cold
Jun 5, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2773-2.2-createchannel-recovery-cold

Conversation

@zackees

@zackees zackees commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Extracts the progressive memory-reduction retry loop inside ChannelEngineRMTImpl::createChannel into a new FL_NO_INLINE attemptAllocationRecovery() cold helper. Hot path (initial allocation succeeds, the common static-addLeds<>-at-boot case) shrinks proportionally; cold path is behaviorally unchanged.
  • Fixes a pre-existing C++17 nested-namespace error in src/fl/net/network_detector.h that broke local quick-mode test builds under -Wc++17-extensions. (CI uses C++17+ so it didn't surface there.)

Same pattern that worked for #2773 item 2.1 in #2830 — the helper isolates the FL_LOG_RMT/FL_WARN operator<< instantiations and a per-iteration Rmt5ChannelConfig constructor that the linker would otherwise have to keep live inside createChannel's body.

Target: ~1–2 KB Blink savings on ESP32-S3.

Closes one bullet on the #2773 punch list.

Test plan

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Updated namespace declarations in network detection module.
    • Reorganized RMT5 channel memory allocation logic for improved code structure.

…lper (#2773 item 2.2)

Same pattern that worked for #2773 item 2.1 in PR #2830: the progressive
memory-reduction retry loop inside ChannelEngineRMTImpl::createChannel is
a cold path (only reached when the initial allocation fails — typically
never, in the static addLeds<>-at-boot scenario), but its body contains
FL_LOG_RMT/FL_WARN operator<< instantiations plus a per-iteration
Rmt5ChannelConfig constructor that the linker has to keep live inside the
hot function body.

Move the retry block into attemptAllocationRecovery(), an FL_NO_INLINE
member helper. The hot path (initial allocation succeeds) shrinks
proportionally; the cold path is unchanged behaviorally.

Also fix a pre-existing C++17 nested-namespace error in
src/fl/net/network_detector.h that broke local quick-mode test builds
under -Wc++17-extensions. (CI uses C++17+ so it didn't catch it.)

Target: ~1-2 KB Blink savings on ESP32-S3.
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Wondering what really moved? Review this PR in Change Stack to inspect semantic changes, definitions, and references.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af49d27b-b5e9-4c21-905e-c56428928cd4

📥 Commits

Reviewing files that changed from the base of the PR and between df207c0 and 18f7824.

📒 Files selected for processing (2)
  • src/fl/net/network_detector.h
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp

📝 Walkthrough

Walkthrough

This PR contains two independent refactoring updates: a namespace declaration style change to the network detector header, and extraction of RMT5 channel memory-allocation recovery logic into a dedicated cold-path helper method to simplify the hot path.

Changes

Network and RMT5 Refactoring

Layer / File(s) Summary
Network detector namespace formatting
src/fl/net/network_detector.h
Namespace declaration rewritten from inline nested form to expanded nested form with matching closing comments; no public API changes.
RMT5 allocation recovery helper extraction
src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
New attemptAllocationRecovery(...) helper method introduced to handle progressive memory-reduction retry logic for RMT TX channel allocation; createChannel(...) updated to call this helper, reducing hot-path complexity while preserving original failure semantics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • FastLED/FastLED#2826: Both PRs refactor RMT5 allocation recovery logic in ChannelEngineRMTImpl::createChannel()—this PR extracts the recovery path into a helper method, while the related PR extracts recovery/failure logging into noinline helpers.

Poem

🐰 A rabbit hops through namespaces wide,
Where mem'ries retry with stubborn pride,
From inline chaos to ordered grace,
Cold paths extracted to find their place!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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: extracting a cold-helper function for the RMT5 channel recovery loop. It is specific, concise, and directly related to the primary modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/2773-2.2-createchannel-recovery-cold

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.

@zackees
zackees merged commit b9ddd8c into master Jun 5, 2026
7 of 8 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 5, 2026
zackees added a commit that referenced this pull request Jun 6, 2026
…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.
@zackees
zackees deleted the feat/2773-2.2-createchannel-recovery-cold 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.

1 participant