Google today revealed a tweak it has made in the latest Chrome beta to further boost performance: concurrent compilation, which offloads a large part of the optimizing compilation phase to a background thread. Previously, Chrome compiled JavaScript on the main thread, where it could interfere with the performance of the JavaScript application.
As a result, Google says JavaScript applications remain responsive and performance gets a boost. This is all handled by V8, Chrome’s JavaScript engine.
Here’s how it works. First, V8 defers compilation of JavaScript functions until immediately before they are executed the first time (to reduce the overall time spent compiling). Next, pieces of code that are executed very often are compiled a second time by a specialized optimizing compiler. This second pass makes takes more time, but thanks to many advanced optimization techniques, it delivers much faster code.
Here is Chrome without concurrent compilation (V8 is fully occupied optimizing a large piece of code, causing an execution pause):
Here is Chrome with concurrent compilation (V8 still optimizes the large piece of code, but does so in a background thread):
The graphs above show excerpts of V8’s vital signs when running Mandreel, part of Google’s Octane benchmark suite, on a Nexus 5. The black bar represents JavaScript execution, so the goal is to get it as close to solid as possible.
Instead of taking turns compiling optimized Javascript code and executing it, V8 now uses concurrent compilation for large pieces of code to avoid stuttering and dropped frames in complex applications like games. We can expect these improvements to arrive in the stable version of Chrome in the next few months.
See also – Google will block local extensions in Chrome 33 for Windows, disable existing ones not in the Chrome Web Store and Google brings Chrome apps to Android and iOS, lets developers submit to Google Play and Apple’s App Store
Top Image Credit: Kimihiro Hoshino/AFP/Getty Images
Get the TNW newsletter
Get the most important tech news in your inbox each week.