wasmtime-rb icon indicating copy to clipboard operation
wasmtime-rb copied to clipboard

WASM components

Open sandstrom opened this issue 2 years ago • 8 comments

I noticed the recent update to the readme for wit-bindgen.

It mentions that the wasmtime crate now has support for components: https://github.com/bytecodealliance/wit-bindgen/blob/main/README.md#host-runtimes-for-components

There are also these docs (with examples for other languages): https://component-model.bytecodealliance.org/language-support.html

Just wanted to check in and see if this is already supported in wasmtime-rb, or if there are plans to support it in the future.

sandstrom avatar Feb 01 '23 16:02 sandstrom

Hey @sandstrom, unfortunately Wasm components are not currently supported in the Ruby bindings.

My understanding (could be outdated things are moving fast!) is that we're still at least a couple months away from the spec being stable. Thus I have no immediate plans to look into it, but happy to provide support if someone wants to work on it.

jbourassa avatar Feb 01 '23 22:02 jbourassa

I was just about to come in to say something similar :) (For context, I work closely with the Wasmtime time)

We're almost to a place with the component model where it makes sense to start thinking through how to componentize all of the various projects, but we're not quite there yet. If folks want to play around with the tooling, happy to see that, but there's still one chunk of work that needs to be done before we start encouraging people to really dig in.

linclark avatar Feb 01 '23 22:02 linclark

Thanks for the update @jbourassa and @linclark 🙏🏻

sandstrom avatar Feb 02 '23 09:02 sandstrom

It seems like this might be worth looking at again now that WASI P2 has shipped. Love to see component support for ruby!

superchris avatar Feb 20 '24 16:02 superchris

Is this on anyone's radar right now?

Very much not saying I have funds available (I probably don't), but if I could find some, is there anywhere I could direct them to bump this up someone's priority queue? 😅

(I'd love to help out with implementation but I have negative free time right now.)

jeffparsons avatar Sep 10 '24 00:09 jeffparsons

Is this on anyone's radar right now?

To my knowledge this isn't in anyone's radar right now unfortunately. However, if there's anyone interested or has the time to start contributing in this direction, I'm happy to provide support to get this work started.

saulecabrera avatar Sep 10 '24 10:09 saulecabrera

Hey, I'm working on trying to add some component support to the elixir wasmtime wrapper, wasmex. If I make any progress, my guess is a lot of the rust code will be similar hopefully? I'll at least try to investigate and share whatever I can.

superchris avatar Sep 10 '24 19:09 superchris

If none one has picked it up in 2 weeks, I could take a stab at it, or at least get the ball rolling. I do not have an immediate use case for it but I've been meaning to play around with Wasm components.

jbourassa avatar Sep 10 '24 19:09 jbourassa

This Zulip thread may be relevant: https://bytecodealliance.zulipchat.com/#narrow/stream/217126-wasmtime/topic/wasmtime-py.20missing.20peices

Specifically the talk of extending the Wasmtime C API to handle Val etc.

Maybe worth syncing up with yohe if anyone starts working on this?

jeffparsons avatar Oct 02 '24 21:10 jeffparsons

Maybe worth syncing up with yohe if anyone starts working on this?

We don't use the C API. I think it'll be worth collaborating eventually, but for now I'm focusing on producing a working integration. I've made some progress; I'm about to tackle the Val conversion.

I plan to use the untyped API, using the Val enum to convert between Wasm types and Rust types, and convert those Rust types back to Ruby objects (numbers, Hash for records, Array for lists, exceptions for errors, etc.). In other words: Wasm (canonical ABI) <-> Rust (Val) <-> Ruby (VALUE).

There should be a way to bypass the Rust Val and go directly to Ruby by implementing the lift/lower for Ruby's VALUE. We can try that once we have the simpler approach working.

I haven't looked into resources yet, but IIUC they bring extra considerations. I'll look at that next, once I have a basic end-to-end component working.

jbourassa avatar Oct 03 '24 13:10 jbourassa