Re: [whatwg/streams] ReadableStream.from(asyncIterable) (#1083)

It depends on your definition of "serious performance benefits".

I went away and implemented it, and in a microbenchmark
```
ReadableStream.from([chunk]).pipeTo(writable);
```
takes 83μs with the array optimisation and 139μs without it.

Obviously with a larger array the performance difference would be much more striking, but I mostly care about the performance of the single-chunk case.

Unfortunately the presence of thenables in the array complicates things. I didn't go to the trouble of matching the behaviour that the ES standard gives to them. It would require falling back to an async algorithm the first time we see a thenable. The performance impact would not be significant in the normal case, but the implementation would be messy. I don't actually like the behaviour of following the thenable, so I'd prefer to ignore the problem, but I don't think we can.

My draft CL is at https://chromium-review.googlesource.com/c/chromium/src/+/3023854.


By the way @MattiasBuelens this is some amazing specification work. I didn't find a single issue while implementing.

-- 
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/1083#issuecomment-879373078

Received on Tuesday, 13 July 2021 20:17:31 UTC