Firefox may get a significant performance boost from an unlikely ally

Jan 26, 2010 11:18 GMT  ·  By

Personal computers are a relatively new development, yet the pace at which things change in this space make the computers and software of even 10 years ago look antiquated. CPU speed, memory size, everything that has to do with hardware is several times faster and the software has, for the most part, evolved to take advantage of the new capabilities. Yet, for the last 30 years or so since the PC became a reality, something stayed the same, there was the hardware, there was the operating system and the software stack built for it and that's what you had to work with. Even after the internet came along, most of the work was done on the computer with the resources available locally.

But things are changing and the rate of change is increasing, the internet is becoming more than just a content repository or a communication avenue, apps like online office suites, image editors, chat clients, even things like Facebook, are blurring the line between traditional software and web sites. In time, more and more applications will be online rather than installed programs and if Google has its way , the browser, for all intents and purposes, will be the only piece of software you have on your machine.

This puts a lot of pressure on browser makers to meet the increasing needs of web developers and a lot of times this boils down to raw speed. The biggest reason why the move online hasn't happened sooner, besides internet connections speeds, was that web apps were and still are significantly slower than native software. This meant that a lot of the resource-hungry features had to be left out, often the ones the users wanted the most, and the interface kept simple just to make sure it was usable.

For the past couple of years though, again championed by Google, browsers have put a lot more emphasis on speed and JavaScript performance in particular. The latest Firefox 3.6 is several times faster than even Firefox 3.0. The latest Google Chrome 4 is almost five times faster than the first release, which at its time was several time faster than any competitor, and the browser has only been in existence for a little over a year.

Firefox has made some big strides but still trails Chrome, and Safari for that matter, in JavaScript performance. But Mozilla is not giving up and thanks to its greatest asset, its community, it may be taking some interesting approaches to improving web app performance thanks, in particular, to one project, Jetpack-to-CUDA, which uses the GPU to offload some of the more complex tasks from CPU. This frees up the processor to handle everything else, while the graphics card, which is mostly underutilized in usual scenarios, does the heavy lifting.

Jetpack-to-CUDA is more of a proof-of-concept at this point, but it shows that web developers are going to have a lot more processing power at their disposal in the not so distant future. As the name implies, the project aims to enable developers using the new Jetpack extension platform for Firefox to send some of the more intensive tasks in their apps to the GPU. You can read more about the project here or you can check out the project's website. CUDA is a parallel computing architecture and API developed by graphics-chip maker Nvidia to allow developers to take advantage of the graphics card in software which traditionally relies exclusively on the CPU, i.e. everything else but games and recently operating system interfaces (in Windows Vista, 7 but also on Linux).

Now, the developer behind the Jetpack-to-CUDA project, Alexander Miltsev, wrote a guest post over at Mozilla Labs, Mozilla's 'research and development branch', detailing some of the ways the project handles things but also looks at the broader picture of improving JavaScript performance using parallel computing, in this case the GPU. It gets a bit technical at times, but there are some interesting things for non-developers as well, so it's well worth a read.

At this point, you're probably wondering if there is really a need for this much processing power for JavaScript apps. Sure, web apps can get pretty complex these days, but even the slower computers can handle anything the web can throw at them. But this isn't because web apps don't need more processing power, it's because developers have had to adjust their needs to the resources they have available.

Miltsev highlights some of the areas which would benefit the most from the utilizing the GPU. "While text documents, videos, music, and image-base forms of collaboration are now common place, there are many needs require a level of compute performace beyond the web platform as it exists today, such as: consumption of high-quality digital video or music streams; complex image or speech recognition; manipulation and processing large pictures of nature or space; processing large sets of tabular data locally in the browser; complex animations with DOM elements (via DirectX or OpenGL); exploring 3D worlds, such as SecondLife or an OpenSim Grid; real-time audio and video editing; having an integrated development environment that runs entirely in the browser," he writes.

It's clear that with more to work with, web developers could greatly improve their apps or move into areas which haven't been feasible so far. But why does it have to be JavaScript when there are several alternatives out there which would be much suited for complex applications? It has to do with practicality, JavaScript is likely the most widely-used web technology and a lot of developers are familiar with it. As Miltsev points out, alternatives have either proven unwieldy and unpopular, like ActiveX, Java and anything else that requires a plug-in, with the sole exception of Flash, or are too early in development to be viable, like the Native Client project.

But JavaScript has its drawbacks, even with its wide use and large developer community, the browsers, though having made significant improvements in recent years, still can't process JavaScript code fast enough for more complex apps. Miltsev believes Jetpack can change this. "With Jetpack you can easily extend Firefox and enhance JavaScript’s abilities and reach on the client. However, this complicated functionality also requires greater speed with which to process it. JavaScript, being an interpreted language, is much slower than a compiled language such as C++, for example," he explains.

Browser makers will no doubt continue to make great improvements to JavaScript performance, but there is a limit to what they can do. Technologies like Jetpack-to-CUDA could be a real answer to this problem, at least in the short-to-medium term. Right now, the project is still very much in its early days, and the Jetpack platform is still in active development and not yet ready to replace Firefox's current add-on platform. But if things go well, developers should have a lot more resources at their disposal which, in the end, benefits the users. You can check out Miltsev's entire article over at Mozilla Labs.