Repository navigation
perf(rmt5): no-op free()/freeDMA() under FASTLED_RMT_STATIC_ALLOCATION (#2856 item 3.6) - #2861
Conversation
#2856 item 3.6) Under FASTLED_RMT_STATIC_ALLOCATION=1 (#2846) the user has asserted no removeLeds() / late addLeds(). The destructor of ChannelEngineRMTImpl still calls memMgr.free() / memMgr.freeDMA() on every channel at process end, but the ledger isn't meaningfully tracked under static mode so the work is dead — yet it still pulls fl::vector_inlined::erase, the begin/end iterator chain, and the multi-line FL_LOG_RMT / FL_WARN operator<< instantiations into the binary. Skip both bodies under the macro. Default behavior (FASTLED_RMT_STATIC_ALLOCATION=0) is unchanged. Refs #2856 item 3.6. Stacks on #2846 (FASTLED_RMT_STATIC_ALLOCATION opt-in macro). Estimated savings: ~few hundred bytes additional when both #2791 (FASTLED_LOG_VERBOSITY=0) and #2846 are also opted in.
|
Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place. 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)
📝 WalkthroughWalkthroughThis PR makes ChangesRMT Static Allocation Memory Management
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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 |
This is the consolidated PR for items 3.1, 3.2, 3.3, 3.5 of FastLED#2856. Item 3.6 already merged via FastLED#2861; item 3.4 was already in master before FastLED#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 FastLED#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 FastLED#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 FastLED#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.
Summary
First PR against meta #2856. Implements item 3.6 in its smallest viable form.
Under `FASTLED_RMT_STATIC_ALLOCATION=1` (#2846) the user has asserted no `removeLeds()` / late `addLeds()`. The destructor of `ChannelEngineRMTImpl` still calls `memMgr.free()` / `memMgr.freeDMA()` on every channel at process end, but the ledger isn't meaningfully tracked under static mode so the work is dead — yet it still pulls `fl::vector_inlined::erase`, the `begin`/`end` iterator chain, and the multi-line `FL_LOG_RMT` / `FL_WARN` `operator<<` instantiations into the binary.
Skip both bodies under the macro:
```cpp
void RmtMemoryManager::free(u8 channel_id, bool is_tx) FL_NOEXCEPT {
#if FASTLED_RMT_STATIC_ALLOCATION
(void)channel_id; (void)is_tx;
#else
// ... existing ledger update + erase loop + FL_LOG_RMT ...
#endif
}
```
Default behavior (`FASTLED_RMT_STATIC_ALLOCATION=0`) is unchanged.
Scope vs the rest of meta #2856
This PR ships item 3.6 only. Items 3.1, 3.2, 3.3, 3.5 are scoped for their own PRs (multi-day / large-blast-radius). Item 3.4 (encoder dedup) was already done in the existing RMT5 architecture before #2856 was filed — the encoder is a runtime virtual on `IRMT5Peripheral::createEncoder(const ChipsetTiming&, u32)`, not templated per-chipset. Updating the tracking matrix on #2856 to reflect this.
Test plan
Refs #2856 item 3.6.
🤖 Generated with Claude Code
Summary by CodeRabbit