This week at Google I/O, Software Engineer Deepti Gandluri presented a session titled “WebAssembly for Developers.” In this session she presented new features for WebAssembly which have already been implemented in the current version of the Chrome Web browser. The proposed new features are WebAssembly Threads, SIMD, Implicit Caching and ReferenceTypes.
WebAssembly Threads extend the capabilities of the current browser-based Web worker thread architecture. As Gandluri said during her presentation, “The dark side of Web workers is that they do not share data between them.”
WebAssembly Threads, on the other hand, allow threads to access shared memory. The result is that now Web developers can write code that, for example, allows independent threads to concurrently render images across the main web page. Without the capabilities provided by WebAssembly Threads, threads need to “wait in line” to do the rendering. The performance gains can be significant.
Single Instruction Multiple Data (SIMD) allows a single instruction executed on a CPU to operate on multiple data instances, thus making overall execution time 2 to 5 times faster. SIMD is particularly useful for tasks such as in-browser video processing which typically requires massive amounts of CPU resources to do work.
Implicit Caching speeds up the time required to get WebAssembly code up and running in a browser. Using Implicit Caching, the WebAssembly binary gets recompiled on the browser to a CPU specific format once and then cached for repeated use. Before the introduction of Implicit Caching, recompilation of WebAssembly binaries happened repeated.
Google’s Vision for Web Assembly
According to Thomas Nattestad (Product Manager at Google), the new features are central to Google’s intention of positioning WebAssembly to increase performance and portability in the browser and enhance the power of browser-based computing to enable initiatives such of Progress Web Applications and new Web Capabilities. According to Nattestad, “If you can build in iOS, Windows, or IoT, you can build it in a browser.”