We Used WebAssembly To Speed Up Our Web Program By 20X (Case Study)

How We Used WebAssembly To Accelerate Our Internet Program By 20X (Case Study)

Robert Aboukhalil


It’s used outside the browser, for example as an efficient and flexible language for serverless computing.
But beyond just being”not JavaScript”, its distinguishing factor is that it is possible to compile code from languages such as C/C++/Rust (and much more! ) into WebAssembly and run them at the browser. Because WebAssembly is statically typed, utilizes a linear memory, and is stored in a compact binary format, so it is also extremely fast, and may eventually permit us to conduct code at”near-native” rates, i.e. at rates close to exactly what you’d get by running the binary on the control line. The capacity to leverage existing tools and libraries for use in the browser and the related possibility of speedup, are just two reasons that make WebAssembly compelling for the web.

To explore whether we could leverage WebAssembly to accelerate our internet app, we hunted for an tool which calculates QC metrics. We sought a tool written in C/C++/Rust that it was amenable to porting to WebAssembly.

After some research, we chose to go with seqtk, a commonly-used, open-source tool written in C which may help us assess the quality of sequencing information (and is more commonly used to manipulate those data files).

Architecture of this WebAssembly + WebWorkers implementation of fastq.bio (Big preview)
  • Fastq.bio source code (on GitHub)
  • An Abridged Cartoon Introduction To WebAssembly,” Lin Clark
  • We compare both the WebAssembly and JavaScript implementations using the metric of, to evaluate whether using WebAssembly did any good. Because both implementations use JavaScript for this purpose, we discount the time that it takes for generating graphs.