Mozilla: Web apps faster with Firefox 3.1

TraceMonkey will speed JavaScript applications dramatically, making browsing snappier and opening new horizons for Web applications, the open-source developer promises.

Stephen Shankland principal writer
Stephen Shankland has been a reporter at CNET since 1998 and writes about processors, digital photography, AI, quantum computing, computer science, materials science, supercomputers, drones, browsers, 3D printing, USB, and new computing technology in general. He has a soft spot in his heart for standards groups and I/O interfaces. His first big scoop was about radioactive cat poop.
Expertise processors, semiconductors, web browsers, quantum computing, supercomputers, AI, 3D printing, drones, computer science, physics, programming, materials science, USB, UWB, Android, digital photography, science Credentials
  • I've been covering the technology industry for 24 years and was a science writer for five years before that. I've got deep expertise in microprocessors, digital photography, computer hardware and software, internet standards, web technology, and other dee
Stephen Shankland
4 min read

Updated at 2:40 p.m. PDT with more details about Firefox 3.1 features.

Firefox 3.1 will run many Web-based applications such as Gmail faster through incorporation of a feature called TraceMonkey that dramatically speeds up programs written in JavaScript, Mozilla said Friday.

JavaScript has been very broadly used to add pizzazz or flexibility to Web pages over the years, but in recent years, it's also become the plumbing for many rich Internet applications. However, because JavaScript has been hobbled by pokey performance, Web-based applications often struggled to work as responsively as "native" software running directly on PCs, and programmers writing Web applications have often turned to other options, such as Adobe Systems' Flash and Flex.

Now Mozilla hopes to change the balance of power in JavaScript's favor.

"TraceMonkey is a project to bring native code speed to JavaScript," said Mike Shaver, Mozilla's interim vice president of engineering, adding that JavaScript performance nearly doubles compared to Firefox 3.0, based on the SunSpider test of JavaScript performance. That speeds up many basic tasks, but it also brings image editing and 3D graphics into JavaScript's abilities, he said.

On Thursday, Mozilla programmers built TraceMonkey into the latest developer version of the open-source Web browser, and it will appear in the next released test version, which likely will be the first beta of Firefox 3.1, Shaver said. Firefox 3.1 is due in final form by the end of the year, though Mozilla is willing to let the schedule slip a bit, if necessary.

TraceMonkey dramatically improves the speed of many JavaScript operations.
TraceMonkey dramatically improves the speed of many JavaScript operations. (Click to enlarge.) Mozilla

JavaScript execution speed can make surfing the Web snappier, so naturally, it's a key part of the resurgent browser wars between Microsoft's Internet Explorer, Mozilla's Firefox, Apple's Safari, and Opera. "We're as aware as anybody that the market is competitive again," Shaver said.

The SunSpider JavaScript test shows a boost of 83 percent, according to programmer and JavaScript pioneer Brendan Eich, who has worked on TraceMonkey and blogged about it on Friday. However, that speed test is an artificial benchmark that is an imperfect reflection of actual JavaScript applications such as Yahoo's Zimbra e-mail software.

Another illustration of TraceMonkey speed is a video of photo editing. Contrast and brightness adjustments take about 100 milliseconds instead of more than 700.

Shaver discussed TraceMonkey on his own blog too.

TraceMonkey explained
TraceMonkey's name is a cross between SpiderMonkey, Mozilla's current engine for interpreting JavaScript code, and a technique called tracing developed at the University of California at Irvine by Andreas Gal and others. Gal is TraceMonkey's lead architect, Shaver said.

TraceMonkey is what's called a just-in-time compiler, one type of technology that solves the problem of converting programs written by humans into instructions a computer can understand.

Most software that runs on people's computers is already compiled in advance into what's called a binary file, but JavaScript usually is interpreted line by line as it runs, a slower process. "We're getting close to the end of what you can do with an interpreter," Shaver said.

A just-in-time compiler, though, creates that binary file on the fly as the code arrives--when a person visits a new Web page, and the browser encounters JavaScript, for example.

TraceMonkey concentrates only on translating selected high-priority parts of software, though. By tracing and recording JavaScript program execution, TraceMonkey finds loops of repeated activity where programs often spend a lot of time. These loops of actual software behavior then are compiled into native instructions the computer can understand.

In contrast, some compilers translate the entire program, a burdensome process that involves mapping all possible paths the computer can take through the code and trying to figure out which are most important. Tracing technology, based on the actual execution of the program, concentrates only on the areas that actually occupy the computer.

"It lets us focus our optimization energy on the parts of the program that matter most," Shaver said.

That concentration means that TraceMonkey doesn't require a lot of memory or a slow-loading plug-in, Shaver said. And it also means that it's good for mobile devices, one of Mozilla's main focuses for browser development.

There's still a lot of work to be done in improving Web-based applications, though. Mozilla's next priority is improving the DOM--the document object model elements of Web browsers that are in charge of drawing and manipulating the Web page overall.

Although TraceMonkey currently is built into the new developer version of Firefox 3.1, it's disabled by default to begin with. "We did that because we want to get wider feedback," Shaver said.

Also in Firefox 3.1
Other significant changes will arrive in Firefox 3.1, Shaver said.

One is support for threading by JavaScript programs. Threads are instruction sequences, and newer multicore processors are able to run multiple threads simultaneously. Software support for that will mean JavaScript programs can execute some tasks in the background better, Shaver said.

Another is the built-in ability to play music encoded with the Ogg Vorbis format and video encoded with the Ogg Theora format. These formats, while not nearly as widely used or as supported as rivals such as MP3, are free from proprietary constraints such as patents, Shaver said, and therefore can be added to an open-source project such as Firefox.

"We're excited to bring unencumbered, truly open-source video to the Web," Shaver said. The support also works on all operating systems Firefox supports.

Mozilla will start encouraging Firefox users more actively to move to the current version soon. In about the next two weeks, Firefox 2 users will start getting messages to upgrade to version 3, Shaver said.

Currently, when copies of Firefox 2 check Mozilla servers to see if there's an update, the servers don't say to move all the way to version 3, so users must manually update.

"We're looking at doing that in the next two weeks," Shaver said. "The majority of users are still on Firefox 2."