What’s in the latest Chrome update? A JavaScript jolt from the new Sparkplug compiler

Google is claiming that Chrome 91, the version that launched May 25, is up to 23% faster than its predecessors thanks to a new JavaScript compiler dubbed “Sparkplug.”

The speed improvements made to Chrome will also apply, if they haven’t already, to other browsers that  rely on the Chromium project’s technologies, including the V8 JavaScript engine. Microsoft’s Edge is the most popular non-Google browser based on Chromium.

“An important component of delivering a fast browser is fast JavaScript execution,” wrote Thomas Nattestad, product manager for Chrome, in a May 27 post to a Google blog.

According to Nattestad, the new Sparkplug compiler has been inserted between the two previously-existing — Ignition and Turbofan — to break through a performance stalemate. (The byte code interpreter Ignition began executing JavaScript as soon as possible; meanwhile, the Turbofan optimizer generates high-performance machine code, but required information available only after Ignition started executing JavaScript.)

“Sparkplug strikes a balance between Ignition and Turbofan in that it does generate native machine code but does not depend on information gathered while executing the JavaScript code,” wrote Nattestad. “This lets it start executing quickly while still generating relatively fast code.”

In effect, Sparkplug can’t craft code that matches the performance of Turbofan’s but starts doing it sooner. Elsewhere, Google called Sparkplug a “non-optimizing JS [JavaScript] compiler,” to further differentiate it from Turbofan.

In the far more technical post on the V8 blog, Leszek Swirski, a Google senior software engineer, pointed out that squeezing even more performance out of the JavaScript engine is getting tough. “At some point you can only get faster by removing optimization passes, which reduces peak performance,” Swirski said. “Even worse, we can’t really start optimizing earlier, because we won’t have stable object shape feedback yet.”

Caught between that rock and that hard place, the V8 team built Sparkplug. “Sparkplug is designed to compile fast. Very fast,” Swirski continued. “So fast, that we can pretty much compile whenever we want, allowing us to tier up to Sparkplug code much more aggressively than we can to TurboFan code.”

(Swirski’s post is recommended reading for those wanting a deeper technical dive, but he wrote it in such a way as even non-coders — such as, well, some Computerworld reporters — can understand it, or more accurately, understand most of it. Kudos.)

Benchmark results — also included in Swirski’s piece — indicate a performance boost of between 5% and 15%, depending on the OS and machine. Linux’s version of the Sparkplug-equipped Chrome showed the largest gain, macOS the smallest. On the latter, results from running the browser on an M1-equipped Mac were superior to those on Intel-based Macs. (Google’s claim that the latest Chrome is 23% faster was also based on short builtins, which it spelled out here.)

Other browsers jumped on the Sparkplug gravy train, too.

On May 25, the same day Google refreshed Chrome to v. 91 with the Sparkplug compiler, Microsoft — which was at the time hosting its all-online Build developers conference — declared that its Edge “will be the best performing browser on Windows 10 when Microsoft Edge version 91 releases.” (Microsoft launched Edge 91 on May 27.)

Microsoft based its claim on features it has added to its browser atop the Chromium-based foundation: a faster startup process that pre-loads parts of Edge before it’s opened by the user, and sleeping tabs, which immediately frees up device memory when a tab is no longer active and in the foreground.

Chrome 91 can be downloaded from Google’s website for Windows, macOS and Linux. Edge 91 can be downloaded for Windows and macOS from Microsoft’s site.