Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yield during pending_req_poll #274

Open
jameysharp opened this issue Jun 1, 2023 · 0 comments
Open

Yield during pending_req_poll #274

jameysharp opened this issue Jun 1, 2023 · 0 comments

Comments

@jameysharp
Copy link
Contributor

I think pending_req_poll should call tokio::task::yield_now before returning when the request is not ready.

A guest which invokes that hostcall in a loop, like the upstream-async test fixture, may not give Tokio any other opportunities to do I/O. Viceroy currently addresses that by using Wasmtime's "fuel" mechanism to interrupt the loop periodically, but in between those interruptions the loop spins without any way to make progress.

Note that Tokio's implementation of yield_now is very similar to Wasmtime's implementation of an async yield in response to either fuel-based or epoch interruption: both return Pending on the first poll and Ready on the second.

So I think yielding in pending_req_poll will tend to reduce both latency and CPU usage. In addition I think it means the upstream-async test would pass without either fuel-based or epoch interruptions, although there may be other situations which still require those interruptions in order to make progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant