Stream: git-wasmtime

Topic: wasmtime / PR #14252 wasi: read synchronously in FileInpu...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 31 2026 at 23:33):

composia-dave opened PR #14252 from composia-dave:wasi-file-input-stream-blocking-read to bytecodealliance:main:

FileInputStream::read in the Idle state always spawns a background read and answers an empty chunk, even when the file was opened under WasiCtxBuilder::allow_blocking_current_thread(true) — the flag that already makes the descriptor-level read, write, stat etc. run on the current thread (File::run_blocking / as_blocking_file). The blocking_read path honours it, but a guest using the non-blocking read (wasi-libc's stream reads, e.g. CPython's file I/O) gets a number of empty answers that depends on how quickly the blocking pool runs the task — i.e. on host load.

That is guest-observable: for a Wizer-style pre-initialization snapshot (componentize-py) the guest's read-loop iteration count ends up in the heap, and two runs of the same snapshot differed by 42 bytes on a quiet machine and 14.8 MB with a concurrent build running. With this change, a file opened under the flag is read synchronously in read too, and that divergence is gone (measured against 46.0.1 with this same hunk; ported here unchanged — the surrounding code is identical on main).

Behaviour for files NOT opened under the flag is unchanged (the background read stays). The change reuses as_blocking_file and the existing blocking_read helper, and delivers the first chunk from the resulting ReadState directly, keeping position and the Idle/DataAvailable transitions the same as the existing DataAvailable arm.

The wider context (what a pre-init snapshot still observes through wasmtime-wasi once random, clocks and env are pinned) is #14251.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 31 2026 at 23:33):

composia-dave requested pchickey for a review on PR #14252.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 31 2026 at 23:33):

composia-dave requested wasmtime-wasi-reviewers for a review on PR #14252.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 01 2026 at 02:49):

github-actions[bot] added the label wasi on PR #14252.


Last updated: Sep 20 2026 at 18:08 UTC