daichifukui opened PR #8429 from daichifukui:realtime-improvement
to bytecodealliance:main
:
Allow sleep form of poll_oneoff for wasmtime-wasi crate, which just sleeps for relative time using sleep from the std::thread. This patch derives from the commit "Support sleep forms of poll_oneoff" 6b40724d18a144a0f781b7b907a13be885713f1f. Applying this patch would help improve the real-time performance of wasmtime.
Closes #8428
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
daichifukui requested wasmtime-core-reviewers for a review on PR #8429.
daichifukui requested alexcrichton for a review on PR #8429.
alexcrichton submitted PR review:
Thanks! I've got a comment about needing to handle
allow_blocking_current_thread
since by default the current thread should not be blocked, but otherwise looks good to me.
alexcrichton submitted PR review:
Thanks! I've got a comment about needing to handle
allow_blocking_current_thread
since by default the current thread should not be blocked, but otherwise looks good to me.
alexcrichton created PR review comment:
Can this use
self.ctx().allow_blocking_current_thread
to dispatch on whether to callstd::thread::sleep
or do an async tokio-based sleep?
pchickey submitted PR review.
pchickey created PR review comment:
Can you please leave a comment here describing why this special case exists - specifically that it was experimentally determined to result in more consistent sleep times as required for real-time use cases?
daichifukui updated PR #8429.
daichifukui submitted PR review.
daichifukui created PR review comment:
Hi @pchickey ,
Yes, I added a comment for more explanation. Hopefully that helps us understand this special case.
daichifukui submitted PR review.
daichifukui created PR review comment:
Hi @alexcrichton ,
Yes, we can use it. Take a look at the updated change. Ifself.ctx().allow_blocking_current_thread
is false, we just skip callingstd::thread::sleep
, and then do the rest ofpoll_oneoff
to do an async tokio-based sleep.
alexcrichton updated PR #8429.
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #8429.
alexcrichton merged PR #8429.
Last updated: Nov 22 2024 at 17:03 UTC