Hi, I'm Ron Cormier. I'm the owner of a small software company where I design websites and build reusable web applications.

This blog is a work in progress but I plan on writing about website development, software design, information technology, and some of the projects I'm working on for Communicate Solutions. Check out my company's website, Communicate Solutions.com.
Sign in

Tags


Chrome has V8 engine Chrome logo

A couple months ago I wrote about how Google may be pushing its new Chrome browser by making changes to google.com.  Having done a lot of work in JavaScript recently, it got me wondering how Chrome intended to actually speed things up.  It turns out the key is their new JavaScript engine, V8.

V8 is the code name of the JavaScript virtual machine shipped with Chrome.  It is named V8 because it is supposed to be powerful like and 8 cylinder car engine.  I did some googling and found a video where the V8 tech lead, Lars Bak, explains how it is fast.

 

Why is V8 fast?

There are primarily three techniques V8 to improve the speed of execution of JavaScript in Chrome:
1. Hidden Objects
If two objects of the same type are created, a third, hidden object is created which links the two child objects.  The key reason for doing this is that it helps generate efficient machine code.

2. Dynamically generated machine code
When V8 parses your JavaScript, it doesn't generate an intermediate byte code as most engines do.  Instead, it generates native machine code (assembly).  This is much faster since there is no interpretation step.

3. Precise garbage collection
Lars says that memory is reclaimed incrementally so there are minimal pauses or hiccups in the browser when using a complex JavaScript application.

 

When is it not fast? 

As Lars explains in a MSDN Expert to Expert video, V8 is optimized for the most common JavaScript programming patterns and operations.  If your JavaScript program uses infrequent operations, V8 could experience very slow performance.  An example of an operation which could slow things down is deleting/re-adding object properties.  V8 is standards compliant, so it will work but it might not be fast.  "If you write that kind of code, we want to penalize you", mentions Lars with a chuckle.  He also goes on to say that this is how it works in the initial version and it could be changed in future version.

 

The Verdict

V8 and Chrome definitely sound cool.  Lars doesn't strike me as an architecture astronaut so the future looks bright.  However, the technology is so new that I wouldn't yet recommend it for most users.  Honestly I haven't tried it out yet myself.  I'm pretty happy with Firefox and especially all the extensions that are available for Firefox.  I am planning to run my web app's test cases in Chrome in the near future... I'll be sure to post the results.

 

Bonus JS Architecture Talk

Can't get enough?  Check out this talk given by Ryan Dahl at the 2009 European JavaScript Conference.  Ryan describes NodeJS, a server-side JavaScript platform built on V8 which features purely asynchronous I/O and event loop concurrency.  The main program never waits on I/O... giggity.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5