Stream: wasmtime

Topic: Making it possible to plug components into others at runtime


view this post on Zulip Julia DeMille (Oct 29 2024 at 18:20):

Call me a mad scientist for this, if you'd like.

I want to be able to, at runtime, satisfy a component's imports, using the exports of another component I have instantiated, without having to manually define each resource and function.

This doesn't seem possible right now. I want to make it possible. I have never contributed to wasmtime, and this is certainly a huge project to take on as a first contribution. I've been looking under the hood, and have some ideas, but I figure I should probably announce my intentions so people know I'm up to this. That way, I can hopefully ask questions, too.

view this post on Zulip Chris Fallin (Oct 29 2024 at 18:27):

@Julia DeMille a very interesting goal for sure!

it might help (me, anyway) to define a little more what you mean by dynamically/at runtime: do you mean that you want to start a component C, without any of its imports initially, and as external resources are called/used, dynamically fill them in somehow? or do you mean that you want a reflection-like introspection ability from within one component, to load another component, work out what it needs to instantiate, and invent/plug that in before starting it? or something else?

view this post on Zulip Julia DeMille (Oct 29 2024 at 18:29):

Chris Fallin said:

or do you mean that you want a reflection-like introspection ability from within one component, to load another component, work out what it needs to instantiate, and invent/plug that in before starting it?

This one—when loading in a component, being able to supply the Linker with another component and have its exports satisfy whatever imports it can.

view this post on Zulip Chris Fallin (Oct 29 2024 at 18:30):

can you unpack "whatever imports it can" a bit -- is this a best-effort thing, where we're duck-type-matching things up and there may be some missing pieces? or is there a step in this system where we inspect the component, see it wants a world W with imports A, B, C, and put together exactly those?

view this post on Zulip Julia DeMille (Oct 29 2024 at 18:34):

Take the regex and validator components from the composing components page as an example. They would be matched based on the WIT, I suppose.

If there are imports not defined by a provided component, it would be on the user to define those before instantiating, as normal.

view this post on Zulip Joel Dice (Oct 29 2024 at 19:00):

Possibly relevant: https://github.com/rylev/wepl

From the Features section:

Satisfying imports with other WebAssembly Components

A repl for WebAssembly Components. Contribute to rylev/wepl development by creating an account on GitHub.

view this post on Zulip Julia DeMille (Oct 29 2024 at 19:00):

Joel Dice said:

Possibly relevant: https://github.com/rylev/wepl

Will take a look, thanks

view this post on Zulip Julia DeMille (Oct 30 2024 at 01:16):

That crate uses wasm_compose, which has been superseded by wac. I guess I could try to work out how wac works.

WebAssembly Composition (WAC) tooling. Contribute to bytecodealliance/wac development by creating an account on GitHub.

view this post on Zulip Ralph (Oct 30 2024 at 09:11):

it's all just code.

view this post on Zulip Julia DeMille (Nov 01 2024 at 05:25):

It looks like plug in the wac-graph crate is the most notable function. It's doing... effectively what I planned to do?

WebAssembly Composition (WAC) tooling. Contribute to bytecodealliance/wac development by creating an account on GitHub.

view this post on Zulip Julia DeMille (Nov 01 2024 at 05:26):

It is using a graph instead of wasmtime's linker model, though. Still, shouldn't be terribly hard to adapt.

view this post on Zulip Lann Martin (Nov 01 2024 at 12:44):

Yes, wac plug does what it sounds like you're trying to do except statically, producing a new component. Based on my (limited) understanding of the wac-graph code I'm not sure that it will be directly translatable to the wasmtime Linker, but others might have a better understanding there.


Last updated: Nov 22 2024 at 16:03 UTC