Hypothesis: Why Chrome and Firefox Perform So Poorly in Ubuntu Unity

So I’ve been really busy for the past few years and haven’t been able to spend as much time exploring and working on interesting things in Linux or posting to this blog. I don’t know if that will change in the near future. That was partially my reason for moving from Gentoo to Ubuntu. As fallout from all that, I ran into a very inexplicable situation right around the time that Ubuntu 14.04 came out. For the most part, it worked as before, and the polish that the Unity desktop (it wasn’t introduced in this version) brought was pretty nice, especially for the family. Easy to use and pretty.
At first things were great. But after a while I noticed some unusual performance issues. Nothing made sense. I would open more than four or five tabs and the computer would start swapping and the performance would nose dive. System load in ‘top’ would be in the 2-3 range. Since I tend to prefer Chrome, and I have a habit of having no less than 30-40 tabs open, this was becoming a major problem. But, life intervened in the form of more and more work to keep me away from investigating it and I just slogged through. I’d typically just close all applications, swapoff and swapon to get the system back to some sanity.
Coincidentally, last night I wanted to work on some sound design and I wanted as many system resources dedicated to the virtual modular synthesizer and realtime audio subsystem. I decided, after a few years away, to go back to my most minimal configuration using the XMonad window manager. I far prefer controlling windows by keyboard rather than mouse since it’s just generally faster. At one point I needed to look something up on the web, so I opened Chrome not thinking much about it. I immediately noticed it was faster. Much faster.
Sure, I’m using a window manager that is much lighter than Ubuntu Uniity, but come on… it’s not like there is THAT much of a difference in RAM and CPU utilization between heavier and lighter WMs. I was now curious and launched Firefox. Usually that was a recipe for disaster as both browsers would perform poorly and the rest of the system would tank. Indeed, a few times it was so bad I had to hard power cycle the laptop. But right now with XMonad, both Chrome and Firefox were speeding along just fine.
Why such a huge difference? I used to switch between twm, E, sawfish, metacity, beryl, compiz and kwm regularly and never saw this big of a difference. twm being the most bare bones was guaranteed to work on the lowest and oldest of systems. compiz had all the eye candy and special effects, but as a rough personal quantification of the difference, I’d say that compiz was maybe two times heavier than metacity. And metacity ran pretty well on nearly all systems.
So the big test this afternoon. I decided to hit the family media center and try out a lighter WM. I installed xfce4. It’s somewhat reminiscent of the old Gnome 2 days. I threw it on, configured it, and… everything felt pretty snappy. Not bad for a 2009 laptop. But the big test: Running the game Antichamber.
About two years ago the PC I had doing media center functionality for us died. I cloned it to my old laptop with the bad screen which wasn’t being used. Everything worked fine, except Antichamber. It loaded but the framerate was so low it was completely unusable. Even the game Fez had trouble keeping the audio in sync. I chalked it up to being an older laptop that was perhaps just under the requirements for those games. I was a little perplexed because NVidia cards, even in laptops usually don’t perform this poorly even if they’re over five or six years old.
After switching to xfce4, I tried Antichamber, and… it played perfectly. WTF!? No change in hardware at all, just a switch of the window manager. Then I thought it through a bit and did some Googling. At this point, I think I have an idea what the problem is. Back in 2009, before Ubuntu had Unity, the only applications that made use of 3D acceleration were games, video editors, and 3D modeling/rendering software. Today, the landscape is different. I knew that Unity made use of 3D acceleration and would likely have some impact on some 3D applications. (NOTE: Unity uses compiz) But in the intervening time, web browsers have also been added to the mix. They, like the games and Unity, are using GL today.
A little Googling also revealed that Unity will fall back to software assisted rendering if your 3D accelerator can’t do something that it needs. So all of that processing and data gets shifted from the graphics processor to your plain old CPU and regular RAM. I think the reason that Chrome performs so poorly under Unity is that it spins up a new Chrome process for each tab. Each of those processes hooks into the GL subsystem and the computer’s GPU or potentially uses up a LOT more CPU and RAM for software rendering. This is likely why Chrome is such a heavy load on a system even when it’s not being used. My system idle with Chrome doing nothing and 30+ tabs open is about 50%. Swap gets hit pretty hard, especially if I hit a site that has a lot of ads. imdb.com used to be horrible in Chrome. (There is also Flash, but we all know about that)
Firefox fares better, but it only has one process, so not as many hooks into GL as Chrome can potentially have. Right now, I’m typing this from within Chrome and have a ton of tabs open. No lag. No loud fan. No hot laptop. There is no single point to blame here. It’s not that “Unity sucks” or “Chrome sucks” or “Firefox sucks” or “Ubuntu/Linux sucks”. It’s that there is a resource on most systems that used to be used infrequently, and now it is drawn upon very heavily: the GPU. I suspect that this is also true in other OSes. If you’re seeing crappy browser performance, maybe it’s time to turn off the eye candy, or look into disabling your browser’s reliance on GL. It’s also likely that if you run on a desktop computer, you don’t notice this as much if you have a really good GPU in the system and more RAM and CPU than you can pack in the typical laptop.
For my laptop, the difference is like night and day. I can live without the niceties of Unity for now and I’m more than happy to go back to my beloved keyboard driven window manager, XMonad in exchange for vastly better performance. After showing my wife the improved performance on the family laptop, she said she doesn’t care about the eye candy and is willing to go through a few adjustments to xfce4. It’s not that different from Gnome 2 which she was used to a few years back. Long term… I think future laptops in this household will have the best GPU and video RAM that I can justify without going “gamer” level.

No Responses Yet to “Hypothesis: Why Chrome and Firefox Perform So Poorly in Ubuntu Unity”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: