What is TraceMonkey?
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?
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:
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?
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
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.