-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default readableStrategy HWM to 0? #777
Comments
+1 to changing this. The disadvantages seem fine. I don't think we need the same defaults for readable vs. transform since we already know the readable strategy is very nich for transform streams. The mechanics of how to do this are harder, hmm. I'm no longer convinced we're doing the right thing for non-transform streams, actually :(. With fresh eyes, I think I would have preferred that only Right now instead, providing I think we do Practically I think this looks like your 3. |
I like your suggestion better so that is what I am working on. I have run into an interesting problem with this test: promise_test(() => {
const ts = new TransformStream();
const writer = ts.writable.getWriter();
writer.close();
return Promise.all([writer.closed, ts.readable.getReader().closed]);
}, 'TransformStream: by default, closing the writable closes the readable (when there are no queued writes)'); This test never completes with HWM 0 because the promise returned by TransformWriterDefaultSink's start() method never resolves. I think this is pretty clearly bad behaviour. Strictly speaking, this has always been broken, but making the readable HWM default to 0 makes it a lot more obvious. I am looking at revising the state machine so that we don't need to delay returning from start(). |
PR #786 fixes the test in my last comment. |
The reduces "buffer bloat" in pipes. The most significant change is that now be default transform() is called until something is read. In normal use, TransformStream will be used in a pipe and a transform() will be triggered immediately to fill the queue in the following writable. So the difference from the point of view of everyday use is minimal. If the highWaterMark passed to the TransformStream constructor is undefined (or not present) it will be changed to zero before passing it on to the ReadableStream constructor. Some tests assumed that transform() would be called without anything being read and so have been fixed. In most cases the tests were fixed by supplying an explicit highWaterMark to the constructor. Verify that default strategies have the expected values. Closes whatwg#777.
This reduces "buffer bloat" in pipes. The most significant change is that now by default transform() is called until something is read. In normal use, TransformStream will be used in a pipe and a transform() will be triggered immediately to fill the queue in the following writable. So the difference from the point of view of everyday use is minimal. If the highWaterMark passed to the TransformStream constructor is undefined (or not present) it will be changed to zero before passing it on to the ReadableStream constructor. Some tests assumed that transform() would be called without anything being read and so have been fixed. In most cases the tests were fixed by supplying an explicit highWaterMark to the constructor. Verify that default strategies have the expected values. Closes #777.
Currently a TransformStream with the default strategies adds two chunks of buffering to any pipe. I'd like to reduce that as much as possible. We can't reduce the HWM of the writableStrategy to 0 because it would have permanent backpressure preventing the pipe from working. However, reducing the HWM of the readableStrategy to
0
will work.Advantages:
Disadvantages:
I've thought of three variations for how to treat the third argument of TransformStream:
{highWaterMark: 0}
. Anything else is passed to the ReadableStream constructor unchanged.{highWaterMark: 0}
. Anything else is unchanged.{highWaterMark: 0}
. Anything else that doesn't already have ahighWaterMark
property gets one added with value0
.I think I prefer the first one.
The text was updated successfully, but these errors were encountered: