13

Opening 20+ tabs in Firefox inevitably leads to a situation where 2-3 tabs are constantly using a fair amount of CPU, slowing the entire system down. I wonder if it's possible to impose a limit on total CPU time consumed by each tab. I understand it may not be possible to find out how much of that time is consumed by plugins and the like, so I'm OK with limiting only Javascript execution time.

There is this addon called suspend tab which takes the right action but based on a wrong criteria, stopping (and unloading) all inactive tabs after a timeout. However, this feels like carpet bombing: I have tabs with books or articles I'm reading, and most of them are not offensive. I'd rather not have to reload them unnecessarily, as they are often quite big and take time to load.

Note this is different from a popular question about identifying offending tabs. I'm not interested in hunting such tabs manually.

I use Firefox and have no immediate intention to go for a different one. However, I welcome relevant answers for other browsers, because having a browser which goes easy on the CPU may convince me to switch.

2 Answers2

1

You can use the command line utility cpulimit (install by aptitude install cpulimit or brew install cpulimit for OSX) by limiting the maximum CPU usage per tab. Typing about:processes in Firefox will give you the process ids. Assume the offending tab has process id 1234. Then

cpulimit -l 10 -p 1234

would limit that tab to 10% CPU usage.

An alternative would be to start another instance of Firefox or Firefox Developer Edition, put all resource-intensive tabs there and limit the entire application with cpulimit.

ttq
  • 1,063
  • 1
  • 7
  • 5
0

You can use the utilities "nice" and "renice" to set/change the priority of processes so they take up more or less CPU time.

For example this command would set the process with the process ID of 987 to have a priority of 1:

renice 1 -p 987

And this would set the process with the process ID of 987 to have a priority of 19:

renice 19 -p 987

Processes with lower priority values are given more CPU time and processes with higher priority values are given less. Typically priority values range from -20 to 20 and default to a value of 0 if not otherwise specified.