Is there a way to limit cpu usage per tab in Firefox?
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.
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
.