why is threading limited to threads?
why are threads provided by component model?
can't we make an API that provides for a host to provide an API for threads?
(or even like popen or async-signal safety)
there's this amazing paper we've been reading that in our opinion basically does away with the need of language support for threads http://tom7.org/papers/modal-types-for-mobile-code.pdf
There are a bunch of questions here but to add a note on the last: tom7's dissertation is certainly interesting, but the goal of WASI is (I think) not to pull in advanced type system features and do something radically different -- there is only so much innovation budget to take in one step
we need interrupt handling in component model if we wanna be able to stick component model in microcontrollers
someone recently made a custom-page-sizes proposal that makes wasm far more viable in microcontrollers than it's ever been, it'd be unfortunate if we couldn't use it due to lack of support for interrupt handling
I'm not sure why you have strikeout over all your text, and interrupt handling is a different question than either threading or modal types above, but re: embedded use-cases, @Dan Gohman has done some thinking around this
the reason is that modal types solve both threading and interrupt handling
Ah, OK. You're certainly welcome to propose a design based around that in more detail (linking to a dissertation alone is not enough), but keep in mind what I said above: there's only so much innovation budget we can spend; something that diverges radically from the way these use-cases are usually solved will have an uphill battle
it's the concept of worlds (not to be confused with component model worlds - also why are component model worlds called worlds if they don't seem to provide any actual isolation? but anyway) that makes it work for these things
Design proposals would be interesting but I'd encourage you to keep a few principles in mind:
the reason we're bringing it up now is that we believe it's not yet too late to discuss it, unlike... the unfortunate fact that the GC proposal allows cyclic references, which we're slightly upset about. well anyway, no point in discussing that.
the simple fact is that spawning a thread, a process, or setting up interrupt handlers, are more or less the same APIs (with varying levels of "things you're allowed to share" and "how simultaneous these things are"), but hooked up to different backends. what we wanna see is an API that allows a component, like wasi-threads
to export a function that spawns threads, instead of baking it into component model. likewise we could have wasi-signals
and wasi-popen
using the same principle.
there are huge benefits to using "more or less the same API" instead of doing the same thing multiple times. like yeah, we could probably shove popens and interrupts into component model separately, but then you'd have to come up with 3 separate "how does this interact with the rest of the API", one for each of them, and if you overlook anything then things can go really wrong and you get unsoundness. having a model that describes what they're allowed to do and using the same model for all of them lets you get away with a lot more, even if it does take a little more upfront work.
does this make sense?
In general, threading (and similarly: forking) is not "just" a function like any other. It affects many aspects of the runtime semantics.
I recall there being a detailed blogpost about this in the context of WASM/WASI. But can find it right now
I don't think GC would be terribly useful if it didn't allow cycles (at least I can't think of a GC'd language that would be able to use it if that were the case)
another use-case (and this one may be of interest to the serverless folks) is the ability to seamlessly use wasm in the database, with the embedder automatically handling the whole "sending the relevant core modules to the database" and stuff
should we stick that in the component model itself, like we're doing with threads?
it's more or less the same problem domain
David Lloyd said:
I don't think GC would be terribly useful if it didn't allow cycles (at least I can't think of a GC'd language that would be able to use it if that were the case)
(erlang/elixir)
Soni L. said:
another use-case (and this one may be of interest to the serverless folks) is the ability to seamlessly use wasm in the database, with the embedder automatically handling the whole "sending the relevant core modules to the database" and stuff
should we stick that in the component model itself, like we're doing with threads?
and here's the thing - we think wasm should be supporting such use-cases. not via "stick an API for each use-case into the component model specification (or some extension)" but "provide an API for the general class of these use-cases".
As Chris said above; Feel free to write up a proposal for a generic mechanism that unifies threading and "sending the relevant core modules to the database and stuff"
Last updated: Dec 23 2024 at 12:05 UTC