-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/wasm components #630
Conversation
So I've hit a bit of wall here where it looks I'll need to do something drastic to get component support working the way I think it should. A little conext: A wasm component has, as it's definition, a |
Hey @superchris first things first: it's awesome that you start tackling this. Having good component support is the next most pressing thing for wasmex to have. thank you 💜 I started looking into components but didn't had the time yet to start a real prototype - so I'm afraid my understanding of how components work isn't perfect yet. My (maybe naïve?) understanding of components was that they are more or less normal wasm modules with added .wit type definitions. Those type definitions could be "used" by wasmex to read/write function results/params. I wasn't sure how that "using" of the WIT types could be done - my hope was to maybe have an elixir macro that defines proper elixir-structs, which wasmex then knows how to (de-)serialise to what the bytes the wasm module needs. Basically, like building our own bindgen. Coming from that understanding, I didn't get the part on why we need to link other NIFs or use the wasmtime bindgen. Can you elaborate there, please? I probably just don't know enough to fully understand the problem - so just dropping a link to the relevant docs for me to educate myself also works. If you're up for it, we could also just have a call and discuss/brainstorm possible approaches synchronous. :) |
Hey @tessi! Thanks for wasmex :) So the issue I am facing is that I will need to generate two kinds of bindings, one in rust, and another in Elixir. In my branch I the rust bindings I need are in |
@tessi I think after reading your comments again I understand what you are saying. Having our own Elixir bindgen would be amazing, I was trying to do a lazier approach because I was intimidated by making to do the lowering and lifting of elixir types into wasm memory. I probably am not facile enough with rust and the internals of wasm to be able to tackle the elixir bindgen idea just yet. Anyways, happy to talk if you'd like 😄 |
yay, i'm on UTC+2 so that isn't horribly far off. I'm currently on watch for the barely sleeping, feverish baby so today is not a good day to talk sync. But we'll find a time :) Not being very into wrangling bytes in rust shouldn't stop us. Maybe we can somehow expose the raw memory to elixir and write/read it from there. Not sure what's best, but we have options. I'll do some reading into wasmtimes bindgen and see how heavy it is. From what you wrote here, writing our own bindgen/wrapper/wit-type-serialiser still sounds like a good approach, if we can make it work - much easier to use than having to build a separate NIF and somehow link it 🤔 |
brainstorm idea: if we can implement wasmtimes bindgen! macro basically utilizes the Lift/Lower traits, which we can implement ourselves for elixir-structs instead of deriving it automatically from known rust types. |
Hey @tessi I got a little further in my implementation and at this point I've hacked things up to the point its a bit of a mess ;) I had to switch out the wasi library to new ones ( |
I did end up making some amount of progress after I decided to split off to another project at least temporarily. It's still got some hand coded plumbing I need to get rid of, but have several examples working with tests to at least prove out the approach. Code is here: https://github.com/launchscout/wasm_components_ex However after looking at wasmtime-rb where the beginning of component support has landed, I think their approach is better and would allow us to dynamically invoke functions on components without a separate nif lib per component as my current approach requires. I may try another PR based on it. In short, they convert ruby types back and forth to wasmcomponent val types in rust. This seems like a much smaller lift (pun intended :) ). I still think the lift/lower idea is a good one, just not quite sure how to start and how ambitious it is compared to the other approaches. Happy to pair some time @tessi if you'd like |
wow, cool! will have a look this evening - both, your examples as well as wasmtime-rb actually, i'm not too too set on a single idea as long as users don't have to learn rust/nifs (given they already have a .wasm component). I mean, if that's what's required we have to, but better not :) re pairing: I'm sure by now you're the subject matter expert on components :) happy to pair though. Let's arrange something in a private channel. How can I reach you best? bluesky/mastodon would be my favourites, mail works too |
Hey @tessi I just started trying to use BlueSky more I am @superchrisnelson.bsky.social |
@superchris thanks again for the call yesterday! was fun and it fuels more excitement for component support 🔥 |
That sounds awesome more experiments are the way to go. Eventually the best path forward will emerge :) |
@superchris this is great and I love to merge this (and iterate in separate PRs) 💜 |
Thanks again @superchris . This was a super cool feature for a first PR. Can't wait to see what comes next :) 💜 |
This is a draft PR to show how the progress is coming along for supporting web assembly components. Check out
wasm_components_test.exs
to see where things are at