[whatwg/streams] Provide a way to communicate the current optimal write size (#1016)

Currently `desiredSize` on ReadableStreamDefaultController and WritableStreamDefaultWriter always reflects the amount of queue space available. This is connected to how much buffering we use. However, a sink may have 324KB of space available in some internal buffer, invisible to the streams API and consumers of the streams API. It would be nice if writers to the stream could know that they should aim to write a 324KB chunk. Increasing the highWaterMark of the WritableStream doesn't do anything useful in this situation.

In another case, you might have an API where is optimal to write in 64KB chunks, but the value of desiredSize would go down when the queue is full, leading to writing sub-optimal small chunks.

One solution would be to provide a way that underlying sinks could override the value of `desiredSize`. An alternative would be to provide a differently-named attribute that hinted the optimal chunk size to use right now.

-- 
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/1016

Received on Friday, 13 September 2019 07:47:01 UTC