Stream: wasmtime

Topic: ✔ (Host)InputStream/OutputStream async -> sync


view this post on Zulip Victor Adossi (Aug 22 2023 at 13:53):

In doing some experimentation round upgrading from wasmtime 11.0.1 to 12.0.0, I found that InputStream was converted to HostInputStream and it looks like the read/write are now synchronous.

I'm wondering if one of the following cases is true:

  1. Runtime embedders are expected to lean sync for now
  2. Runtime embedders are expected to do some conversion somehow

If (2) is the case, the easiest way I could think of was a tokio::runtime::Runtime & block_on, but that doesn't feel quite right...

view this post on Zulip Dan Gohman (Aug 22 2023 at 14:00):

HostInputStream is still async; HostInputStream::read is meant to be non-blocking, and there's a HostInputStream::ready for waiting for data which is an async fn.

view this post on Zulip Lann Martin (Aug 22 2023 at 14:04):

It isn't entirely obvious from the trait docs; is the intent there that you can straightforwardly map it to a AsyncRead?

view this post on Zulip Lann Martin (Aug 22 2023 at 14:10):

i.e. attempt to read, if you get ([], Open) back then await ready or something?

view this post on Zulip Alex Crichton (Aug 22 2023 at 14:13):

straightforward, no, easy, yes -- see AsyncReadStream

view this post on Zulip Alex Crichton (Aug 22 2023 at 14:13):

er that may not exist in the 12.0.0 release actually, so ignore me

view this post on Zulip Lann Martin (Aug 22 2023 at 14:16):

no it is: https://github.com/bytecodealliance/wasmtime/blob/v12.0.0/crates/wasi/src/preview2/pipe.rs#L146

view this post on Zulip Alex Crichton (Aug 22 2023 at 14:17):

oh our docs.rs builds may have failed as they're still at 11.0.1

view this post on Zulip Alex Crichton (Aug 22 2023 at 14:20):

well in any case that's the rough idea, adaptation via tokio is provided with Async{Read,Write}Stream

view this post on Zulip Victor Adossi (Aug 23 2023 at 01:22):

Thanks for the clarification @Dan Gohman @Lann Martin @Alex Crichton , I see how it was meant to be used now!

I wasn't thinking of that interplay between ready and HostInputStream::read

view this post on Zulip Notification Bot (Aug 23 2023 at 01:22):

Victor Adossi has marked this topic as resolved.

view this post on Zulip Notification Bot (Aug 23 2023 at 12:59):

Tei Roberts has marked this topic as unresolved.

view this post on Zulip Notification Bot (Aug 23 2023 at 12:59):

Tei Roberts has marked this topic as resolved.

view this post on Zulip Freja Roberts (Aug 23 2023 at 13:00):

Sorry, about that, thought the checkmark meant join as I didn't see any tooltip :sweat_smile:

view this post on Zulip Pat Hickey (Aug 23 2023 at 16:33):

this is still a work in progress https://github.com/bytecodealliance/wasmtime/pull/6877

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

view this post on Zulip Pat Hickey (Aug 23 2023 at 16:34):

the short story is: backpressure design is being revised to take into account that any call with a list<bytes> is going to consume the resources of the callee, so the callee has to explicitly permit how much that is allowed to consume

view this post on Zulip Pat Hickey (Aug 23 2023 at 16:35):

and also, flushing is a way to request & observe the completion of a write, since the write itself is non-blocking it cant report that it failed if that happens after the call is over. the explicit flush call allows userland to wait for completion to produce an error, or guarantee that it succeeded


Last updated: Dec 23 2024 at 14:03 UTC