Re: [whatwg/streams] Require pipeTo() to properly use the destination queue (#720)

ricea commented on this pull request.



> @@ -642,10 +642,15 @@ ReadableStream(<var>underlyingSource</var> = {}, { <var>size</var>, <var>highWat
        * While WritableStreamDefaultWriterGetDesiredSize(_writer_) is ≤ *0* or is *null*, the user agent must not read
          from _reader_.
        * If _reader_ is a <a>BYOB reader</a>, WritableStreamDefaultWriterGetDesiredSize(_writer_) should be used to
-         determine the size of the chunks read from _reader_.
-       * Otherwise, WritableStreamDefaultWriterGetDesiredSize(_writer_) may be used to determine the flow rate
-         heuristically, e.g. by delaying reads while it is judged to be "low" compared to the size of chunks that have
-         been typically read.
+         determine the size of the chunks read from _reader_. Otherwise, the desired size may be used to determine the
+         flow rate heuristically, e.g. by delaying reads while the desired size is judged to be "low" compared to the
+         size of <a>chunks</a> that have been typically read.
+       * After taking into account these backpressure signals, reading and writing should be done as fast as possible;
+         other signals should not be used to delay the continual reading/writing.

I kinda do want to use "other signals". Let's say I have

```javascript
fetch(url).then(response => {
  response.body
    .pipeThrough(new TextDecoder())
    .pipeTo(tag.writable);
});
```

`tag.writable.desiredSize` is 4096 characters. The TextDecoder transform just counts objects, so it will happily pass through any chunk of bytes as a single object. The system as a whole has enough information to optimise the size of chunks read from `response.body`, but WritableStreamDefaultWriterGetDesiredSize(TextDecoder.writable) is just returning the number 1. 

In the general case, I'd like to use global information to optimise my pipes, and "other signals" might be too restrictive.

How about "reading should not be delayed for reasons other than optimizing chunk size" ?

-- 
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/pull/720#pullrequestreview-29944251

Received on Thursday, 30 March 2017 09:40:43 UTC