Sunday, August 31, 2008

TraceMonkey will drasticly increase speed of Javascript in FF3.1

Firefox 3.1 will be the next major Firefox release. There is still no release date known, but it will probably be end of 2008, start of 2009. The last official (development) release is Alpha 2 released on 19 August. The developers are still hard busy with working and a lot has already changed between then and now.

TraceMonkey is one of those things. It started as an adaption to the JavaScript Engine to increase the speed of JavaScript and has now landed in the nightly releases. Still not enabled by default cause of some regressions, but if you want you can enable it yourself and see what the speed improvements really are.

Step 1: Download the latest release
Step 2: Type 'about:config' in the urlbar
Step 3: Search for javascript.options.jit.content
Step 4: Enable it

It is still buggy, so webpages that use advanced javascript will probably break (ex. google docs)

You could now ask why the speed of JavaScript is so important. First you need to know that FireFox uses his own technologie of Javascript to render the layout of his browser. So actually almost every button is made out of Javascript and CSS. So if JavaScript get faster, the browser gets faster to. To let TraceMonkey increase the speed of Javascript in the browser to, you need to enable another thing:

Step 1: Type 'about:config' in the urlbar
Step 2: Search for javascript.options.jit.chrome
Step 3: Enable it

Now Firefox itself will be responsiver and faster. (Also still buggy)

But sites can also use this boost. It makes existing websites faster and opens a way to more complicated and advanced sites, without having to worry about the performance.

To see some numbers about the speed up, I would recommer you to read: Brendan's blog
More information about the used technology: trace trees (PDF)

2 reacties:

pmontrasio said...

I downloaded the latest nightly release and activated TraceMonkey as you explained.

I went to http://code.google.com/apis/v8/run.html hoping to see some great performances but I keep getting the same scores I'm getting with Firefox 3.0. They are in the 150-160 range while Chrome scores 1600-1700.

Am I doing something wrong in the TraceMonkey activation or am I downloading the wrong release?

I tried two of them: the zip files for Windows at ftp://ftp.mozilla.org/pub/firefox/tinderbox-builds/mozilla-central-win32/ and ftp://ftp.mozilla.org/pub/firefox/nightly/latest-trunk/

Thanks

h4writer said...

@pmontrasio:

You need to know that Tracemonkey is atm a enormous platform to improve JS. There are a lot of optimizations already in it, but there is still A LOT space for improvements. One of the things that will hopefully land in next development releases is the recursion improvements. Because now from the moment you got a recursion there is no speed up at all.

The basics of the test you used is recursion. It's a specific test only to show that google Chrome is very good at it.

But again probably there will be a enormous improvement over the next few months when the improvements of recursion gets into Tracemonkey