Stream: wasmtime

Topic: Example on how to use `Func::call_concurrent`?


view this post on Zulip Lorenzo (Jan 08 2026 at 01:06):

Hi everyone. I've updated wasmtime from v27 to v40 aiming to call component functions concurrently (as part of the same Store instance, with dynamically linked components). e.g. say I have WASI CLI A and WASI CLI B and want to run both components concurrently that share the same store and can also communicate between each other.

I'm trying to implement Func::call_concurrent -- does anyone know if there are any examples for this? I'm not sure if it's possible to do what I'm thinking, perhaps I'd need multiple Stores and to manage the data replication from the host?

view this post on Zulip Alex Crichton (Jan 08 2026 at 15:21):

Most examples at this time will be throughout Wasmtime's test suite, we don't have dedicated examples for this just yet.

You'll be able to use one store and you'll be using run_concurrent to get an Accessor which from there you can call call_concurrent

view this post on Zulip Lorenzo (Jan 08 2026 at 23:28):

I see. That sounds good, thanks!

view this post on Zulip Lorenzo (Jan 11 2026 at 02:23):

I've tried a few different things so far but I only see the components running serially rather than concurrently. It just picks one of 2 components and runs that indefinitely.

Here's the example component. I'm running two instances of this to test concurrency.
image.png

So I'd expect to see 2 different program numbers appearing in stdout every second. But only one component is running.

image.png

I've tried different ways to join the tasks, for example like below taken from wasmtime tests.

image.png

Do I have the wrong idea here, Is it not possible to run 2 CLI programs in WASI concurrently? or am I just doing it wrong?

view this post on Zulip Alex Crichton (Jan 11 2026 at 22:31):

You're running into this clause of the documentation which is that using tokio in the guest induces "store blocking behavior" which means concurrency doesn't work inside of run_concurrent

view this post on Zulip Alex Crichton (Jan 11 2026 at 22:31):

Unfortunately there's no great solution for that at this time, it's one that we need to work on within Wasmtime itself

view this post on Zulip Lorenzo (Jan 11 2026 at 22:49):

Oh ok. Thanks for letting me know! Looks like the fix is planned to be included with wasip3, is that right? I'd be happy to help with implementing this.

view this post on Zulip Victor Adossi (Jan 12 2026 at 16:50):

Hey just wanted to note @Lorenzo , a doc comment would probably be appreciated if you were willing to contribute one in the meantime!

If you went to the rust docs and would have benefitted from seeing a guide to how to use call_concurrent maybe some docs near there would be useful?

view this post on Zulip Lorenzo Fontoura (Jan 13 2026 at 00:05):

Opened here https://github.com/bytecodealliance/wasmtime/pull/12330 :)

We read every piece of feedback, and take your input very seriously.

view this post on Zulip Victor Adossi (Jan 13 2026 at 19:59):

Amazing job @Lorenzo Fontoura!


Last updated: Feb 24 2026 at 04:36 UTC