Does TraceMonkey kick Firefox into turbo mode?

Over the past few days I've been hearing a lot about Mozilla's new and improved JavaScript engine codenamed TraceMonkey. This new scripting engine hopes to bring JavaScript up to speed with natively-compiled code rather than be stuck in the slow lane like other interpreted coding languages. But does it work?

Over the past few days I've been hearing a lot about Mozilla's new and improved JavaScript engine codenamed TraceMonkey. This new scripting engine hopes to bring JavaScript up to speed with natively-compiled code rather than be stuck in the slow lane like other interpreted coding languages. But does it work?

I'd have taken a closer look at TraceMonkey last week but a sudden bout of stomach flu put me in a mood to do very little other than to sit down quietly and take small sips of water. This morning though I awoke feeling a lot better and decided to take a look at TraceMonkey for myself.

To use TraceMonkey I first had to download a nightly build of Firefox 3.1 (the build I'm using here is dated Aug 25). To switch TraceMonkey on I had to open an about:config tab and set javascript.options.jit.content to true.

So, with the nightly build downloaded and installed I then went on to replicate two out of the four tests that Mozilla team members had already posted data for, which were:

Note: I didn't run the Matrix manipulation test because I couldn't figure out how to make it work and it'll become clear in a moment why I didn't run the SunSpider ubench test.

Tests involved making two runs - one with TraceMonkey disabled and another with it enabled.

Test 1 - SunSpider JavaScript benchmark
  • TraceMonkey disabled: 2781.0ms +/- 5.0%
  • TraceMonkey enabled: Test failed

Does TraceMonkey kick Firefox into turbo mode?

I'm not sure what was going on here but the date-format-tofte script seemed to crash the browser every time when TraceMonkey was enabled. Based on this issue I abandoned my plans to run SunSpider ubench too.

Test 2 - Image manipulation demo

I had more luck with the image manipulation demo.

  • TraceMonkey disabled: Draw Time: 430ms | Frames Per Sec: 2.3255813953488373
  • TraceMonkey enabled: 89ms | Frames Per Sec: 11.235955056179774

That makes TraceMonkey around 4.8 times faster than the standard JavaScript engine.

Real world testing

In addition to running benchmarks, I tested TraceMonkey out on a selection of websites that I regularly visit and found there to be a huge performance boost to be gained from TraceMonkey. Websites such as Gmail were amazingly responsive, much faster than what I normally expect from them even when using Firefox 3.0.

However, I did experience a few crashes while surfing so this technology is still a way off being ready for prime time. But it does offer the promise of a much faster, smoother internet experience.

Good work Mozilla team!