arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1901.09056cs.PL
收藏

不那么快:分析WebAssembly与本机代码的性能

Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code

Abhinav Jangda, Bobby Powers, Emery Berger, Arjun Guha

摘要:

所有主要的Web浏览器现在都支持WebAssembly,这是一种低级字节码,旨在作为C和C++等语言编写的代码的编译目标。WebAssembly的一个关键目标是与本机代码的性能对等;以前的工作报告接近对等,许多编译到WebAssembly的应用程序平均比本机代码慢10%。然而,这项评估仅限于一套科学内核,每个内核大约由100行代码组成。运行更多的应用程序是不可能的,因为将代码编译到WebAssembly只是难题的一部分:标准的Unix API在Web浏览器环境中不可用。为了应对这一挑战,我们构建了Browsix-Wasm,这是Browsix的一个重要扩展,它首次使直接在浏览器中运行未经修改的WebAssembly编译的Unix应用程序成为可能。然后,我们使用Browsix-Wasm对WebAssembly与Native的性能进行了第一次大规模评估。在SPEC CPU基准测试中,我们发现了一个巨大的性能差距:编译到WebAssembly的应用程序运行速度平均慢45%(Firefox)到55%(Chrome),峰值慢2.08倍(Firefox)和2.5倍(Chrome)。我们确定了性能下降的原因,其中一些是由于优化缺失和代码生成问题造成的,而另一些则是WebAssembly平台固有的。

英文摘要:

All major web browsers now support WebAssembly, a low-level bytecode intended to serve as a compilation target for code written in languages like C and C++. A key goal of WebAssembly is performance parity with native code; previous work reports near parity, with many applications compiled to WebAssembly running on average 10% slower than native code. However, this evaluation was limited to a suite of scientific kernels, each consisting of roughly 100 lines of code. Running more substantial applications was not possible because compiling code to WebAssembly is only part of the puzzle: standard Unix APIs are not available in the web browser environment. To address this challenge, we build Browsix-Wasm, a significant extension to Browsix that, for the first time, makes it possible to run unmodified WebAssembly-compiled Unix applications directly inside the browser. We then use Browsix-Wasm to conduct the first large-scale evaluation of the performance of WebAssembly vs. native. Across the SPEC CPU suite of benchmarks, we find a substantial performance gap: applications compiled to WebAssembly run slower by an average of 45% (Firefox) to 55% (Chrome), with peak slowdowns of 2.08x (Firefox) and 2.5x (Chrome). We identify the causes of this performance degradation, some of which are due to missing optimizations and code generation issues, while others are inherent to the WebAssembly platform.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