A New Crankshaft for V8

Tuesday, December 07, 2010

Today we are introducing Crankshaft, a new compilation infrastructure for V8, Google Chrome’s JavaScript engine. By using aggressive optimizations, Crankshaft dramatically improves the performance of compute-intensive JavaScript applications - often by more than a factor of two! This will give users a faster and more responsive experience loading web pages and applications built with complex JavaScript. Here is a comparison of Chrome with and without Crankshaft on the V8 benchmark suite:


The benchmarks that benefit the most from Crankshaft are Richards, DeltaBlue and Crypto. This shows that we have taken the performance of JavaScript property accesses, arithmetic operations, tight loops, and function calls to the next level. Overall, Crankshaft boosts V8’s performance by 50% on the V8 benchmark suite. This is the biggest performance improvement since we launched Chrome in 2008.


In addition to improving peak performance as measured by the V8 benchmark suite, Crankshaft also improves the start-up time of web applications such as GMail. Our page cycler benchmarks show that Crankshaft improves the page load performance of Chrome by 12% for pages that contain significant amounts of JavaScript code.

Crankshaft uses adaptive compilation to improve both start-up time and peak performance. The idea is to heavily optimize code that is frequently executed and not waste time optimizing code that is not. Because of this, benchmarks that finish in just a few milliseconds, such as SunSpider, will show little improvement with Crankshaft. The more work an application does, the bigger the gains will be.

Crankshaft has four main components:
  1. A base compiler which is used for all code initially. The base compiler generates code quickly without heavy optimizations. Compilation with the base compiler is twice as fast as with the V8 compiler in Chrome 9 and generates 30% less code.
  2. A runtime profiler which monitors the running system and identifies hot code, i.e., code that we spend a significant amount of the time running.
  3. An optimizing compiler which recompiles and optimizes hot code identified by the runtime profiler. It uses static single assignment form to perform optimizations such as loop-invariant code motion, linear-scan register allocation and inlining. The optimization decisions are based on type information collected while running the code produced by the base compiler.
  4. Deoptimization support which allows the optimizing compiler to be optimistic in the assumptions it makes when generating code. With deoptimization support, it is possible to bail out to the code generated by the base compiler if the assumptions in the optimized code turn out to be too optimistic.
V8 with Crankshaft for the 32-bit Intel architecture is available today in the V8 bleeding edge repository and in canary builds of Chrome. Work on the ARM and 64-bit ports has started.

We are excited about the JavaScript speed improvements we are delivering with Crankshaft today. Crankshaft provides a great infrastructure for the next wave of JavaScript speed improvements in V8 and we will continue to push JavaScript performance to enable the next generation of web applications.

34 comments:

Manish said...

Excellent!

Scott Scowden said...

Deadly.

Mayhem said...

This pleases me!

Adam said...

Are there any performance differences in 64-bit? Does Crankshaft take advantage of multi-core architectures in any way? Does it ever use the GPU? Will it come to the Android browser?

pikadudeno1 said...

Sounds like Tracemonkey. Nice to see Mozilla and Google stealing good ideas off each other. :)

Harold Fowler said...

Oh wow, OK this makes a lot of sense dude, very good stuff.

www.privacy-resources.edu.tc

Jonas N said...

