Skip to content

useMemoryFS fd_write has O(n^2) slowdown due to repeated concatenation of buffers #12

@TerrorJack

Description

@TerrorJack

See

if (requiredLength > file.node.content.byteLength) {
, fd_write always allocates a new buffer and copies over old content when appending content, which results in O(n^2) slowdown when doing a lot of small writes.

I noticed this when working on bjorn3/browser_wasi_shim#95; almost all wasi in-memory vfs implementation written in js/ts I can find has the same issue, including this one.

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