Re: [whatwg/streams] Allow other specifications to create readable byte streams (#1121)

> It takes a mandatory autoAllocateChunkSize.

My only concern with making this mandatory is the potential to introduce developer-visible side effects that prevent optimizations. At an abstract level `autoAllocationChunkSize` should be set to `options['bufferSize']` the same way `highWaterMark` is already. The pull algorithm would then call the OS directly with the automatically allocated buffer. This implies that the difference between the `byteLength` of the `Uint8Array` view and the underlying `ArrayBuffer` is the amount of space not used by the incoming data and that this might be visible to developers.

Due to the way the pull algorithm is implemented in Chromium there is a mandatory memory copy when receiving bytes and so the `ArrayBuffer` is currently always exactly the same length as the `Uint8Array`. Based on my understanding of how fetch() is implemented the same is true there. Having the Streams implementation automatically allocate these buffers instead would mean always allocating larger buffers than necessary with potentially developer-visible side effects.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1121#issuecomment-814473948

Received on Tuesday, 6 April 2021 22:22:36 UTC