Repository navigation
perf(channels): add waitDone() virtual + manager N=1 fast path (Phase 2 of #2815, Closes #2819) - #2828
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds IChannelDriver::waitDone(u32) with a default delegating implementation, and changes ChannelManager::waitForReady() to detect a single non-READY driver and call that driver's waitDone(timeoutMs) as a fast path; other cases fall back to the existing aggregate wait. ChangesSingle-Driver Wait Optimization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
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 |
… 2 of #2815, Closes #2819) Adds IChannelDriver::waitDone(u32 timeoutMs) as a virtual with a default delegate to the existing waitForReady(timeoutMs). Drivers that have an ISR-driven completion primitive (FreeRTOS semaphore, IDF wait-all-done call, event-group) can override this to block directly on it - bypassing both the spin tier (from #2818) and the cooperator yield loop. Drivers that haven't migrated continue to work unchanged via the default delegate. ChannelManager::waitForReady now does a poll() pre-pass to classify drivers, and when exactly one driver is BUSY it delegates to driver->waitDone(timeoutMs) - the single-driver fast path. The N=1 case covers ~83% of FastLED sketches per a survey of examples/. For N > 1 (multi-driver aggregate wait) the manager falls through to the existing tiered waitForCondition loop. Phase 3 of #2815 will add a shared-sem / task-notification fan-in for that case. This PR does NOT add the per-driver waitDone() overrides themselves. Each driver-side override (PARLIO -> parlio_tx_unit_wait_all_done, RMT5 -> rmt_tx_wait_all_done, LCD_SPI -> existing xSemaphoreTake on mCompleteSem, etc.) is incremental and can land as a separate small PR per driver, gradually unlocking the ISR-exact wait for each. Closes #2819. Refs #2815, #2818. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4e9c11d to
f30a548
Compare
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
Summary
Phase 2 of #2815 / Closes #2819. Builds on #2817 (NetworkDetector gate) and #2827 (Tier-2 spin).
Adds the
IChannelDriver::waitDone(u32 timeoutMs)virtual with a default delegate, and inserts a single-driver fast path inChannelManager::waitForReady. Together they expose a hook for drivers to bypass the spin/yield loop and block directly on their existing ISR-driven completion primitive.What the fast path does
For a driver that overrides
waitDone()to call its semaphore-backed wait (e.g. PARLIO ->parlio_tx_unit_wait_all_done, LCD_SPI -> existingxSemaphoreTake(mCompleteSem, ticks)), the wait wakes precisely when the DMA-done ISR fires (~µs) instead of paying the 250 us spin budget or the cooperator yield's tick floor.The default
waitDone()delegates to the existingwaitForReady(timeoutMs), so drivers that haven't migrated continue to work identically to before. No regressions.Survey: N=1 is the common case
Across
examples/, ~83% of sketches register a single driver type (single chipset family, possibly multiple strips on the same driver). True multi-driver concurrency (e.g. SPI clockless + PARLIO simultaneously) is rare. The fast path covers the overwhelming majority of users.Files
src/fl/channels/driver.hbool waitDone(u32 timeoutMs)with default-delegate towaitForReadysrc/fl/channels/manager.cpp.hppwaitForReadyWhat this PR does NOT do (deferred to follow-up PRs)
The fast path only delivers the latency win if drivers override
waitDone(). The driver-side overrides are intentionally NOT in this PR - each one is small and self-contained, and they should land incrementally so a regression in any one is easy to bisect:parlio_tx_unit_wait_all_done()(parlio_peripheral_esp.cpp.hpp:334)rmt_tx_wait_all_done()(IDF semaphore)xSemaphoreTake(mCompleteSem, ticks)(lcd_spi_peripheral_esp.cpp.hpp:452)xSemaphoreTake(mCompleteSem, ticks)(i2s_spi_peripheral_esp.cpp.hpp:556)spi_device_get_trans_result()(spi_peripheral_esp.cpp.hpp:283)mBusy- needs ~20 LOC to add a binary sem + give-in-ISRmBusy- needs ~20 LOC similarEach driver override is essentially:
Test plan
Host
waitDone).spi_pingpong_pipeline_logic, independent ofFastLED.*/waitFor*/ChannelManager).Hardware (deferred until driver-side overrides land)
waitDoneoverride: confirmshow()wall time drops by ~250 us (the previously-paid spin budget).Cross-references
🤖 Generated with Claude Code
Summary by CodeRabbit