driver: a host call registered while a driver is parked wakes it (stale race snapshot) - #289
Merged
Merged
Conversation
…le race snapshot) driveAsync parks a quiet guest on Promise.race([...pendingHostCalls, ...]), and that spread is a snapshot. An export entered through the synchronous drive path starts no new driver, so it fires no driver-arrival; a host call the guest registers during it is invisible to the parked race. When that call settles, its continuation readies the thread but nothing drives the store, and the settlement pump stands down because the parked driver keeps storeDriverDepth > 0. The guest is resumed only by the next unrelated export call. The routine victim is a stream-dom producer: a readDirect session keeps a HostActivity driver parked (one long-poll import outstanding), and every import awaited from an event handler stalls until the next event. Fix: a host-call-arrival one-shot, sibling to driver arrival, fired by the new registerHostCall() at both lowering sites and raced by driveAsync's two parks and the settlement pump. Same class as #239 with the registration, rather than a second loop, as the unheard event. Regression: runtime/tests/parked_driver_host_call_test.ts (store-level, fails pre-fix).
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.
`driveAsync` parks a quiet guest on `Promise.race([...pendingHostCalls, armDriverArrival])`; the spread is a snapshot. An export entered through the synchronous `drive` path starts no new driver and so fires no driver-arrival; a host call the guest registers during it is invisible to the parked race. When it settles, the continuation readies the thread but nothing drives the store — the settlement pump stands down because the parked driver keeps `storeDriverDepth > 0`. The guest resumes only on the next unrelated export call.
Routine victim: a stream-dom producer. A `readDirect` session keeps a `HostActivity` driver parked as long as one host import (a long poll) is outstanding, and every import awaited from an event handler then stalls until the next event. Found in polyvisor M1; minimal end-to-end repro (wit-bindgen guest, Deno host) at the bottom.
Fix: a host-call-arrival one-shot beside driver arrival, fired by `registerHostCall()` at both lowering sites and raced by `driveAsync`'s two parks and the settlement pump. Same class as #239 with the registration, rather than a second loop, as the unheard event.
Regression test: `runtime/tests/parked_driver_host_call_test.ts` (store-level, fails pre-fix). `just test-runtime`: 702 passed.
End-to-end repro shape
Guest: `run` returns a stream and spawns (a) a task awaiting a never-settling import, (b) a scheduler task. Async export `kick` queues a job that awaits import `ping` (host settles it after 20 ms) and wakes the scheduler. Host holds a `readDirect` session on the stream. Pre-fix: `ping N` settles, `job N` observes it only after `kick N+1`.
Automerge armed.