Repository navigation
fix(task): clamp the SYSTEM yield to the caller's budget; drop dead needsDeepYield (#3765) - #3766
Merged
Merged
Conversation
…eedsDeepYield (#3765) Two items from the #3765 meta-tracker. 1. task::run()'s SYSTEM branch called pumpCoroutines(1000) with a literal 1000, ignoring its own `microseconds` parameter. Since run() is a do/while loop against a deadline, a caller asking for run(250, SYSTEM) could pump past its own budget. Now clamped to fl::min(1000u, remaining()), mirroring exactly what the COROUTINES branch immediately below already does. Scope, stated plainly because it is narrower than I first claimed on #3765: this is a correctness/consistency fix, NOT an observable bug fix on either platform this suite exercises. - ESP32: pumpCoroutines() floors any non-zero request at one FreeRTOS tick (the `if (ticks == 0) ticks = 1` branch from #2254), so 250 and 1000 are identical. The #2254 deep-yield guarantee is untouched. - Host: CoroutineRunner::run() early-returns when no coroutine is registered (`if (mCount == 0) return;`), so both are no-ops. It only bites with coroutines registered, where the hardcoded 1000 pumps them past the caller's deadline. 2. ICoroutineRuntime::needsDeepYield() was dead code -- declared in coroutine_runtime.h, overridden in coroutine_esp32.impl.hpp, called from nowhere. It duplicated fl::NetworkDetector with weaker semantics (WIFI_MODE_NULL only; no Bluetooth, no Ethernet) and was superseded by the NetworkDetector gating in #2817/#3764. Removed, along with its only caller-helper isWiFiActive() and the esp_wifi include and weak symbol declaration that existed solely to serve it. soc/soc_caps.h is deliberately left: it sits in an IWYU keep block and other ESP headers may rely on it transitively, and this file cannot be compiled locally. On testing: the first version of this change shipped a wall-clock test asserting run(250) does not sleep ~1000us. It passed against the un-fixed code, because of the mCount==0 early return above -- false assurance, so it was removed rather than kept. What remains pins the contract that IS observable here: the zero-budget path must take the cheap fl::yield() and must not sleep, and a small budget must terminate. Verified: 357/357 host tests, bash lint --cpp exit 0. The ESP32 deletion is compile-verified by CI's ESP32 jobs, not locally. Refs #3765, #3762, #2817, #2254 Co-Authored-By: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThe system task runner now limits coroutine pumping to the caller’s remaining microsecond budget. The coroutine runtime removes WiFi-specific deep-yield detection, and executor tests cover zero-budget yielding and bounded positive-budget execution. ChangesSystem yield behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two items from the #3765 meta-tracker — the two that are actually landable while on-device work is blocked by FastLED/fbuild#1213.
1.
task::run()ignored its ownmicrosecondsbudgetexecutor.cpp.hppcalledpumpCoroutines(1000)with a literal1000, discarding the caller'smicroseconds. Becauserun()is ado/whileloop against a deadline,run(250, SYSTEM)could pump past its own budget.Now clamped to
fl::min(1000u, remaining())— exactly what theCOROUTINESbranch three lines below already does.Scope, stated plainly because it is narrower than I claimed on #3765. This is a correctness/consistency fix, not an observable bug fix on either platform this suite exercises:
pumpCoroutines()floors any non-zero request at one FreeRTOS tick (theif (ticks == 0) ticks = 1branch from #2254) — 250 and 1000 are identical. The #2254 deep-yield guarantee is untouched.CoroutineRunner::run()early-returns when no coroutine is registered (if (mCount == 0) return;) — both are no-ops.It only bites with coroutines registered, where the hardcoded 1000 pumps them past the caller's deadline.
2.
needsDeepYield()was dead codeDeclared in
coroutine_runtime.h, overridden incoroutine_esp32.impl.hpp, called from nowhere. It duplicatedfl::NetworkDetectorwith weaker semantics —WIFI_MODE_NULLonly, no Bluetooth, no Ethernet — and was superseded by theNetworkDetectorgating in #2817 / #3764.Removed along with its only helper
isWiFiActive()and theesp_wifi.hinclude plus weak-symbol declaration that existed solely to serve it.soc/soc_caps.his deliberately left: it sits inside anIWYU pragma: keepblock, other ESP headers may rely on it transitively, and this file cannot be compiled locally — not worth the risk for a dead include.A note on the test, because it matters
My first version of this change shipped a wall-clock test asserting
run(250, SYSTEM)does not sleep ~1000 µs. It passed against the un-fixed code — themCount == 0early return above means neither value sleeps on host. That is false assurance, so I deleted it rather than keep a green test that proves nothing. It also corrected my own understanding of the bug's scope, which is why the framing above differs from #3765.What remains pins the contract that is observable here: the zero-budget path must take the cheap
fl::yield()and must not sleep, and a small budget must terminate.Verification
bash lint --cppexit 0Not in this PR
Remaining #3765 items, all needing hardware or further investigation:
show()duration on 3.10.3 vs mastertimingDriftTestreproducer (it has none, so it has never been run)spinBudget= 250 µs when a deep yield costs a full 1000 µs tick)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests