Destructor17 opened issue #14364:
Feature
monotonic-clock.wait-untilandmonotonic-clock.wait-forin WASIp3 (and probably corresponding pollables in WASIp2) are implemented usingtokio::time::sleep, which is kinda inaccurate in terms of waiting. It seem to have 1ms resolution on UNIX and up to ~16ms on Windows. It would be nice to have a higher-resolution sleep primitive.Benefit
It's not observable on workloads Wasmtime is usually used for, but such inaccuracy has high impact on GUI apps if sleep between frames is implemented in guest code. In my case 1ms resolution makes FPS drop from 60 to 58 on UNIX and to 30 on Windows.
Implementation
This can be solved by simply using tokio_hrtime, a drop-in replacement for
tokio::time.Alternatives
Well,
tokio_hrtimeis just the first thing that pops up while googling. Have not researched this topic in-depth, but there should be more implementations, althoughtokio_hrtimeworks fine for me.As for Windows, this problem can also be (partially) solved by calling timeBeginPeriod function to increase resolution to 1ms, but they say it makes Windows waste CPU cycles.
Last updated: Sep 20 2026 at 18:08 UTC