-
Notifications
You must be signed in to change notification settings - Fork 267
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
Support WASI poll_oneoff for clock events #625
Comments
excellent. I'll help with this unless you are game. |
It appears this is also used in zig, though not sure the code and compilation instructions that generates the binding https://github.com/ziglang/zig/blob/0e6285c8fc31ff866df96847fe34e660da38b4a9/lib/std/time.zig#L24-L47 |
lol I completely forgot about that :)) |
@clarkmcc as there's more than one way to do it, if you have a moment, can you make a scratch repo to reproduce that error? I used wasm32-wasi locally and it failed but invisibly, as opposed to the error you found. I want to make sure I'm doing the same so I can sort it. Main thing is I want to iterate on this, and firstly solve the thread.sleep thing which is reasonably common across compilers. |
@codefromthecrypt here's a reproduction https://github.com/clarkmcc/wazero-issue-625. I believe the key is to pipe stdout and stderr so that the Rust panic gets passed back to Go. |
thanks, @clarkmcc! self-note: here's the wasi-libc call site for sleep, though there are other uses of poll_oneoff https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c |
I did some research and the best way to incrementally implement this is to cheat similarly to how wasmtime and wasi-libc do, where they hook into sleep when the poll event is a clock. ex bytecodealliance/wasmtime#2753 |
by cheat I mean use one sleeper for both supported clocks (wall and nano) due to an interpretation of "clock_settime" not affecting relative time https://linux.die.net/man/3/clock_settime |
#629 works, but I need to backfill tests and check other impls |
Notes about go-generated wasm, doesn't use wasi, rather implements sleep with nanotime.
Ex. the following only uses nanotime when compiled with package main
import "time"
func main() {
time.Sleep(time.Second * 10)
} related, cc @prep |
verified tinygo uses what we think it does |
verified zig thanks to @mathetake for the help gettin ziggy witit $ zig build-exe -O ReleaseSmall -target wasm32-wasi sleep.zig const std = @import("std");
pub fn main() !void {
std.time.sleep(std.time.ns_per_s * 5);
} |
thanks for the patience. #629 should sort this out and also do so incrementally because implementing all of poll_oneoff would be quite a task both for the coder and reviewer! |
Is your feature request related to a problem? Please describe.
Related to #271. The following code in Rust causes the following panic.
Describe the solution you'd like
Support for the
poll_oneoff
WASI method.The text was updated successfully, but these errors were encountered: