Stream: wasi-threads

Topic: ✔ thread-spawn import


view this post on Zulip Scott Waye (May 26 2023 at 18:51):

Why in https://github.com/WebAssembly/wasi-libc/blob/1dfe5c302d1c5ab621f7abf04620fae92700fd22/libc-bottom-half/sources/__wasilibc_real.c#L664 does thread-spawn come from a "wasi" module and not "wasi_snapshot_preview1" like everything else in this file?

WASI libc implementation for WebAssembly. Contribute to WebAssembly/wasi-libc development by creating an account on GitHub.

view this post on Zulip Timmy Silesmo (May 26 2023 at 20:03):

Hello!
I saw that they have thread spawn in wasi_preview1 in wasmer: https://github.com/wasmerio/wasmer/blob/36b077d34b47ec735e5bac7aebcf2878e30135e7/lib/wasi/src/lib.rs#LL398C11-L398C11

🚀 The leading WebAssembly Runtime supporting WASI and Emscripten - wasmer/lib.rs at 36b077d34b47ec735e5bac7aebcf2878e30135e7 · wasmerio/wasmer

view this post on Zulip Timmy Silesmo (May 26 2023 at 20:04):

So if you are able to generate a wasm file with the thread-spawn in the preview namespace then we should be able to run it in the example I send over

view this post on Zulip Scott Waye (May 26 2023 at 20:37):

Ok, but it is the Wasi-SDK that is placing thread-spawn in wasi. I could just change it and rebuild the sdk I suppose, submit a PR and see what they say

view this post on Zulip Scott Waye (May 27 2023 at 15:17):

https://github.com/WebAssembly/wasi-libc/pull/418

This PR changes the import module for thread-spawn from wasi to wasi_snapshot_preview1 . I believe this is correct looking at the spec header file: wasi-libc/libc-bottom-half/heade...

view this post on Zulip bjorn3 (May 27 2023 at 15:25):

thread-spawn comes from https://github.com/WebAssembly/wasi-threads which I believe is part of preview2, not preview1.

Contribute to WebAssembly/wasi-threads development by creating an account on GitHub.

view this post on Zulip Dan Gohman (May 27 2023 at 15:30):

wasi-threads is currently being developed within the framework of preview1, because it's built on the instance-per-thread model, which isn't compatible with preview2.

view this post on Zulip Dan Gohman (May 27 2023 at 15:31):

There are people working on designs for a native threading mechanism for core wasm, which would have various advantages, including being compatible with preview2 and the component model, but it's in an early stage right now.

view this post on Zulip daxpedda (May 27 2023 at 15:59):

Dan Gohman said:

There are people working on designs for a native threading mechanism for core wasm, which would have various advantages, including being compatible with preview2 and the component model, but it's in an early stage right now.

Is there any public information on this? Like a proposal?

view this post on Zulip Dan Gohman (May 27 2023 at 16:00):

The basic design is described in the "Weakening WebAssembly" paper: https://dl.acm.org/doi/pdf/10.1145/3360559

view this post on Zulip Dan Gohman (May 27 2023 at 16:02):

The paper also covers lots of memory ordering topics, but the relevant part here is the fork instruction for creating new threads, and the shared qualifier for functions, globals, etc.

view this post on Zulip Dan Gohman (May 27 2023 at 16:03):

(I'm hoping that fork gets renamed because it's not like Unix fork; it doesn't clone the current callstack, it just starts a new thread executing a given function)

view this post on Zulip Dan Gohman (May 27 2023 at 16:06):

I don't know of any public updates on this yet, but I have heard that there are people starting to work on moving this forward.

view this post on Zulip daxpedda (May 27 2023 at 16:16):

I knew about the paper, was wondering about public updates indeed. My impression was that the idea is totally abandoned.
I'm glad it's being picked up again!

view this post on Zulip Scott Waye (May 30 2023 at 14:33):

Will close as apparently "wasi" is the right import, so maybe it is wasmer that is wrong. I'm pretty confused to be honest.

view this post on Zulip Notification Bot (May 30 2023 at 14:33):

Scott Waye has marked this topic as resolved.

view this post on Zulip YAMAMOTO Takashi (May 31 2023 at 00:33):

Scott Waye said:

Will close as apparently "wasi" is the right import, so maybe it is wasmer that is wrong. I'm pretty confused to be honest.

for some reasons wasmer exports it with multiple names.


Last updated: Nov 22 2024 at 16:03 UTC