Tracemonkey to Boost JavaScript Performance in Firefox 3.1

by Ostatic Staff - Aug. 25, 2008

JavaScript has become an increasingly important part of the Web application ecosystem. For years, JavaScript was seen as a hack, a language that was neither standardized nor stable, which could do little more than validate HTML form entries or change images when the mouse cursor hovered over them. Nowadays, however, JavaScript is the key to many of the Web's most interesting applications, using the "Ajax" paradigm ("Asynchronous JavaScript and XML"). This has led to a renaissance in the use of JavaScript, as well as a flurry of libraries aimed at making it easier to use and cross-browser compatible.

All of the libraries in the world can't take away from the fact that JavaScript has long been seen as something of a slowpoke. This didn't matter much when JavaScript "applications" were several dozen lines long. But when your word processor, photo editor, or photo-sharing application is written in JavaScript, you really want to be sure that the language is running at top speed.

Firefox 3, the latest stable version of the open-source browser, improved JavaScript execution time when compared with Firefox 2. However, the speed has continued to feel a bit slow. It was thus with a great deal of excitement and promise that several JavaScript developers announced late last week that a new JavaScript engine, known as "Tracemonkey," is already in the nightly developer releases, and that it will be a part of Firefox 3.1 when it is released. The Tracemonkey engine is dramatically faster than the existing JavaScript engine, with some actions running 20 times faster.

Brendan Eich, the creator of JavaScript and still a major force in its design and implementation, posted graphs on his blog that demonstrate just how much faster Tracemonkey will be than the current JavaScript engine. This does not mean that all applications will run 20 times faster, but it does mean that nearly every application will enjoy some speed boost.

The speedups are due to a technique known as "thread tracing," developed by Michael Franz's research group at the University of California, Irvine, which is why the implementation is called "Tracemonkey." This technique takes advantage of the fact that many slowdowns take place because of loops, and that improving loop speed will result in overall improved performance. This information is then used in the JavaScript just-in-time (JIT) compiler, allowing for fast execution of the JavaScript code. Eich pointed out that these speed improvements will affect Firefox's overall performance, given that increasingly large proportions of the browser itself are written in JavaScript.

Additional information is available from Mike Shaver, another JavaScript engineer who blogged about the improvements. Finally, a long article that goes into more detail is available at ArsTechnica, which calls these improvements "massive," and includes interviews with Eich and Shaver.