In Chrome 91, Google’s slotted a third compiler in the middle called Sparkplug. Like Turbofan, it generates machine code, but it doesn’t optimize its code based on new information so its output isn’t quite as fine. But because it doesn’t have to wait around for that information, it can get initiated just after Ignition does and construct up velocity almost as quickly. It eases the pipeline’s transition from Ignition to Turbofan.
In Google’s testing, Sparkplug improved the V8 engine’s compute performance by 5 to 15%, relying on the hardware, website, and operating system.
The new V8 also includes a second optimization; the removing of embedded builtins, which Google recently realized were inflicting performance issues. In that sense, it’s more of a bug fix. It isn’t Google’s final resolution to the dispute because it uses too much memory (as all Chrome versions are destined to do, apparently) but it’s enough of an improvement to merit inclusion.
Put briefly, a builtin is a prewritten snippet of code that handles a common process, and they’re pulled from memory by the CPU as the code runs. The dispute with them is that in some CPU architectures, if the builtin isn’t stored in the same memory space as the engine’s code, it can take the CPU quite a while to find it. Apple’s M1 chip is particularly susceptible to this dispute.
V8’s new resolution is to copy the library of builtins from wherever it happens to be to paste it next to the compiled code it’s creating. This duplication is cause for the increased memory utilization, but it enables the CPU to consistently make correct department predictions when it searches for the right builtin, thus allowing the CPU to use it for out-of-order execution.
Google found that the duplication fix could offer a fairly variable performance improvement of 3 to 15%. YouTube and Apple’s M1 benefited from it the most.
You’re probably using Chrome 91 right now (if not, you can download it here). Have you noticed the extra velocity?
Image credit: Pawel Czerwinski