[Lifehacker] 1 New Entry: Why TraceMonkey is Going to Blow Your Web Browsing Mind [Firefox]

Why TraceMonkey is Going to Blow Your Web Browsing Mind [Firefox]


There's a lot about the next iteration of the open-source Firefox browser to be geeked out about. From private browsing modes to tab preview panels, from punchier colors to really smart session restoring, there's been a lot of thought put into how people want to use the web. But perhaps the greatest promise in Firefox 3.1 is the one most users won't see at all—a serious overhaul of the browser's JavaScript engine, newly christened as TraceMonkey. If you don't obsessively follow the Mozilla developer's blogs or read insider tech news, you might have a few questions about TraceMonkey—like, say, what's different about it, how much faster is it, why that matters, and how you can try it out right now. We've compiled a primer on TraceMonkey's features and uses, as well as how to experience it. Read on to see what's new under the hood in the upcoming Firefox.

What is TraceMonkey?

The answer to that question that everyone can understand is, "It's the new JavaScript engine in Firefox 3.1, and it's a lot faster."

The slightly geekier answer is that TraceMonkey is a descendant of SpiderMonkey, the first-ever JavaScript engine written for Ye Olde Netscape web browser. TraceMonkey uses "just in time" methods to understand and execute commands given to it by Ajax-heavy sites like Gmail, Facebook, and other webapps that can manipulate data without requiring a page refresh. One Mozilla exec told Ars Technica that TraceMonkey represents "performance improvements ranging between 20 and 40 times faster in some cases."

Okay, for the truly geeky amongst you: TraceMonkey uses "an alternative compilation strategy in which no controlflow
graph is ever constructed, but in which relevant (i.e., frequently executed) control flows are instead discovered lazily during execution." Or, rather than spend processor time trying to determine all the ways a certain if/when command can be executed, TraceMonkey just guns through it at first, generating the code it needs to run. As soon as the command turns out a different result, or another path becomes "hot," the compiler re-figures code for all the different paths. So TraceMonkey moves quickly to figure out at least one path through a maze of code, or a "trace tree," and offers it up to the user ASAP. Think of it as an impulsive chess player, versus the guy who takes all afternoon to run out every scenario under the sun.

Need a better explanation than this CSE drop-out can provide? Try Andreas Gal's TraceMonkey FAQ post, or this PDF whitepaper from the University of California, Irvine, describing trace tree methodology. Or check out the video below, queued up to the relevant TraceMonkey portion of a BarCamp presentation by Gen Kanai:

How much do milliseconds really matter?

In short, plenty. JavaScript has become a predominant technology amongst today's web developers, and Mozilla—along with pretty much every web browser maker out there—aims to make it just as fast as code that runs on your desktop. The closer everyone gets to that kind of speed, the closer the idea of the Web as Desktop gets to reality.

This is handily demonstrated in a video demonstration of online photo editing over at Mozilla's site. With just-in-time compiling, actions the user takes on a web program move along as if being adjusted in a desktop app, as opposed to having to basically re-load an entire JavaScript app and figure out what state it's in.

Oh, but you're the numbers-and-graphs type, right? Mozilla has posted TraceMonkey benchmarks run on Apple's SunSpider tester back in August. Here's the basic overview graph:

And here's TraceMonkey pitted against Google Chrome's much-touted V8 JavaScript engine, run by Mozilla on the same SunSpider benchmark suite:

Now this is, as even Mozilla points out, just one test of JavaScript speed, and you're only seeing what Firefox's developers have publicly displayed. I tried running a TraceMonkey-enabled Firefox 3.1 build through the same Celtic Kane JavaScript test I used in our browser speed tests (one which at least one Firefox developer has expressed serious doubts about), but the results came back pretty noticeably off-key—timing out at 10 times slower than Chrome, or even Firefox 3.0.

From human observation, I can say that Gmail did seem a good deal snappier using TraceMonkey, and Facebook's mini-feed on my main page seemed to start folding down the page the instant the web page was called up. Of course, I'm using the highly-variable Windows Vista, and my Firefox 3.1 build was running no add-ons or external plug-ins. Still, it seems like Mozilla's claims aren't just inside-ball developer braggery—this monkey is a swift one.

So I should get ready to switch to Firefox 3.1?

We're never shy about touting an open-source, highly-extendable browser, so feel free to try it out when it drops (or look below for help on giving it a test without disturbing your regular Firefox). But given how all the code for Firefox is available to anyone, Firefox's SpiderMonkey engine is already being used in Yahoo Widgets, an offline Ultima Online server emulator, the JavaScript elements of the Windows-in-Linux WINE project, and likely a good number of other spots. If TraceMonkey's speed makes a noticeable impact, you'll likely see it put into place in those places and many more, and other browsers might just pick up on it as a mainstay or option, or at least develop their own versions.

Okay, I'm sold. How do I get TraceMonkey in my Firefox?

Our intrepid (and Firefox-loving) intern AsianAngel has done the good work of detailing how to test out TraceMonkey without touching Firefox or any other browser you've got installed over at her blog. You're basically installing a copy of Portable Firefox, then grabbing the latest beta build of Firefox 3.1 with TraceMonkey enabled and installing it into the guts of that Portable Firefox folder. Note that 3.1 comes with TraceMonkey enabled by default for web content, but you can also have TraceMonkey be the go-to handler for browser chrome (i.e. toolbars and display) and add-ons by enabling it in about:config.

Your take

We've certainly said (and shown) our piece on TraceMonkey, but we're just one team of bloggers, albeit a highly geeky one. We want to hear from our bleeding-edge fans how TraceMonkey is working in the wilds of the web, so tell us your take in the comments.


You received this email because you are subscribed to the real_time feed for http://feeds.gawker.com/lifehacker/full. To change your subscription settings, please log into RSSFWD.

No comments: