Re: [streams] Custom tee function (#401)

In my previous comment I meant the current tee() spec.

>From you original post in this thread:

> If the JS were able to provide a tee implementation that didn't depend on creating a clone

Which is already stated in the stream spec.  See:

> Note that the chunks seen in each branch will be the same object. If the chunks are not immutable, this could allow interference between the two branches. (Let us know if you think we should add an option to tee that creates structured clones of the chunks for each branch.)

The cloning issue is different from what you mention here, though:

> What happens when you have vastly different consumption rates for the two streams? If one reader is 1 gigabyte ahead of the other, do you exert back pressure?

This is really the crux of the problem and AFAICT not optimizable in the general js case.

@martinthomson can you explain under what scenario this can actually be optimized not to consume memory equal to the difference in consumption?  Particularly for a js defined stream (which you seemed focused on in your original post).

The only optimization that seems possible is if its a dom produced stream reading from a file.  But I don't see how js defined custom tee() would help with this.

> the requirement for SameObject on the chunks would need to be relaxed to accomplish this

I'm really confused what you want.  The initial comment was asking for no clone, but this seems to be suggesting you do want a clone.

I do agree allowing the tee's to be different objects would help with the from-disk-optimization, at the expense of penalizing all other tee's.  Perhaps some kind of copy-on-write chunk mechanism could support both.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/401#issuecomment-151320732

Received on Tuesday, 27 October 2015 00:14:03 UTC