WebAssembly / WebAssembly/WASI

What does "flush" mean?

Open
#678 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-io S-inactive
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

What does "flush" mean? None of the WASI proposals currently define what it means to "flush" one of their output-streams.

wasi-io's documentation on flush says:

This tells the output-stream that the caller intends any buffered output to be flushed.

(Aside from the recursive definition 😜),
which buffers, to what extent, and with what goal?

Does this include OS buffers? I.e.

  • for filesystems, does this mean just performing a write? Or write+fsync? (Or does it require the use of O_DIRECT to bypass Linux' internal caching entirely 🤭?)
  • for sockets, does this mean just performing a send? Or send with TCP_NODELAY enabled? If a write has not been flushed, does that mean we actually should've sent it with MSG_MORE in the first place?

Or put differently, why should a consumer of a random output-stream of which it doesn't know its origin, call flush (or one of its cousins)? What guarantee do they have after their data has been flushed? Is it now persistently stored on disk? Has it been sent out on the wire? Has the peer successfully received it?

As far as I can see in wasmtime, none of wasi-filesystem, wasi-sockets & wasi-http use flush for anything other than waiting for a previous write to finish.

Apologies for the many question marks :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the wasi-io documentation for flush, then compare how wasmtime's wasi-filesystem, wasi-sockets, and wasi-http use it. Done means documenting a precise guarantee for flushing output streams, including which buffering layers and delivery or persistence guarantees are in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
networking, operating-systems
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.