Microsoft fine-tunes WebAssembly for Edge browser

By tweaking when the Chakra JavaScript engine parses WebAssembly functions, the Edge browser provides faster web app performance

Microsoft fine-tunes WebAssembly for Edge browser
clusternote (CC BY 2.0)

WebAssembly, the portable binary format for improving web application performance, is being tweaked by Microsoft for its Edge browser.

With the browser featured in the recent Windows 10 Creators Update, the Chakra JavaScript engine defers parsing WebAssembly functions until called; other engines parse functions at start time.

"We've observed startup time as a major headache for large web apps and have rarely seen runtime performance being the issue from our experiences with existing WebAssembly and asm.js workloads," said Limin Zhu, program manager for the Chakra team at Microsoft, this week. "As a result, a WebAssembly app often loads noticeably faster in Microsoft Edge."

WebAssembly MVP (minimum viable product) currently is supported behind the Experimental JavaScript Features flag in Edge, Zhu said. Aside from the Creators Update, Microsoft is tuning WebAssembly performance and working on remaining MVP features, including response APIs and structured cloning, before WebAssembly is turned on by default in Edge.

Users need to check the "Enable experimental JavaScript features" box in about:flags to turn on WebAssembly and other experimental features, such as SharedArrayBuffer. But a commenter on Microsoft's bulletin about WebAssembly was all for using the technology right now. "Seems like with all of the promise of WebAssembly, you would skip 'experimental' and go straight to 'replace my slow JavaScript with this incredible tech that is 20x faster and awesome than JS could ever hope to be.' In fact, Edge is now a WebAssembly browser."

WebAssembly has been lauded by JavaScript founder Brendan Eich, who has said it "becomes the safe native format for the Web" at some point. Recently moving to MVP status, WebAssembly has been backed by major browser vendors, including Apple, Google, Mozilla, and Microsoft.

The Creators Update also features other improvements, including saving memory by re-deferring functions. The capability descended from Internet Explorer's defer-parse function and defer-parse event handlers. With re-deferring, for every function Chakra deems would no longer get executed, the engine frees the bulk of memory that function holds to store metadata after pre-parsing, leaving the function in a deferred state as if it has been pre-parsed. Creators Update also extends just-in-time optimization to avoid creating heap arguments with the presence of formals as long as there are no writes to formals. Microsoft's web crawler estimates this optimization benefits about 95 percent of websites.

Copyright © 2017 IDG Communications, Inc.