A Suggestion for Mozilla

In the next version of Firefox, can you please put in a little utility that tells me which tab in which browser instance is causing it to eat up the CPU? Just this blog post took several minutes to create…

[Update Tuesday morning]

Folks, note that this is not a memory problem (I’ve got eight gigs of RAM) — it is a CPU problem. I have a quad-core Phenom II, and it still gets brought to its knees, at least in Firefox, but sometimes it slows down everything.

28 thoughts on “A Suggestion for Mozilla”

  1. I’d go to IE (not kidding) if you’re on a windows box. IE hasn’t had the major memory leak problem since IE 7.

    IE 9 has been even more stable for me than both chrome and mozilla, enough that when I changed computers I didn’t bother installing Firefox at all.

  2. It’s Hobby Space.. it’s always Hobby Space. Clark loves to embed a flash video in every post and if there’s 30 of them on the page things get bad. 🙂

    Alternatively, switch gmail to html view, see if that helps.

  3. I am not on a Windows box. IE is not an option at all, let alone a desirable one…

    Trent, I want what I asked for — a utility in the browser that tells me which tab to shut down so it is no longer bringing my machine to its knees. Why is that too much to ask for?

  4. Rand, I don’t think they actually do the appropriate accounting. If they do, there’s probably an addon available. I don’t know about you, but on one of my computers Firefox occasionally locks up and the cpu is fine. It’s actually some sort of deadlock, and it seems to be at the OS level.

  5. I don’t think they actually do the appropriate accounting.

    Well, I don’t see any reason that they can’t. I’m requesting that they start doing so, or I’m going to start seeking another browser.

  6. I am basically pulling this out of my ass, but I think it has to do with FireFox not giving each tab its own thread. That’s why you only see one Firefox process no matter how many threads or windows you have open. And threads are the main tool used to manage out-of-control code.

    Apparently this is a huge problem to solve, but I see some references saying that threaded FF will happen Real Soon Now.

    I do not understand why this is as difficult as it in fact seems to be, but there you go.

    Two related features I’d like:
    Sometimes I have so many tabs open the tab for the site I’m looking at gets shoved off to the side. I’d like to be able demand that tab be scrolled to.

    And here’s the one I really, truly want: I want to be able to identify which tab is playing whatever audio I’m being blasted with. Happened to me again while researching threaded tabs: opened a dozen tabs, and one of them had an autoplay audio file. And, of course, of all the tabs I’d opened for my search, it was the last one I closed.

  7. I’d noticed issues whenever I left Instapundit open for too long–I think it was something in the Pajamas Media ad system in the sidebar. Could be flash, could be some epicly incompetent javascript. But I agree with Rand, and ideally Firefox might include tiny little indicators bars on top of each tab showing how much processor power/memory each is using.

    @DJMoore: People who deliberately embed autoplay audio/video should be locked in a room where said audio/video plays on an endless loop for at least a week.

  8. Totally useless (to this discussion) aside:

    “That’s why you only see one Firefox process no matter how many threads or windows you have open.”

    Nope, that’s because you’re doing it wrong. (Assuming linux), do “ps -A | grep firefox”, then to “top – p xxxxx” where xxxx is the process id number found by ps. Then in top press H to switch to threads view. You will see tons of threads. I agree that none of those are individual tabs as far as the online info indicates, but firefox is multithreaded.

  9. I suspect you’re on Linux, but on my Macs, I’ve actually removed the Flash components from /Library/Internet Plugins.

    On the rare occasions that I actually WANT to see the Flash content on a page (like a restaurant site, where all I want is the frickin’ hours of operation, but I have to watch their frickin’ animation to get there), I select the menu ‘Develop > Open Page with > Chrome’. Since Chrome has its own Flash implementation, I can see what I want, quit Chrome, and return to Flash-free browsing.

    Result: fewer crashes, fewer “what the heck is chewing up my CPU”… and, as a bonus, my browser TELLS the site that I don’t have Flash, so it’s one more vote against their continuing to use it. (Not that it does any good…)

    Learned this from DaringFireball.com

  10. I’m running Ubuntu and Firefox on an Intel laptop, and I very highly recommend Flashblock. It’s available through Firefox Tools. Instead of each Flash animation, you see a little symbol. If you want to view a Flash animation or video, just click on the symbol.

    I don’t use tabs, and Flash still causes things to slow down. And yes, there usually is something on Glenn Reynolds’ page that slows things to a crawl if you leave it open for too long, and it’s almost certainly Flash-based.

    I lifted my beer in a toast to Steve Jobs when I read that the iPad does not support Flash.

    (BTW, BlockSite is a useful, add-on, too. It’s kinda fun to put the most obnoxious ads on a blacklist.)

  11. Slightly more convenient than Stephen’s method is FlashBlock

    With most web sites where you actually want the flash content, turning it on is just one extra click. It’s not perfect: occasionally a page will depend on Flash applets for functionality *and* not give you any visible place to enable every such applet, in which case “whitelist that web server” or “don’t go back to that web server” become the only options. But web surfing has been about ten times more stable and five times less annoying since I started using it.

    It’s possible for Javascript rather than Flash to be the culprit… but honestly, I’ve never really seen that happen. Even broken infinite-looping pages just trigger Firefox’s “this script is sucking a lot of CPU, are you sure you want to keep running it?” dialog.

  12. Well, I went to Firefox’s add-ons site and looked up cpu usage. The two at the bottom (status bar ex and system usage) look the most like what you’re talking about. That’s just from reading the descriptions, though — I haven’t tried them out.

  13. I use Flashblock, with a very few exceptions on the whitelist, and I’ve had hardly any memory-related issues running Firefox.

  14. This is, as one of the commenters said, incredible, but I think it is worth a try:
    http://thinkmoult.com/2009/02/24/tech-tip-speed-up-firefox-to-use-less-cpu/

    Mozilla Firefox is a popular browser and so it should seem a sad issue when people experience 30% or more CPU usage. Some testing has revealed the culprit to be tabs. Not just tabs, but specifically the loading animation – those spinning circle things – that cause this CPU usage.

    Are you a victim of this issue? It’s simple to test. Open up about 3 or more tabs and tell them to load non-existent pages. This will cause Firefox to load them until they timeout. During this period, quickly fire up an xterm and start up “top”. Check the X and firefox CPU usages. If you are on Windows, press control-alt-delete and go to system processes, check the CPU usage. If you see spikes (sudden surges in CPU % usage), it’s likely it’s because of Mozilla Firefox.

    Alright. How do I fix this issue? Well, you’ll have to remove that annoying loading animation.

    You can click on the link to read about the Linux solution. I hope you find it helpful.

    As to your actual request, googling reveals a lot of discussion about Firefox’s ability to be a CPU hog and Firefox’s lack of ability to show the information you want. But I do agree with the above comments about Flash – it is also a common culprit and flashblocker does wonders for websurfing. I use a flash monitor, which notifies me when flash uses more than x% of the CPU and it gives me the option to kill flash.

  15. I have to second Rands request for an indicator of which tab is burning CPU, and add per tab memory.

    Meanwhile, noscript, adblock+, or similar may help.

    Also, firefox has gotten away from the dangerous practice of running most plugins in the same process space as the browser. Killing the plugin container will kill plugins in loaded tabs while leaving the browser intact. This doesn’t give per tab control, but can at least tells you browser vs. plugin load.

  16. FlashBlock (or similar ClickToFlash for Mac) is slightly more convenient. But removing it has a salutary effect on the websites using Flash. To quote Gruber:

    Without Flash installed, Safari effectively tells websites you visit, “Hey, I don’t have Flash installed”, which allows the sites to send alternative content. Static images instead of Flash for ads, for example. With ClickToFlash, Safari is effectively telling websites you visit, “Yes, sure, I have Flash installed,” but then not actually loading Flash content.

  17. DJMoore Says

    I want to be able to identify which tab is playing whatever audio I’m being blasted with. Happened to me again while researching threaded tabs: opened a dozen tabs, and one of them had an autoplay audio file.

    Yes, please!

  18. There’s a little bit of misconception here, perhaps, in that the problem is less CPU usage per se than interruptibility. Any process that is set to update as fast as possible will consume all the CPU cycles if nothing else is running.

    What you want, however, is for any such process to be fully interruptible, in the sense that if you want something else done — move a window, raise a window, click a link, echo what you type on the keyboard — the scheduler will immediately bump the trivial task out of the execution queue and shove your task in. If that takes a millisecond, the computer seems responsive and alive. If it takes 5 seconds, the computer seems sluggish, and if it takes more than 1 minute you’ll probably consider the computer locked up and perhaps reboot it.

    So the real offense is applications that are not playing nice with the scheduler, which perhaps means they are ignoring signals, or an inept scheduler, or perhaps applications that have made operating system calls that have hung. In the latter category my experience over the years is that for Internet-using applications a call to resolve a name to an IP address, a DNS call, appears uninterruptible in some really stupid way, easily hanging at least the application. Another problem is an application that suddenly asks for a massive amount of memory or suddenly wants a lot of child proceses started (e.g. the notorious fork bomb). The OS attempts to comply, which involves lots of housekeeping, swapping of other jobs in and out, disk I/O galore, and a variety of other low-level stuff that can be uninterruptible. (For example, if FF suddenly asks for 2x physical RAM, and the OS swaps out the shell window in which you haven’t’ typed for 20 minutes to reclaim its RAM, and then you in rage attempt to raise the shell window to type ‘top’ — now the OS has been asked to swap back in the shell window while it’s in the middle of swapping everything out to comply with the FF request — a big mess.)

    But it can be expected that applications will ask the OS for more than the hardware will provide, and for programmers of application foo to pay little attention to whether some other application bar can interrupt it. These are operating system problems, and the flaws Rand mentions are, I suggest, operating system flaws. A good robust OS should not allow misbehaving applications to slow or stop the OS and make the computer unresponsive.

    I realize I’m dumping on Linux here, and I yield to no one in my Linux fandom in general, but my impression is that the desktop distributions have cut corners on the robust multi-user environment aspects of the OS in order to focus on the personal desktop experience, and it may be coping effectively with more powerful and sophisticated hardware and applications hasn’t gotten the development attention it should.

    I should also mention that part of Rand’s comment seems purely directed at FF in that he suggests only FF slows down when one of the pages it attempts to load is screwy. This is indeed an application issue, not an OS issue, but the tricky bit here is that FF is attempting to act like a mini-OS — a general recent trend, as web pages have begun acting more and more like applications than mere content — and this is a very hard thing to get right.

  19. Carl, sometimes CPU usage, rather than responsiveness or prioritization, is really the issue. One time this is true: you are using a laptop and you want the battery to last as long as possible. Also: Rand might also simply be interested in which tab has more computation (for good or evil) going on than he expected.

  20. Bobwun, no one doubts CPU usage per se is of theoretical interest, or of practical interest in some particular applications. Laptop usage is perhaps one of them, although the metric you want is efficient CPU usage, i.e. how do you get x done with the least pointless computation? (Turn off all visual effects in your window manager is one obvious step.)

    However my impression is that it doesn’t matter much for laptops. I believe the big battery suck for laptops is (1) powering the display, (2) disk I/O, (3) fans, and (4) radio. This is why folks who want to max battery life dim the display at every chance, turn off the WiFi and Bluetooth, and try to avoid disk I/O or even let the drives spin down (of course, spinning up and down really takes energy, so you’ve got to be clever about that). Ideally you’d also like to keep the beast cool to reduce the use of fans, which can involve slowing down the CPU.

    The reason for (2) and (3) is just that doing actual mechanical work, that is moving tiny bits of metal and plastic around, is always more energy costly than just moving electrons hither and yon. The reason for (1) is that in ordinary daylight the amount of light you must produce to compete with natural background is substantial, the LCD panel throws away half of it by definition, and the luminous efficiency of converting electrical power to light is only about 10-20% for the standard fluorescents used to backlight ordinary laptops. The reason for (4) is that generating high-quality radio signals from DC power is also very energy inefficient.

    You’ll note, for example, that the Kindle — which has no moving parts and an “E-Ink” display, i.e. a display that is legible like print because of reflected light, and need not emit any light on its own — can run a week on its (much smaller) battery, provided you don’t use the radio (Internet).

  21. Er…I’m missing where anything (authoritative) there contradicts what I said, Bobprime. Again, I’m not suggesting running a laptop CPU flat-out doesn’t suck up the power — how could it not? What I’m suggesting is that for ordinary situations maximizing CPU efficiency doesn’t seem to matter much compared to the other things I mentioned. I think part of the issue here is definitional: for the most part, getting X done on a laptop requires Y CPU cycles, and you can’t fiddle with Y very much, except insofar as you have operating-system eye-candy (like the visual effects I mentioned) that you can remove. So you’re only for-sure way to reduce CPU usage on a laptop is to attempt fewer tasks with it, i.e. don’t turn it on as much. Not very helpful advice.

  22. It looks to me like it directly contradicts you — you suggested that the mechanical bits (like the fan) would dwarf the energy required to use the CPU, and that’s wrong for many laptops. As for being practical: I recently switched to a laptop for daily use, and it certainly surprised me that flash was draining my battery, and it also surprised me that shutting down idle applications allowed my battery to last much longer before it needed a recharge. I had assumed that if I didn’t hear the fan, CPU usage wouldn’t make much difference.

  23. I don’t recall using the word “dwarf,” bobneplusinfra. But I see we have a miscommunication here. I certainly agree that not asking the computer to do work will lengthen its battery life. I assume what you mean by shutting down “idle” applications is terminating applications that are anything but “idle” in the EE sense (not using the CPU), which are “idle” in the sense that they’re running (using the CPU) but not doing anything you find useful.

    Yes, I agree, not asking your laptop to do stuff you don’t find useful is a good way to save energy. I also suggest not having it stream Youtube videos all night while you go to sleep, for the same reason.

    What I was talking about is how to make better use of your battery while getting the same things done, i.e. reading the same amount of e-mail, downloading the same number of megabytes of Internet pr0n and Barack Obama speeches, and so forth. Enter reducing screen brightness, turning off WiFi when not in use, making efficient use of disk I/O. Is this more clear? It’s the difference between saving energy by installing CFLs and saving energy by turning off the lights.

Comments are closed.