Speedy Performance

By Darryl K. Taft  |  Posted 2008-08-25 Print this article Print

"A major goal of the project has been to set JavaScript up to compete with natively compiled code, rather than simply against other interpreters," said Resig. "This means that we're starting to see speeds that are completely out of this league when it comes to performance."

Added Eich, "We're supporting a bunch of platforms out of the box, including ARM, so we're supporting mobile Firefox."

In a section of his post describing "What it all means," Eich said:

"We have, right now, x86, x86-64, and ARM support in TraceMonkey. This means we are ready for mobile and desktop target platforms out of the box.

As the performance keeps going up, people will write and transport code that was -too slow' to run in the browser as JS. This means the web can accommodate workloads that right now require a proprietary plug-in.

As we trace more of the DOM and our other native code, we increase the memory-safe code base that must be trusted not to have an exploitable bug.

Tracing follows only the hot paths, and builds a trace-tree cache. Cold code never gets traced or JITted, avoiding the memory bloat that whole-method JITs incur. Tracing is mobile-friendly.

JS-driven <canvas> rendering, with toolkits, scene graphs, game logic, etc. all in JS, are one wave of the future that is about to crest."

Moreover, Eich said, "TraceMonkey advances us toward the Mozilla 2 future where even more Firefox code is written in JS. Firefox gets faster and safer as this process unfolds."

Mike Shaver, vice president of engineering at Mozilla, said of the TraceMonkey results:

"These are the early results from a project we've been calling TraceMonkey, which adds native code compilation to Mozilla's JavaScript engine (-SpiderMonkey'). Based on a technique developed at UC Irvine called -trace trees,' and building on code and ideas shared with the Tamarin Tracing project, a few of us have spent the last 2 months (and most of the last few nights) teaching SpiderMonkey some exciting new tricks."

The goal of the TraceMonkey project-which is still in its early stages-is to take JavaScript performance to another level, where instead of competing against other interpreters, we start to compete against native code."

Describing the concept of tracing, Resig wrote:

"In simple terms tracing works by watching for commonly-repeated actions (such as loops, function calls, or type checking) and tries to optimize their resulting native code into the lowest number of actions. The premise is rather simple-and it's an advance that we'll probably see proliferate to many interpreters and engines in the upcoming years."

"You record the instructions the interpreter is executing, like a VCR," Eich said.

"We're looking at putting this [tracing JIT] into our native C++ DOM [Document Object Model] code base," Eich told eWEEK. "We're going to make our DOM traceable. We'll move a lot of our code into JavaScript."

With the performance enhancements afforded by TraceMonkey, developers can start transporting code from other languages and other platforms and porting it to the browser, Eich said. "This moves the goal posts on proprietary plug-ins," he said. "JavaScript with TraceMonkey will be so fast people can do ports of games."

Darryl K. Taft covers the development tools and developer-related issues beat from his office in Baltimore. He has more than 10 years of experience in the business and is always looking for the next scoop. Taft is a member of the Association for Computing Machinery (ACM) and was named 'one of the most active middleware reporters in the world' by The Middleware Co. He also has his own card in the 'Who's Who in Enterprise Java' deck.

Submit a Comment

Loading Comments...
Manage your Newsletters: Login   Register My Newsletters

Rocket Fuel