Stream: git-wasmtime

Topic: wasmtime / PR #11591 chore(wasi-io): Set max chunk size f...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 19:00):

ThorstenHans opened PR #11591 from ThorstenHans:chore/wasio-streaming-chunksize to bytecodealliance:main:

While moving vast amounts of data using wasi:io streams, we found the existing max chunk size of 4KB adding a lot of overhead. To reduce the number of chunks that one must create, this PR changes the max chunk size from 4KB to 64KB for all blocking write operations.

Here a simple table outlining how many chunks are required based on max chunk size being either 4KB or 64KB:

File Size No. of Chunks (4 KB) No. of Chunks (64 KB)
16 KB 4 1
100 KB 25 2
1 MB 256 16
10 MB 2,560 160
100 MB 25,600 1,600
1 GB 262,144 16,384
10 GB 2,621,440 163,840
100 GB 26,214,400 1,638,400

I'll leave this in a draft state for now and will collect additional data on performance improvements

view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 22:20):

pchickey commented on PR #11591:

The blocking-write-and-flush chunk size is specified in the wasi-io spec, not in wasmtime, so we actually can't make this change without a breaking change to Wasi, which won't happen at this point because streams are completely redone as part of the component model as part of Wasi 0.3.

Basically, blocking-write-and-flush is a convenience method that exists primarily to make sure its always possible to write a debug message without getting any sort of protocol right. Its not meant to be the fast path. Instead, you should use check-write, write, and polling on a pollable in order to get the maximum performance out of an output-stream. So, please check if you can start using a larger chunk size when switching to that part of the interface. We have a lot more flexibility with how those methods are implemented.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 03 2025 at 12:51):

ThorstenHans commented on PR #11591:

@pchickey thanks for the feedback.

the blocking apis are actually used in a 3rd party dependency on the guest side. I'll reach out to one of the maintainers to discuss and suggest the change you mentioned.

Q: You mentioned the chunk size being "specified" in the wasi-io spec, I can only find 4096 being referenced in comments: https://github.com/WebAssembly/wasi-io/blob/73222408bd3de90c8a9144c9ece02bb606c834f6/wit/streams.wit#L154

Any other places you can point me to?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 03 2025 at 16:01):

pchickey commented on PR #11591:

The comments are the spec, yes.


Last updated: Dec 06 2025 at 06:05 UTC