Expand description
Async GPU dispatch & back-pressure.
After the launch host function records a kernel launch (via a CUDA
Event on real hardware), Wasmtime suspends the calling Wasm fiber by
awaiting a DispatchFuture. The runtime is free to schedule other
Wasm instances in the meantime. The future resolves when the CUDA Event
synchronises, signaling kernel completion.
On no-CUDA hosts the future resolves immediately (it represents work that “ran” only nominally), but the back-pressure machinery still applies — useful for unit-testing the rate-limit logic.
Structs§
- Back
Pressure - A back-pressure semaphore plus a live-counter for observability.
- Borrowed
Dispatch Permit - Borrowed counterpart to
DispatchPermitreturned byBackPressure::acquire_borrowed. Its lifetime is bound to the&BackPressureit was acquired from, so it cannot cross atokio::spawnboundary — useDispatchPermitfor that. In return, acquisition skips theArc<Semaphore>clone the owned variant pays. - Dispatch
Future - A future representing an in-flight GPU dispatch.
- Dispatch
Permit - RAII permit returned by
BackPressure::acquire. Dropping it releases the underlying semaphore slot and decrements the live counter.
Enums§
- Back
Pressure Error - Errors returned by the deadline-aware back-pressure acquire path.
Constants§
- DEADLINE_
NEAR_ WINDOW - Window before the configured deadline during which the back-pressure
path tightens: new acquires are rejected with
BackPressureError::DeadlineNearso the in-flight cohort can drain without being further saturated by fresh launches. Picked at 50 ms — five default epoch ticks — which empirically lets a per-tile loop wind down (typical tile completion ≤ a few ms) without surrendering useful budget on the common path. - DEFAULT_
MAX_ CONCURRENT_ GPU_ OPS - Default maximum number of concurrent GPU operations across the process. Mirrors the plan’s choice of “a few times the number of SMs” — tuned at startup to match the deployed hardware in S17.