~ a boring technical blog ~

about me

My name is Ben Kelly. I’m a software engineer working on the DOM team at Mozilla.
See my Mozillians profile for more contact information.

Evaluating the Streams API’s Asynchronous Read Function

For a while now Google’s Domenic Denicola, Takeshi Yoshino, and others have been working on a new specification for streaming data in the browser. The Streams API is important because it allows large resources to be processed in a memory efficient way. Currently, browser APIs like XMLHttpRequest do not support this kind of processing.

Mozilla is very interested in implementing some kind of streaming data interface. To that end we’ve been evaluating the proposed Streams spec to determine if its the right way forward for Firefox.

In particular, we had a concern about how the proposed read() function was defined to always be asynchronous and return a promise. Given how often data is read() from a stream, it seemed like this might introduce excessive overhead that could not be easily optimized away. To try to address that concern we wrote some rough benchmarks to see how the spec might perform.

TL;DR: The benchmarks suggest that the Streams API’s asynchronous read() will not cause performance problems in practice.

written in mozilla,streams Read on →