-
Notifications
You must be signed in to change notification settings - Fork 8
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
The future of the wasi-threads proposal #48
Comments
I think that wasi-threads has been valuable, both in enabling experimentation and in parallelizing some of the implementation work for threads. The implementations of the memory model support, atomics, wait/notify in engines, as well as mutex/rwlock/etc. in toolchains, are things that are good to have with any threading model. I also think that, as we said up front when wasi-threads was starting, the instance-per-thread model that wasi-threads is built on has some limitations. It prevents linear memory from being encapsulated, it's complicated if we want to link multiple modules together, and in browsers especially it ties threads to some heavyweight resources. These limitations also turn out to make it incompatible with the component model and WASI Preview 2. Consequently, I propose we pursue option 1. The full standardization process will take time, but I'm optimistic that we can get to the point where we can start building prototypes and catch up to where the current wasi-threads is now on a much quicker timeframe. |
add toywasm and wasmer. |
does an alternative proposal which doesn't have those limitations really exist? unless someome gives me an url of the alternative proposal, i propose to pursue option 2. |
add #13 (lack of defined semantics with multiple linked modules) |
I was just talking to @pchickey and he has a good write-up on the "should wasi-threads become a part of preview1" in WebAssembly/WASI#545 — might be worth a read. He highlights how the "instance per thread" paradigm is a problem for incorporating wasi-threads in the component model; let me get back to that later. I think my answer here to "should we (1) propose core Wasm threads or (2) advance wasi-threads" is "both"! But don't get me wrong: I'm not saying we must progress wasi-threads to phase 2. I propose:
Back to the "instance per thread" problem: if the component model and wasi-threads are incompatible, is work on wasi-threads wasted? I would propose that no, I think there is this intermediate period where wasi-threads is still very valuable. Someone may ask, "what if I want WASI but not the component model?" — I can't answer that and it's probably an issue for a different repository! I am going to continue working on making threads available in a portable way in WebAssembly, focusing mainly on the core threads work but helping out as much I can with wasi-threads. |
Thanks all for sharing your view on that topic so far. As of writing the post I only knew there are plans to work on Wasm core threads, but didn't know there's already a work in progress started recently by @abrown. Having threading support in core Wasm sounds reasonable and it's probably good for the long term. However, as pointed out by @abrown, it's going to take time to get there. Until then, I think WASI should provide a standardized solution that satisfies at least a (potentially significant) subset of use cases. If that doesn't happen, I think the adoption of WASI across different teams/companies will be slower as some of the innovations will be blocked, or worst case - might lead to fragmentation and various forks of the spec implemented by different runtimes (which I think we should avoid if we want to compile once, run anywhere). Given the amount of work and significant progress made as part of If the proposal stays where it is today (phase 1), it will always be considered experimental and its support may be limited by some of the toolchains (an example of that is a discussion rust-lang/rust#112922 regarding tiering of wasi-threads target). I think we should consider either backporting |
My personal opinion (I am not a very active WASI contributor, so take that as you will) is that standardizing this in WASI would help develop user base, which in turn would help drive adoption upstream. Relying on upstream standardization alone would make the curve of getting it in steeper, by removing possible intermediate steps. In addition to what thread that @yamt opened shows, there is are a couple aspects of how 'core threads' are going to fit within larger Web standards:
|
Thank you very much for your valuable feedback. We have engaged in extensive discussions on this matter, involving participants from the WASI subgroup meeting (refer to the agenda item). After careful consideration, the community has reached the following conclusions and agreements:
With respect to point 3, you might wonder why we don't simply transition to the new proposal once it's available and supported by both toolchains and runtimes. There are scenarios where runtime updates are not possible for an extended timeframe (beyond 5 years), leaving only the option of updating the WASM binary. For these scenarios, we want to provide the opportunity to use WASI threads today, while also taking advantage of non-threading-related toolchain updates in the future. I am resolving this ticket now. Please don't hesitate to reopen it if there are further discussions or questions. Furthermore, if you're interested in helping with the remaining work on WASI threads or maintaining the toolchain support, feel free to reach out to me directly. |
I wrote a comment (#7 (comment)) justifying the existence of |
Hi all,
As there was recently not much work on the proposal, I'd like us to define some next steps to move towards finalizing threading support in WebAssembly.
A brief summary of the current state:
wasi_thread_spawn
host call was clarified_start
#21wasi_thread_exit()
: Iswasi_thread_exit
needed? #7I think there are two possible ways we can move forward with the proposal:
My personal opinion is that we should progress with
wasi-threads
proposal and accept the risk it becomes deprecated in the distant future (if ever) by WebAssembly threads - this approach will enable a number of use cases in short/mid-term that are currently blocked by lack of standardization of threading in the WASI ecosystem. There's already been a lot of discussions on open questions, and it feels like some of them only need a summary and updated documentation before closing, and some of them can be even resolved as follow-ups after this proposal.I'm looking for others' feedback on that before taking any next steps.
cc @sunfishcode @abrown @sbc100 @AlexEne @yamt
The text was updated successfully, but these errors were encountered: