arrows5592961280100570571orig

Mozilla gives WebAssembly a parallelism boost

Mozilla is improving compilation in both the WebAssembly portable bytecode format and asm.js JavaScript subset by leveraging parallelization in its Firefox browser.

Using parallelism, an engineer at Mozilla worked on reducing startup times in asm.js programs in the browser. "As our JavaScript engine, SpiderMonkey, uses the same compilation pipeline for both asm.js and WebAssembly, this also benefitted WebAssembly compilation," said the engineer, Benjamin Bouvier.

Parallelization, he said, consists of splitting a sequential program into smaller independent tasks, then running them on different CPUs. "If your program is using N cores, it can be up to N times faster."

Mozilla's goal is to make more work run in parallel by taking out the SpiderMonkey middle-level intermediate representation (MIR) from the main thread, as well as removing and code generation. "Instead of emitting a MIR graph as we parse the function's body, we emit a small, compact, pre-order representation of the function's body," Bouvier said. "In short, a new IR. As work was starting on WebAssembly (wasm) at this time, and since asm.js semantics and wasm semantics mostly match, the IR could just be the wasm encoding, consisting of the wasm opcodes plus a few specific asm.js ones. Then, wasm is translated to MIR in another thread." Instead of parsing and generating MIR in a single pass, wasm IR would be parsed and generated in one pass, while the MIR would be generated out of the wasm IR in another pass.

While Mozilla found compilation much faster in its new scheme, it still can be a pain, especially in mobile applications, according to Bouvier. "This is mostly due to the fact that we're running a whole multi-million-line codebase through the back end of a compiler to generate optimized code," he said. "Following this work, the next bottleneck during the compilation process is parsing, which matters for asm.js in particular, which source is plain text. Decoding WebAssembly is an order of magnitude faster though, and it can be made even faster." More load-time optimizations are coming, Bouvier said.

WebAssembly is a highly touted attempt to improve the Web's performance through a portable code format running in browsers at native speeds. It has been supported by browser vendors Mozilla, Google, Microsoft, and Apple.

IDG Insider

PREVIOUS ARTICLE

« Feds seek public input on the future of IoT

NEXT ARTICLE

Solar-powered aircraft lands in Silicon Valley »
author_image
IDG News Service

The IDG News Service is the world's leading daily source of global IT news, commentary and editorial resources. The News Service distributes content to IDG's more than 300 IT publications in more than 60 countries.

  • Mail

Recommended for You

Trump hits partial pause on Huawei ban, but 5G concerns persist

Phil Muncaster reports on China and beyond

FinancialForce profits from PSA investment

Martin Veitch's inside track on today’s tech trends

Future-proofing the Middle East

Keri Allan looks at the latest trends and technologies

Poll

Do you think your smartphone is making you a workaholic?