“Online marketplace eBay has revealed how it boosted performance of a demanding web app by 50x using WebAssembly,” reports TechRepublic:

The “astonishing” speed-up after switching from a JavaScript-based to a largely WebAssembly-based web app was detailed by the eBay engineering team, who say the performance boost helped make it possible to build a highly-accurate barcode scanner as a web app… a feature it offers in its Android and iOS apps to allow sellers to scan items they are auctioning. “WebAssembly was different. It has tremendous potential, we just did not have the right use case. Well, that changed recently,” write the eBay software engineering team.

One of the advantages of WebAssembly (Wasm) is that it offers code portability for a variety of languages, allowing developers to take code they’ve written for other platforms and compile to WebAssembly so it can run in major web browsers. Consequently eBay was able to take the existing version of its barcode scanner written in C++ and compile that to Wasm using Emscripten, adopting the Docker and Node.js-based approach outlined here. After a few minor teething problems, the eBay team were able to run the barcode scanner in the browser, using a Worker thread and JavaScript glue code.
The Wasm-based scanner was able to process images of the barcode at 50 Frames per Second (FPS), compared to about 1FPS in an earlier JavaScript-based scanner eBay had tested, a speed-up the team described as “astonishing”.

Unfortunately, the Wasm code only successfully completed scans 60% of the time, because it wasn’t using the inbuilt APIs available for the C++ code to either autofocus or provide user tap focus for the center of the scanned object. eBay’s team ultimately ended up implementing three separate worker threads running the Wasm code, the open-source barcode reader ZBar, and their original JavaScript-based scanner code.

“The winning response (i.e. the first one to send a valid barcode) is sent to the main thread, and all workers are terminated… With three threads racing against each other, the success rate was indeed close to 100%.”

Share on Google+

of this story at Slashdot.

…read more

Source:: Slashdot