One top-level shared
flag instead of granular shared
flags per-type
#32
Replies: 2 comments
-
Apologies for throwing out a short comment - I'll try to digest this more thoroughly in the meantime. The standard knee-jerk argument against such a module-level flag is that it interferes with our ability to merge already-compiled modules (e.g. see WebAssembly/binaryen#5709). For example if I build a program involving an unshared module that calls a shared module (which may have been separately compiled), for optimisation/deployment/distribution purposes I may want to merge these two modules together into one bigger module, but this wouldn't easily be possible if "sharedness" could only be marked at module granularity. |
Beta Was this translation helpful? Give feedback.
-
What @conrad-watt said. As I have argued on multiple occasions, no semantics should ever be tied to module scopes. Modules are merely a grouping mechanism for definitions, and regrouping (splitting/merging modules) should always be possible without restrictions. |
Beta Was this translation helpful? Give feedback.
-
I've been talking with @abrown about this proposal and thinking about some high-level details about how it might be implemented in Wasmtime. Nothing is concrete yet and it's clear that lots of internals in Wasmtime need to be redesigned for this proposal in addition to the embedding API. One thing that I've been thinking about though is whether it would suffice to change the proposal to avoid adding
shared
tags on all types and instead have a singleshared
tag at the module level. For example instead ofit would instead be:
The theory would be that within a
shared
module everything behaves exactly the same as the current state of the proposal if all types/globals/funcs/etc were all taggedshared
. So in that sense I'm not thinking that this would not be a runtime-wise semantic change. The major change, relative to the current proposal, is that module can no longer declare both shared and unshared things internally and use them, except of course for core wasm today which can work with ashared
memory (through the priorthreads
proposal).I realize that this would be a radical rethinking of the current proposal. I also realize that it would be a pretty significant shift in course from prior thinking. I also realize that use cases which rely on intermixing shared and unshared things may not work. In that sense I wanted to start a discussion on this and see where it goes. Some benefits of this approach that I've been thinking are:
Store
which is used to create an instance. AStore
, however, is effectively a single-threaded thing and can only be used on one thread at a time. This is in contrast with shared things which want to be used on multiple threads at the same time. That means to get aSharedFunc
(again, a hypothetical) you'd have to create a single-threadedStore
, create anInstance
which is bound to thatStore
, then acquire aFunc
as an export, then cast that to aSharedFunc
, then move that to other threads and work with it. This is in contrast with a hypothetical shared module where in Wasmtime we'd represent that at the type level (e.g. aSharedModule
as opposed to aModule
which would have a different instantiation process which may not deal with aStore
.I'll reiterate again as well that I realize this would be a radical change of pace for this proposal. That being said if a change like this were ever to be made this is probably the time to do it. So in that sense I wanted to test the waters a bit and throw this out there and see what others thought. I do not personally understand all the intricacies of threading on the web for example and would be eager to hear more about how that means this could never work or things like that.
Beta Was this translation helpful? Give feedback.
All reactions