IEEE International Symposium on Workload Characterization (IISWC) 2021
The Cost of Speculation: Revisiting Overheads in the V8 JavaScript Engine
Alberto Parravicini, Rene Mueller
Abstract
JavaScript, while widely used in web applications, is also gaining popularity beyond the web, such as on the server as part of Node.js or on the desktop using the Electron framework, for example, in the Slack application. However, executing code written in this weakly and dynamically typed language efficiently, requires sophisticated Just-in-time (JIT). In this paper, we revisit the overheads when running JavaScript. We perform a detailed analysis of the JetStream2 benchmark suite running on Google's modern V8 JavaScript engine. We identify micro-architectural bottlenecks and runtime overheads that result from the speculations made by the JIT compiler when it generates machine code for the dynamically, weakly-typed language. We find that checks that verify assumptions made by the compiler have an average execution overhead of 8 %, 2--4x of what an earlier study reported on an older version of V8. We then focus one specific the type check, the check for Small Integers (SMI) and find that the conditional branches are not underlying cause but rather the computation of the condition itself. This makes the problem attractive for a HW/SW codesign solution. We present an extension for the ARMv8 instruction set that optimizes SMI load instructions and type checks. We can improve execution time on SMI-heavy computations by up to 10 % on prototype implementation of the new instructions in the gem5 simulator. This is an encouraging result, indicating that dynamic languages can benefit from a HW/SW codesign.
