uwasi
uwasi copied to clipboard
useMemoryFS fd_write has O(n^2) slowdown due to repeated concatenation of buffers
See https://github.com/swiftwasm/uwasi/blob/7adb986f4320cfda6d63d8291a8412f42483813d/src/features/fd.ts#L672, 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 https://github.com/bjorn3/browser_wasi_shim/pull/95; almost all wasi in-memory vfs implementation written in js/ts I can find has the same issue, including this one.