Open Bug 1140892 Opened 9 years ago Updated 2 years ago

Performance in not active tab is extremely slow in comparison with active tab

Categories

(Core :: Networking, defect, P3)

36 Branch
x86_64
Windows 7
defect

Tracking

()

UNCONFIRMED

People

(Reporter: crimsteam, Unassigned)

References

Details

(Whiteboard: [necko-backlog][presto])

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20150305021524

Steps to reproduce:

Hi, some time ago (mabye ~2 years or more) I make privite script for Greasemonkey/Scriptish and run it in Firefox (don't remeber what version last, but I started from FX2, jump to FX3, jump to FX4, etc.). This script is simple, just change in page some URL (goes to other URL on the same domain), sometimes submit forms etc. I run this script more than one tabs, minimum 10, but in past I run it on 50 tabs (after changing my PC to Intel i-7 2600K 4/8 core, 8GB RAM, and connection 80Mb/s).

And what can I tell that in past don't have any problem on Firefox, everything works like a charm. But now its realy, realy slowly, test this on latest Firefox 36 and Greasemonkey/Scriptish, without any other extension. I noticed that Firefox make network action (like change URL or send form via POST) extremely slow on all not active tabs - but without tab what is actually active. So if I run 10 tabs (tab0-tab9), and active tab9 only this tab make action "normal", this means the same as I open only one tab (active this tab) and run script << "loading indicator" changing it's state fast. But all other not activate tab works very slowly, and when I go from tab9 to tab0 then tab0 works with normal speed and tab9 will start works slowly (like all other not activated tabs).

To make some comparision I make this script for last stable Chrome 41 and Tampermonkey addon, and results are terrible for Firefox. I know Chrome is multiprocess, it's very responsive, but like said before, in past Firefox was the same and I never have any problem with this browser. This is my results (Time from Start/Stop action on active vs. not active tab) in both browser:

Firefox
Start time 2:47:30
End time (active tab) 2:53 << spend 5 minutes 30 sec
End time (not active tab) 3:08 << omg, spend ~20 minutes (15 minutes more than active tab)
* - my RAM for Firefox process jump to 1,2GB but I run Minimize memory on about:memory page, unfortunately this not help.

Chrome
Start time 3:15
End time (active tab) 3:19 << spend 4 minutes
End time (not active tab) 3:22 << spend 7 minutes (3 minutes more than active tab)

As we see spend time for active tab in Firefox is not so big (comparing to Chrome), but for not active tab is horrible. I don't know what I should think about this. Is there on Firefox any preferences in about:config page responsible for performance in active tab vs. not active tab? Because now it looks like that not active tab are specially slowing, but why?

I can only add that after I start script on this 10 tabs, and 9 tabs finished his job, but only one left (let say tab1), and this tab1 is not active then I still see that this tab working slowly, event if other tabs finish his job and don't need power resource from pc/internet connection. If I active this tab1 then it will start working with normal speed.

Any comment, solution, or other advice for this strange situation?

=== 
Update:
===

I make some dig and noticed that after Firefox4 (so first version was Firefox5) you make some improvements for performance (especialy for not active tab) like we see here: http://website-archive.mozilla.org/www.mozilla.org/firefox_releasenotes/en-US/firefox/5.0/releasenotes/

- Tuned HTTP idle connection logic for increased performance
- Background tabs have setTimeout and setInterval clamped to 1000ms to improve performance

OK, in my script I use setTimeout a lot of time, setInterval only one, but problem is that I always pass more than 1s, random value from [1,1.1,1.2] so in theory it should not have any effect to my works. Maybe Greasemonkey/Scriptish use this function when injected stript to page so I make another test, I change dom.min_background_timeout_value to 4 (the same as we have in dom.min_timeout_value). Here is the result in last stable Firefox36 and Nightly (today), but run script only in 5 tabs to not waste much time:

Firefox 36
Start time 20:48
End time (active tab) 20:53 << spend 5 miutes
End time (not active tab) 20:58 << spend 10 minutes (5 minutes more than active tab)

Firefox Nightly (without e10s)
Start time 21:02
End time (active tab) 22:06:40 << spend 4 miutes 40 seconds
End time (not active tab) 21:12:10 << spend ~10 minutes (~5 minutes more than active tab)

As we see this preference change don't make any effect in my case. I still see that Firefox make some throttle for network operation for all not active tab << this operations are always slow.  This "sleeping" can be somehow controlled? Because now this works worse (== slow) than I noticed in Firefox2/3/4. I understand why you try limit consuming resources from not active tab but now using FX for making some automated action in short time was completly killed (we waste to much time as you can see in my posted results). In past I run this script on Sempron 2500 with 512 MB RAM and it works better than on actual machine and Firefox (obviously something is not working as it should). In past on Firefox 4 I run this script in 50 tab and still don't have any problem... now it's completly unusable and I don't know how can I fix this.
Component: Untriaged → General
I make more research around this problem. First, I make this test case (script), action for once tab:

- take free account from 50 defined accounts and log this account (via POST)
- script one time change url to other sub page (via changing pathname)
- remember some data from this account
- make logout (via GET)

I don't make action with 0 timeout but always set something from 1 - 1.2 seconds to make sure that GC will have change done his work etc., because I remember in past Firefox has some memory problem if we don't give them some free time. But I set in about:config this line dom.min_background_timeout_value to 4, to make sure that addons don't slow in not active tab.

This test case was run in that scenerio:

- open 10 new tab with start page (the same domain)
- reset remember data and start script (remember time start)
- refresh 10 page (after this action each tab start his job)
- after all 50 account was checked remember time end

And use this machine: Intel i7 2600K (integrated graphic card), 8GM RAM, 80download/10upload Mbit network speed (real is 67/8 and 23ms ping)

OK, I start test Firefox from version 3.6 to last Nightly 39 and can write this:

the fastest version what I found: 45-50s spend to check all 50 account (this result is repeatable and visible to the naked eye)
Nightly 39 spend 2:30 minutes (sometimes more)

Like you see this regression is terrible. I try figured out what is happen in this Nightly by using Dev Tools (Network) and see that all not active tabs have big time between last and next request to serwer << I see big empty white space beetwen this two action. This space is bigger if open more and more tabs. And this behaviour can be observer without any tools, Firefox make conection to serwer (we see loading indicator rotates around) but completly finish this action after spend much more time (I don't know why or for what we must waste this time). I try check the same on fast Firefox version (via Firebug) and don't see this slowing action (or see, but they are very minimal).

So first I think that exist some limit how many connect can be done to the same server, so change this value on about:page to more connection, but this doesn't help for anything. So I repeat test for 10 tab, but in each tab I open and use page with different domain (page1, page2, page3, etc... to page10) but get the same result. My conclusion is two:

- last Firefox slows because very offten run new GC or new cache backend is slowly
- last Firefox slows because have some limit for process a large number of network connections (but only for not active tab because I see that active tab newer slows)

This are only my hypothesis, but I don't have more power(knowledge) to determinate more detail explanation in the programming site. But I don't need them to see that 45-50s version beat 2:30s version, especialy if this oldest browser version is more responsive then actual (when all tabs works).

In conclusion, I know that mabye 1% or less use Firefox to automate his job, but if we know WWW platform language then using browser for that job is very easy. Now (in 2015), after making all of this progress, improvements, and other optymalization, I get noticable worst result than version from 2012 year.   

So, Boris, I know only you from Mozilla team who has big knowledge around Firefox code (WWW/performance), are you interested to check this case more closer? If it neccessary I can even make two portable version of fast/slow Firefox version, set this browser to make this test case and send all to you for test (with instruction). The differences have be seen very quickly without any additional tools. If it neccessary I can make and send to you video from this action, snapshot from Firefox RAM or any other infos what you need (including give access to my PC via TeamViewer if its necessary). If you don't have time to analyze this then please delegate someone from Mozilla team (person from performance or networking) to take closer this problem. If anyone will be interest to fix this bug then I can spend more time and make more test case that showing this inefficient behavior.
Flags: needinfo?(bzbarsky)
This is a necko question, sounds like?
Flags: needinfo?(bzbarsky)
Component: General → Networking
Product: Firefox → Core
Whiteboard: [necko-backlog][presto]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
See Also: → 1605313
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.