kirancodes.me
To Proof Maintenance & Beyond!

When Function Inlining Meets WebAssembly: Counterintuitive Impacts on Runtime Performance

Alan Romano, Weihang Wang

Abstract

The WebAssembly standard defines a bytecode format serving as a compilation target for languages such as C, C++, and Rust. WebAssembly compilers are built on top of existing compiler infrastructures such as LLVM and newly developed compiler toolchains such as Binaryen, handling various new features of the WebAssembly language. However, we observe that both these new and existing infrastructures implicitly assume that the execution environments of native and WebAssembly applications are the same, ignoring the presence of browser compilers in the WebAssembly pipeline. This incorrect assumption often misguides function inlining optimizations, resulting in a slower WebAssembly module when function inlining is applied. This paper is the first to investigate the counterintuitive impacts of function inlining on WebAssembly runtime performance. We inspect the inlining optimization passes of the LLVM and Binaryen infrastructures used in the Emscripten C/C++-to-WebAssembly compiler. Our investigation on 127 C/C++ samples from the LLVM test suite shows that 66 samples exhibit counterintuitive behavior due to function inlining, particularly from inlining hot functions into long-running functions. We hope our findings motivate further work on revising existing optimizations with the unique characteristics of WebAssembly environments in mind.

BibTeX
@inproceedings{Romano-Wang:FSE23,
  author    = {Alan Romano and
               Weihang Wang},
  title     = {When Function Inlining Meets {WebAssembly:} Counterintuitive Impacts on Runtime Performance},
  booktitle = {{ESEC/SIGSOFT} {FSE}},
  pages     = {350--362},
  publisher = {{ACM}},
  year      = {2023},
}

Related papers