Skip to content

Request: Support sharing mutable memory between host and guest #594

@AaronFriel

Description

@AaronFriel

It looks like the WASI specification with the component model / interface types specification as written today does not support a shared memory type. Mutable shared memory is an important capability for many kinds of software that have tight bounds on latency and/or would benefit from zero-copy IO, ranging from:

  • Virtual machines and emulators
  • High performance computing, especially networking and message passing interfaces
  • Databases software, especially with mmap backed buffers from the host
  • Video and audio streaming, as zero copy IO reduces latency and jitter, memory subsystem overhead

In fact, the current design of the WASI specification makes it more difficult to share memory between host and guest as compared to pre-component model specification, by constraining input & output codegen to specific named types.

There are many ways to address this gap, e.g.:

  • If certain types, like list<T> supported being declared as a borrow<list<T>>. In Rust, this would be received as a &mut [T], in JavaScript a TypedArray, and so on.
  • A dedicated shared buffer type created instead
  • WASI IPC module #49
  • Support for an MVP of mmap #304

For a concrete use case, the Microsoft AI Controller Interface project uses shared memory to reduce latency on mutating moderately large arrays of floating point numbers representing the logits of a large language model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions