Original URL: http://www.theregister.co.uk/2012/05/03/chromium_v8_counters/

Google counters juice V8 Javascript engine

Beta channels primed

By Gavin Clarke

Posted in Software, 3rd May 2012 14:59 GMT

Google’s V8 engine is getting more picky about the Javascript code it optimises to boost the performance of the search giant’s browser.

The current developer and beta channel releases of Chrome now come with a version of V8 that uses a new counters-based algorithm to decide which functions to optimise, Google has revealed.

Google claimed a 25 per cent increase in speed with Chrome 19, with the updated version of V8, compared to Chrome 18 on SunSpider performance tests.

V8 compiles Javascript in two stages: first to machine code and then optimising it, a fact that means V8 needs to predict what functions to optimise.

Traditionally V8 has stopped once every millisecond to look at the running functions and decide which should be optimised. As the Chromium blog put it: "A single millisecond can be a long time to wait before optimizing!“

The new V8 algorithm uses counters to keep track of how often Javascript functions are called and loops executed in a program. The Chromium blog said: “That way V8 is able to quickly gather fine-grained information about performance bottlenecks in a JavaScript program, and to make sure that the optimizing compiler's efforts are spent on those functions that deserve it most.” ®