What is Firefox doing now?

I had some time to kill, so I pulled up my system monitor and had a look. One thing bugged me: Firefox was doing something while I was not doing something with Firefox. So I dove into the settings and documentation and this long post deals with all the things I could find.

First thing you should know is that I use nine desktops with compiz expose. I use the desktops to keep my different tasks, leaving everything open all the time and only suspending/hibernating my computer. Now instead of bookmarking pages and coming back to them, I end up leaving the pages I want to use open, things like documentation, how to blog posts and search results. As a result I have a few Firefox windows and a few tabs open all the time. So, on to streamlining the experience!

Possible culprit one: Javascript and Flash
Both can be killed quite easily by using the NoScript plugin, so I installed that. I don't have any flash plugin installed, so that keeps Firefox nice and lean. Only downside: I can only watch youtube videos by downloading them with cclive or youtube-dl, but that also means I can download them before I take a train ride where I don't have internet connection.

Possible culprit two: animated images
If there is a tab in there somewhere which has an animated image on it (like a gif animation) I would have to turn it off. This can be done by opening about:config and find type "animation". After reading http://kb.mozillazine.org/Animated_images_in_RSS_feeds_%28Thunderbird%29 I decided to change image.animation_mode to "once". This makes sure that all gif animations are only played once.

Possible culprit three: Automatic bookmarks, update checks and polling AJAX code
I removed all my automatically updated bookmarks (RSS/Atom feed bookmarks) and disabled all update checks. But if one of the scripts I allow is using some kind of polling AJAX, Firefox would not only use some CPU but it would also generate some packets. To track that, I ran:

sudo dumpcap -w /tmp/firefox wlan0
sudo chown $USER.$USER /tmp/firefox
wireshark /tmp/firefox

Well after waiting for thirty seconds without seeing any packets come or go, I decided to thrown in some test traffic to see if it worked. It seems that there was no traffic coming from my Firefox. However, there is still some activity, Firefox just won't go to sleep.

Maybe there is some kind of update timer going wild. One of things I found was that http://kb.mozillazine.org/App.update.enabled was enabled, and there was no way to disable it in the menu, so I disabled it right there. I don't get my updates from Mozilla, but from the package repository, so checking for a new version is stupid.

This is where I will have to start fishing for option.. the obvious things have been dealt with.

Next up: Anything with update in the configuration name:
http://kb.mozillazine.org/Places.frecency.updateIdleTime will re-calculate the frecency (not a typo) when Firefox is idle. Now frecency calculations are performed every 10 minutes, so it should not be the problem I'm looking for. Still, I only allow places (the location bar system) to look at my bookmarks, which I did after ending up with 2 second delays in the location bar because it was busy loading a database from disk (my laptop disk is slow). After loading all the bookmarks, maybe even noticing my disk is slow, Firefox would decide to keep it in memory: 600 megabytes of useless search cache for normal operation (90 days history, bookmarks etc.).
As the documentaiton states, I'm setting places.frecency.updateIdleTime to zero to disable frecency calculations.

Next up: http://kb.mozillazine.org/Browser.sessionstore.enabled
To be able to restore from a crash, firefox will write down the session every browser.sessionstore.interval miliseconds (10 seconds by default). This must have some effect on CPU usage every 10 seconds I would say. I could turn that off by setting two values to zero: browser.sessionstore.max_tabs_undo and browser.sessionstore.max_windows_undo. (I'm using Firefox 3.5, and the manual dictates this approach for anything 3.5 and above). But I choose to set the interval to something very high, I set sessionstore.interval to 3600000 (one hour). Because I keep more tabs then bookmarks, I can't really disable this without loosing a lot of info once a crash occurs.

It still does not seem to want to sit down and shut up, so Firefox needs even more work. I did a quick check with strace:

pidof firefox-bin
strace -p `pidof firefox-bin`
lsof -p `pidof firefox-bin`

Turns out firefox is constantly polling an internal pipe. This is probably a bad case of mismanaged threads, but I'm not sure. Doesn't seem I can really fix that... yet.