Skip to content

polling with a zero timeout (p2) or waitable-set.polling (p3) can starve the async runtime #13040

@dicej

Description

@dicej

While debugging tokio-rs/tokio#8034, @alexcrichton and I determined that wasmtime_wasi's wasi:clocks/monotonic-clock#{subscribe_instant,subscribe_duration} implementations can cause starvation when combined with wasi:io/poll#poll (on WASIp2). Likewise, on WASIp3, Wasmtime's waitable-set.poll implementation does not currently yield to the async runtime. Because those implementations do not yield at all for zero-duration waits, and because tokio::task::yield_now in guest code will poll with a zero timeout, the host will not yield to it's tokio runtime and give mio a chance to report readiness for one of the other pollables.

The solution is for the host (i.e. wasmtime_wasi) to call tokio::task::yield_new().await in that scenario before returning control to the guest to give mio a chance to run.

Metadata

Metadata

Assignees

Labels

bugIncorrect behavior in the current implementation that needs fixingwasi:implIssues pertaining to WASI implementation in Wasmtimewasm-proposal:component-model-asyncIssues related to the WebAssembly Component Model async proposal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions