You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to start this issue to hash out the design of how component function calls should work. Currently Wasmex.Components.call_function executes function calls and returns results synchronously, vs Wasmex.call_function for core wasm (non-component) modules is always async and returns results by sending a message to the calling process. I'd love to have component function calls remain synchronous where possible, but in the case of components which have imports this becomes no longer possible. The options in my mind are:
Make call_function async and create an exec_function which returns immediately. Would also need a way in the use Component macro to specify whether the generated wrapper functions should be sync or async.
Make component function calls always async with no option for sync
???
I'm leaning towards 1. It's pretty nice to be able to directly invoke a function and get a result where possible, but alas I don't think this will be possible when functions are imported (ie calling back into elixir from a wasm component).
I'd love to have component function calls remain synchronous where possible
why? 🙃
but in the case of components which have imports this becomes no longer possible
true! And because of that my feeling is to be consistent (with regular Wasm and import-components) and always use async calls. IMO consistency is good for us - wasmex is already quite a complex project, let's keep the number of different implementations of a single functionality (-> function call) small.
Outside of consistency and less overall API surface we have to maintain, I think this plays nicely with the BEAM too. Normally, NIF calls shall return fast (or it's a "dirty NIF" - see: https://www.erlang.org/docs/25/man/erl_nif and ctrl+F for "dirty"). I'd love to avoid that.
So IMO, lets go route 2
Make component function calls always async with no option for sync
Caveat: We didn't benchmark wasmex yet (a thing I want to do - especially if my ElixirConfEU talk was accepted). MAYBE direct (non-async) calls are much faster?! if so, we MIGHT want to reconsider :) But even if, it has the drawback that the user needs to know implementation details like whether a function calls into an import or not. This alone makes it quite a footgun in my opinion.
I wanted to start this issue to hash out the design of how component function calls should work. Currently
Wasmex.Components.call_function
executes function calls and returns results synchronously, vsWasmex.call_function
for core wasm (non-component) modules is always async and returns results by sending a message to the calling process. I'd love to have component function calls remain synchronous where possible, but in the case of components which have imports this becomes no longer possible. The options in my mind are:call_function
async and create anexec_function
which returns immediately. Would also need a way in theuse Component
macro to specify whether the generated wrapper functions should be sync or async.I'm leaning towards 1. It's pretty nice to be able to directly invoke a function and get a result where possible, but alas I don't think this will be possible when functions are imported (ie calling back into elixir from a wasm component).
Thoughts (@tessi, @RoyalIcing, etc)?
The text was updated successfully, but these errors were encountered: