Re: [whatwg/streams] "Set totalSize to totalSize + pair.[[size]]." (#582)

For the record, there are three "reasonable" expectations about desiredSize that I have been considering:

1. desiredSize = HWM - (total size of chunks in queue), subject to rounding errors.
2. desiredSize - HWM == exactly 0 when the queue is empty.
3. desiredSize monotonically decreases as long as there are no calls to read(), and monotonically increases as long as there are no calls to enqueue().

The current specced behaviour satisfies all three expectations (there are rounding errors in 1., but they conform exactly to expectations).

The running total behaviour as implemented in the reference implementation and Chromium satisfies expectation 3, can have unexpected rounding errors on 1. and fails 2. when the size of the chunks varies by a very large magnitude.

The workaround I proposed above can fail 3., can have unexpected rounding errors in 1 and passes 2.

Resetting to zero when the queue becomes empty also can fail 3., have unexpected rounding errors in 1 and passes 2.

I find myself flip-flopping between two positions:
1. Any of these is fine. If you have extreme variations in chunk size then you're going to have a bad time. This being the case, we should stick with the running total behaviour.
2. Having desiredSize != HWM with an empty queue is just too weird, and so we should switch to "reset to zero" behaviour.

-- 
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/582#issuecomment-273702677

Received on Thursday, 19 January 2017 07:40:29 UTC