Repository navigation
perf: combined #2856 items 3.1 + 3.2 + 3.3 + 3.5 (single PR per /clud-pr workflow) - #2863
Conversation
…tem 3.5) The existing allocateTx / allocateRx return result<size_t, RmtMemoryError> — a sum type with discriminator + payload. At the 4 internal callers inside the RMT5 driver chain (ChannelEngineRMT::createChannel × 2, RmtRxChannelImpl::ctor + begin) the specific error code is never read; callers just log + return false on any failure. Add tryAllocateTx / tryAllocateRx wrappers returning bool + size_t out parameter. The result<>-bearing API is retained for callers that need error fidelity (tests, future callers, the public surface). Migrate the 4 internal sites to the new API. Mock RmtMemoryManager (rmt5_support_stubs.h) gets matching always-succeeds stubs so the host test build still links. Refs #2856 item 3.5. Estimated savings: small (call-site result<> constructor + .ok() + .value() decoded into bool check + out param read). Real win compounds with #2791 (FASTLED_LOG_VERBOSITY=0) and #2846 (FASTLED_RMT_STATIC_ALLOCATION=1) where the FL_WARN diagnostic chains already disappear.
This is the consolidated PR for items 3.1, 3.2, 3.3, 3.5 of #2856. Item 3.6 already merged via #2861; item 3.4 was already in master before #2856 was filed (encoder is already a runtime virtual on IRMT5Peripheral::createEncoder). Item 3.1 — Cold-helper split of ChannelEngineRMTImpl::~dtor ============================================================ The destructor body (drain-wait + per-channel cleanup loop + FL_WARN timeout diagnostic + FL_LOG_RMT trailer) is a cold path — only reached at process end. Move it into an FL_NO_INLINE destructorCleanup() helper so its operator<< instantiations + the multi-line cleanup loop body don't contribute to icache footprint in the steady-state code that calls into the engine. Item 3.2 — FL_WARN_LIT / FL_LOG_LIT for literal-only sites ========================================================== Each FL_WARN(literal) bakes an fl::sstream + operator<< chain for the file/line prefix + the literal at every call site. For sites that pass nothing but a literal string, that's pure overhead vs a single fl::println call. Add FL_WARN_LIT(literal) / FL_LOG_LIT(literal) macros: route literal- only messages through fl::println directly, dropping the file/line prefix. The literal carries its own "[RMT]" prefix to partially compensate. The non-literal FL_WARN remains available for sites that need operator<< formatting or the file/line prefix. Migrates the destructor timeout warning as a first proof-of-concept. Other call sites can move to FL_WARN_LIT incrementally. Item 3.3 — Skip NetworkDetector under FASTLED_RMT_STATIC_ALLOCATION =================================================================== ChannelEngineRMT::createChannel calls NetworkDetector::isAnyNetworkActive() on every allocation to choose network-mode vs idle-mode buffer sizing. Under FASTLED_RMT_STATIC_ALLOCATION the user has asserted no network during LED transmission (per #2846), so this resolves to constexpr false. The linker then drops the NetworkDetector singleton + WiFi-state-reading chain from the binary. Item 3.5 — tryAllocateTx / tryAllocateRx status-code variants ============================================================= (Same as the closed #2862 — cherry-picked here for the single combined PR.) Adds bool-returning wrappers around the result<>-bearing allocateTx/allocateRx for the 4 internal callsites that don't need the specific error code. Result<>-bearing API retained for tests + public callers. Refs #2856. Closes the actionable scope of the meta; the deferred items (full Level B refactor, full printf backend, full static-bind addLeds<>) are independently large enough to deserve their own issues and aren't safe to land in one PR session.
|
Linter diff in the way? Review this PR in Change Stack to focus on meaningful changes and expand context only when needed. 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 (6)
📝 WalkthroughWalkthroughThe PR introduces compile-time literal-only logging macros (FL_WARN_LIT/FL_LOG_LIT) for direct string output without formatting overhead, adds status-code style allocation wrappers (tryAllocateTx/tryAllocateRx) to RmtMemoryManager, and refactors RMT TX/RX channel drivers to use these new APIs while adding compile-time networkActive configuration support. ChangesLogging and RMT allocation refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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 |
Summary
Single combined PR for meta #2856, per the /clud-pr workflow's "one PR per task" rule. Items 3.6 (#2861) was already merged separately before this consolidation; item 3.4 was already in master before #2856 was filed.
This PR addresses items 3.1, 3.2, 3.3, and 3.5:
Item 3.1 — Cold-helper split of `ChannelEngineRMTImpl::~dtor`
The destructor body (drain-wait + per-channel cleanup loop + FL_WARN timeout diagnostic + FL_LOG_RMT trailer) is a cold path — only reached at process end. Move it into an `FL_NO_INLINE destructorCleanup()` helper so its operator<< instantiations + the multi-line cleanup loop body don't contribute to icache footprint in the steady-state code that calls into the engine. Same pattern that worked for #2773 items 2.1 (PR #2830), 2.2 (PR #2838), 2.5 (PR #2840).
Item 3.2 — `FL_WARN_LIT` / `FL_LOG_LIT` macros for literal-only sites
Each `FL_WARN(literal)` bakes an `fl::sstream` + `operator<<` chain for the file/line prefix + the literal at every call site. For sites that pass nothing but a literal string, that's pure overhead vs a single `fl::println` call.
Add `FL_WARN_LIT(literal)` / `FL_LOG_LIT(literal)` macros: route literal-only messages through `fl::println` directly, dropping the file/line prefix. The literal carries its own `"[RMT]"` prefix to partially compensate. The non-literal `FL_WARN` remains available for sites that need operator<< formatting or the file/line prefix.
Migrates the destructor timeout warning as a first proof-of-concept. Other call sites can move to `FL_WARN_LIT` incrementally.
This is a bounded, first step toward the full printf-style log backend described in #2856 item 3.2. The full backend (`fl::printf("fmt", args...)`) is multi-day work; this PR introduces the literal-only fast path as a stable building block. Subsequent PRs can add the printf API and bulk-migrate remaining sites.
Item 3.3 — Skip `NetworkDetector` under `FASTLED_RMT_STATIC_ALLOCATION`
`ChannelEngineRMT::createChannel` calls `NetworkDetector::isAnyNetworkActive()` on every allocation to choose network-mode vs idle-mode buffer sizing. Under `FASTLED_RMT_STATIC_ALLOCATION` (#2846) the user has asserted no network during LED transmission, so this resolves to constexpr `false`. The linker then drops the `NetworkDetector` singleton + WiFi-state-reading chain from the binary.
This is the most impactful piece of #2856 item 3.3 that can land safely. The full static-bind addLeds<>() refactor (touching every example) is deferred.
Item 3.5 — `tryAllocateTx` / `tryAllocateRx` status-code variants
(Same content as the closed #2862, cherry-picked into this single combined PR.) Adds bool-returning wrappers around the `result<>`-bearing `allocateTx`/`allocateRx` for the 4 internal callsites that don't need the specific error code. `result<>`-bearing API retained for tests + public callers.
What's NOT in this PR
The /clud-pr stop-hook flagged that #2856 was multi-PR; this PR consolidates. But three pieces of work in the meta are genuinely sprint-sized refactors that cannot safely land in one PR session:
The minimal real wins from each (this PR) are landed; the architectural refactors are documented in #2856's tracking matrix as deferred.
Test plan
Refs #2856.
🤖 Generated with Claude Code
Summary by CodeRabbit