Google revs Chrome's V8 JavaScript engine to drive high-performance web apps

Google aims to stamp out stuttering and dropped frames in complex web apps in Chrome by changing how the browser compiles JavaScript to native code.

Google has tweaked Chrome's JavaScript engine to boost the performance of web applications in the browser.

Read this

Do you save passwords in Chrome? Maybe you should reconsider

Every modern browser lets you save and sync user names and passwords for your favorite websites. Maybe that's not such a good idea.

Read More

Chrome's V8 JavaScript engine compiles JavaScript into machine code just before it is executed. Historically, V8 compiled JavaScript on the main thread, where it could interfere with the performance of the JavaScript application.

In the latest Chrome Beta release, Google has enabled concurrent compilation, which offloads an important part of the compilation process to a background thread to deliver better performance for web apps.

Where does the performance boost come from?

In a blogpost, Yang Guo, multi-threaded V8 engineer at Google, explained how the V8 engine compiles JavaScript in several phases.

The initial "compilation phase is fast but doesn't focus on optimising the code, just on getting it done quickly", Guo wrote.

However blocks of JavaScript code that are executed very often are compiled a second time, this time by an optimising compiler, which takes longer to complete than the initial compilation but that uses optimisation techniques to deliver faster code.

"Until now, V8 took turns compiling optimised Javascript code and executing it. For large pieces of code this could become a nuisance, and in complex applications like games it could even lead to stuttering and dropped frames," he wrote.

The switch to concurrent compilation tackles this issue, he said.

To demonstrate the performance increase concurrent compilation makes possible Google produced two graphs showing V8 performance when running Mandreel, part of the Octane 2.0 benchmark suite, on the Nexus 5 phone.

The first graph shows V8 running without concurrent compilation. V8 is fully occupied with optimising a large piece of code, causing an execution pause of more than 600ms.


Enabling concurrent compilation, allows the optimisation to take place in a background thread without pausing the application's execution, as seen below.


Concurrent compilation improved the Mandreel score of Octane 2.0 by 27 percent on a Nexus 5, Guo wrote, and made graphic-intensive applications such as the Epic Citadel Demo run even smoother in Chrome.

The concurrent compilation feature available in the Chrome Beta release will be added to the stable release of the browser at a later date.

Firefox will also move the entire just-in-time compilation process off the main thread in the forthcoming Firefox 29 release, currently available to test through its Aurora release channel.

More on Google Chrome