I read through the documentation of the current component model implementation in wasmtime. Is it somehow possible to access a components imports? I did not figure out a way on how to do it. For module there it is possible by calling .imports on a module. A component, does not provide this method. Was there any reason behind doing that? I tried to use modules for my implementation, but I realised I needed interface types and I am somewhat dissappointed that I cant access a components imports like a modules imports.
Just not yet implemented I believe: https://github.com/bytecodealliance/wasmtime/issues/4593
thats correct, it is not implemented currently. You can provide component imports via a component::Linker, but there is no way to access them.
We will get around to implementing it at some point but right now it isnt high on our priorities. If you can share your use case, that could help motivate moving it up in priority
Thank you for your answers. I dont think that my use case is too interesting for you. I am writing my master thesis in the field of embedded distributed computing. So I will basically work full time on this for the next 7-8 months on this topic. I thought about using webassembly and tried to understand webassembly by reading parts of the specifications and some papers about it. I recently started using wasmtime and I thought it seems perfect, but realised, that I would need the interface types from the component model. I would also consider contributing to wasmtime / changing some code, but right now I feel like this is somewhat out of scope and I would have to try again in the future. It would be nice if someone of you could give their opinion about the feasability of it.
Just some more thoughts about the plan in my head: Distributed computing should be as easy as possible. Exporting a function makes the host register it to one main node that manages the control flow. The main node can simply call any function and use their return values. Instead of sending large structures (interface types like lists or records), the hosts would usually just send "references" to these types such that these values can be used to do other function calls. If a host does require such a reference for computation, it would pull the data from the owner and provide it to the wasm runtime. So the main work for distributed computing is done in the hosts while the code that is compiled to wasm does not need to worry too much about distributed computing.
Sorry that the message got that long. I got kind of hyped the last week about wasm, but at the end I just hit a wall when I realised interface types are not yet widly supported. So can someone confirm: What I thought is likely pretty hard to implement right now, correct? :/ Maybe I could work on it in the future as a side project.
I hope what I wrote was not too confusing.
ok. that seems like the sort of thing you could accomplish with wasmtime and the component model, yes. afaik, there are only two host implementations of the component model at this time: wasmtime, and the jco transpile
javascript generator https://github.com/bytecodealliance/jco/
you might end up having better luck using jco because it generates js structures which are more amenable to reflection? not clear
hmm, I am not too convinced about using javascript for embedded programming. Apart from a couple of lines of code for wasm, I never used it. As far as I know it introduces quite a bit of overhead. Additionally, I also cooperate with two rather large companies for my master thesis and I am not sure if I can convince them that javascript is the way to go (my thesis is part of a larger project).
Anyways, I will take a look at jco in the afternoon. I will definitly write some pages about wasm and maybe I can even manage to build a small prototype or demonstrator with it.
Last updated: Dec 23 2024 at 14:03 UTC