jco
jco copied to clipboard
preview2 shim browser filesystem writeViaStream has O(n^2) overhead due to repeatedly concatenating buffers
See https://github.com/bytecodealliance/jco/blob/f92eaa519f6db46e02777cf0ac9674025d578d87/packages/preview2-shim/lib/browser/filesystem.js#L123, when this is invoked repeatedly to do a lot of small appends, there is O(n^2) slowdown due to repeatedly concatenating buffers. 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.