Google improves the performance of its V8 JavaScript engine with a new compiler: Sparkplug


Why write a new compiler to improve JavaScript v8 engine? Google explains: Writing a high-performance JavaScript engine isn’t all about a highly optimized compiler like TurboFan. Especially for short sessions, such as loading websites or command line tools, there is a lot of work before the optimizer compiler has a chance to start optimizing, let alone start optimizing. . Take the time to generate the optimal code.

This is why, since 2016, we have moved from monitoring synthetic standards (such as octane) to measuring real world performance, and why since then we’ve been working hard on JavaScript performance outside of compiler optimization. It took a lot of work on the parser, on the stream, on our object model, on the concurrent garbage collector, and on caching the compiled code… let’s just say we never got bored.

However, as we strive to improve the performance of the initial JavaScript runtime, we are starting to run into limitations when optimizing our compiler. The V8 compiler is highly optimized and very fast, but interpreters have an inherent operating load that we cannot get rid of.

With the current dual compiler model, it is not possible to move faster to optimized code. Optimization can be sped up, but at some point you can only get that acceleration by removing the optimization lanes, which reduces peak performance.

This is where Sparkplug comes in, a new unoptimized JavaScript interpreter that Google is launching with V8 v9.1. The spark plug is located between the ignition translator and the TurboFan optimization translator, forming a new pipeline.

Sparkplug is designed to translate quickly. It’s so fast that we can pretty much compile it whenever we want, allowing us to move to Sparkplug code more robustly than we can to TurboFan code. Google says.

One of the reasons for this speed is that the functions that Sparkplug compiles have already been compiled to bytecode, and the bytecode compiler has already done the heavy lifting. On the other hand, Sparkplug does not generate any intermediate representation (IR) like most compilers do. Instead, Sparkplug compiles directly to machine code in a single linear path through the bytecode, freeing up code that matches this implementation of bytecode.

Since Sparkplug does not generate any intermediate representations, the possibilities for optimization are limited, but this is not a problem because there is an optimized compiler in the pipeline.

Google presents how Sparkplug works in this very interesting Technical note.

Source link

Leave A Reply

Your email address will not be published.