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

Implement poll_oneoff in WASI P1 #592

Closed
andreaTP opened this issue Oct 22, 2024 · 7 comments · Fixed by #716
Closed

Implement poll_oneoff in WASI P1 #592

andreaTP opened this issue Oct 22, 2024 · 7 comments · Fixed by #716
Assignees

Comments

@andreaTP
Copy link
Collaborator

Zig, the Go standard library, Rust(in some cases) and c2w require poll_oneoff.
It would be great to have a stable implementation of it.

Spike ref:
https://github.com/dylibso/chicory/pull/530/files#diff-9037d84891e8043e756bfd63e2101686b67d1cad2cc2c4af3b2e6b48675acdf3R1086

@andreaTP andreaTP changed the title WASI implement poll_oneoff Implement poll_oneoff in WASI P1 Oct 22, 2024
@evacchi evacchi self-assigned this Oct 22, 2024
@evacchi
Copy link
Collaborator

evacchi commented Oct 22, 2024

I want to take a look at this one soon

@electrum
Copy link
Collaborator

electrum commented Dec 2, 2024

I started looking at this a while ago, but it didn't seem possible to run the WASI testsuite tests due to them using stdin/stdout/stderr which are fundamentally blocking in our implementation as we use InputStream/OutputStream. Would it suffice to simply implement the timer part and return ENOTSUP for other descriptors?

@electrum
Copy link
Collaborator

electrum commented Dec 2, 2024

I found that various library functions in Python such as the socket library will fail due to poll_oneoff (even though they would eventually fail with a different error as WASI doesn't support creating sockets).

@evacchi
Copy link
Collaborator

evacchi commented Dec 2, 2024

Would it suffice to simply implement the timer part and return ENOTSUP for other descriptors?

pretty much. Also, stdin kinda wants to be treated differently, so in wazero we special case that. Basically I've been meaning to port over the logic here https://github.com/tetratelabs/wazero/blob/610c202ec48f3a7c729f2bf11707330127ab3689/imports/wasi_snapshot_preview1/poll.go#L98-L197

but you can get away with less than that for a lot of binaries; a lot of the nonblocking stuff is related to how the Go compiler (not tinygo) wants to treat I/O (it sets the nonblocking flag everywhere)

@andreaTP
Copy link
Collaborator Author

andreaTP commented Dec 2, 2024

Would it suffice to simply implement the timer part and return ENOTSUP for other descriptors?

Very likely, from what I've seen the Go and Zig code using it are fine with the timer part, just remember to throw meaningful exceptions in case is not so that we can eventually track other usages.

@electrum
Copy link
Collaborator

electrum commented Dec 3, 2024

That code is polling for data on stdin. We could do a sleep loop while calling available().

@evacchi
Copy link
Collaborator

evacchi commented Dec 3, 2024

that might work

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

Successfully merging a pull request may close this issue.

3 participants