The Chrome development team has been tinkering around in the V8 engine, and they’ve found a way to maintain responsiveness while boosting performance: concurrent compilation.
Google V8 engineer Yang Guo revealed the new technique in a blog post explaining how, in the latest release of Chrome Beta, developers moved JavaScript compilation into a background thread, giving Chrome’s JavaScript engine a way to compile large pieces without complications like stuttering or dropped frames in more complex applications.
Chrome’s V8 engine compiles JavaScript into native machine code to quickly execute scripts. Up until now, Chrome compiled JavaScript on the main thread where it could interfere with and slow down performance of the JavaScript app. V8 defers compilation of JavaScript functions until immediately before they’re executed, which saves time but doesn’t focus on optimizing the code.
(Related: Project Nashorn: The bridge between Java and JavaScript)
“Until now, V8 took turns compiling optimized JavaScript code and executing it,” Guo wrote. “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. Concurrent compilation tackles this issue.”
Concurrent compilation still allows V8 to optimize a large piece of code, but in the background, thread execution continues alongside compilation. The improvement will be available with the stable release of Chrome 33 in the next several months.