I wish we had Mac and Linux support for those canary builds now. :(

dmwmd said...

Can Chrome will do what in the faster waiting now?

Rushi said...

Will you persist the optimized code? Why compile the same javascripts again and again especially if you are just loading the same bits from the HTTP local cache?

Peter said...

Great to see this. I'm sorta surprised you hadn't implemented this before, TraceMonkey has been doing this for years....

Andrés said...

Can we get this today on Mac OS X?

Ethan Anderson said...

Can I set chrome to optimize the heart and soul out of pages like Facebook and Gmail when he page code checksum is identical to last access and I use the page over five times a day?

-Pablo- said...

@Jonas N: You can use the Chromium nightly builds (there's even a PPA for that if you're the Ubuntu type).

Luis said...

Comparisons to Tracemonkey are absurd. Trace monkey has always been slow as molasses compared to v8, except in very specific scenarios where tracing works better than a per-method jit. That's why Mozilla ended up creating jaegermonkey, to improve their baseline speed. Now they are integrating both engines into one, but it seems that jaegermonkey is currently responsible for most of the speed improvements in recent benchmarks.

As for chrome, it has always been the fastest, and now I wonder how much they are getting ahead of the competition. Anyway, this is good news for everyone.
It seems that soon, the old distinction between fast static against slow dynamic languages will become irrelevant.

jb said...

In both my mac and Windows XP versions of Chrome, passwords won't load for certain sites -- notable the libary! Chrome won't remember that password, and does not give that option. There are tons of complaints about this in the help forum, but no answers from Google. Many of us who would have preferred the speed of Chrome will uninstall it, since loading passwords is so convenient. I'm not talking about financial institutions, which are a recognized exception.

Barry said...

Out of interest, what sort of improvements does this bring about on the Kraken benchmark?

Rocky Madden said...

Most impressive. Thank you for pushing the bounds of performance!

Guillaume said...

I really love it (max speed !), but I get bugs/crashes all the evening (on Gmail, Google Docs... sad tabs) ! :o I hope it (Chrome + Crankshaft) will be more stable soon. I'm on Windows XP SP3. Anyway, good work guys ! ;)

gagneet said...

New compiler and optimizations do help out in all software development! this is good news, we did the same for flash player, with the new AS3 version on the compiler and virtual machine side...

Rhuantavan said...

Great news!

Brian Burg said...

@Luis: The comparison of V8 to JM is completely appropriate: they both are JS engines that use adaptive compilation.

@Rushi: Conventional wisdom is that it's more expensive to serialize/deserialize the code than it is to re-parse it every time. Perhaps more so when you have no IR (V8 goes directly from AST to assembly, as far as I know..). But, nobody has produced numbers to substantiate or refute this assumption. Looking for a research project?

@OP: I understand that marketing has a place, but air-quoting "adaptive optimization" doesn't explain how/why this version is faster than the previous V8 strategy. I hope a paper or tech report is forthcoming. In particular,

- is the profile-guided optimization applied to trace trees or independent traces?

- what kind of profiling is done? method entry counter, loop header, back edge target, sampling, ..?

- why is the baseline JIT twice as fast? what effect does that have on overall benchmark performance (independent of other optimizations)?

- what is the performance improvement on realistic benchmarks? v8-bench doesn't count.

- i'm puzzled as to how "performance is boosted by 50% on the v8 suite". Across all benchmarks? Just the ones that play well to new optimizations? By the way, how is that score calculated?

Looking forward to some more meaty details.

Kevin said...

how to i install??

Randall Lee said...

So this is a clever improvement and is good...but we can do far better than this! Algorithms are essential!!!(lol)

Arnaud Beausoleil said...

With ChromeOS, Chrome Browser, and things like Node.js (not supported directly by Google, but very promising), I bet V8 is one of the most strategic project for Google atm.

Jose said...

It is so good :D

WRB said...

Google has to fix the plugin issue with AB+ and Noscript. Firefox 4v8 is the tits. Chrome is good for the web but lets see if webkit/v8 can handle some real extensions. Why no Android Chrome love?

Serious said...

Does this mean you will finally have time on your hands to add E4X??

MMMMMM said...

Nice, but I Google need to work on Chrome features, as I see no complelling reason to stop using Opera 11 right now, as it's faster than Chrome and more fully featured too.

Witek Baryluk said...

I primary use Opera 11 (95%), but this new results of V8 are really amazing, and will definietly use on heavy pages or when doing server side javascript. Now we can even write real games or numerical computations in JavaSciprt :)

As I understand base-compiler is simplified existing compiler, to make it compiler faster, so page can bootstrap instantly. This also means that even simple optimizations which were done in previous V8, then will not take place on start, because even this simple optimization takes crucials miliseconds :)

My I ask what is memory usage compared to previous JS engine?

Andrew said...

http://www.arewefastyet.com/awfy2.php?machine=9

Daily comparison between Crankshaft and Spidermonkey TM+JM builds.

Wilson said...

coooooooooooooool!

snowstorm said...

When will the Google Chrome development team address the issue of memory consumption?

I read a review today from Lifehacker where Google Chrome placed last in terms of memory footprint.

Initially I had a hard time believing it but after firing up 9 tabs in Chrome 8.0.552.215 and comparing the result with Firefox 3.6.16 I was amazed to see a two-fold difference: Chrome ate ~240MB while Firefox handled the same pages with ~105MB.

Freeware Lovers said...

Wow, Google "innovated" again!!!

1) Cr-48 is the MacBook's design rip-off
2) Crankshaft - Mozilla's TraceMonkey

continue the list...

Gregorio Espadas said...

If Canary Build 10.0.607.0 for Windows includes V8 3.0.0.1, does it mean that Chrome Daily Build 10.0.608.0 for Linux with the same V8 3.0.0.1, includes Crankshaft too?