Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely slow startup with uBlock Origin #252

Closed
jetwhiz opened this issue May 28, 2015 · 35 comments
Closed

Extremely slow startup with uBlock Origin #252

jetwhiz opened this issue May 28, 2015 · 35 comments

Comments

@jetwhiz
Copy link

jetwhiz commented May 28, 2015

When starting my browser without uBlock Origin enabled (and no ad blocking software at all) my browser is ready to go in about 10 - 15 seconds, however with uBlock Origin enabled it takes around 35 - 45 seconds (with the same settings and tabs open).

When I try this with uBlock instead of uBlock Origin the browser is ready in 10 - 15 seconds (the same as with no ad blocking software at all). This is with the same filters set for both uBlock and uBlock Origin. It seems something specific to uBlock Origin that is taking a very long time to load that does not exist in uBlock.

During the 35 - 45 seconds of waiting with uBlock Origin, Firefox is using ~15% processing power consistently. This is on a Windows 8.1 machine with Firefox 38.0.5 (latest).

@gorhill
Copy link
Owner

gorhill commented May 28, 2015

uBlock and uBlock Origin are essentially the same core code... Difference at this point is merely UI.

What version of uBlock Origin?

@gorhill
Copy link
Owner

gorhill commented May 28, 2015

c

@jetwhiz
Copy link
Author

jetwhiz commented May 28, 2015

I have the latest versions available from the Firefox add-ons website, which are:

uBlock Origin: 0.9.8.1.1
uBlock: 0.9.1.0.1

I've noticed this issue ever since I started using uBlock Origin a few weeks ago (I was using uBlock before that). I got sick of waiting for the startup so I switched back to uBlock and the problem disappeared. Then I experimented with uBlock enabled, uBlock Origin and neither enabled and the results were all very consistent (as mentioned above).

@gorhill
Copy link
Owner

gorhill commented May 28, 2015

I would need to see exactly all your settings, that's not normal. Even 10-15 seconds for uBlock is way more than I would expect. What are your h/w specs?

Again, exactly all your settings.

@gorhill
Copy link
Owner

gorhill commented May 28, 2015

One thing which would be interesting to find out, is the size of the sqlite db used by uBlock. On Windows, it is located at (as per this):

%APPDATA%\Mozilla\Firefox\Profiles\[profile name]\extension-data\ublock0.sqlite

@jetwhiz
Copy link
Author

jetwhiz commented May 28, 2015

For me the 10-15 seconds is normal, since I have ~530 tabs in tab groups and it takes about that long to load the browser generally (even without addons). The bug report is mainly that uBlock Origin is taking 35-45 seconds (much longer than no plugins, and much longer than uBlock -- both about 10-15 seconds). Basically, uBlock adds no additional overhead to browser startup time, while uBlock Origin adds an additional 20-30 seconds to startup time.

My ublock0.sqlite and ublock.sqlite files are both about 9MB in size.

For h/w specs:
Intel QuadCore 2.7 GHz, 16 GB RAM, Seagate Momentus Hybrid @ 7200 RPM

@0xBRM
Copy link

0xBRM commented May 29, 2015

@jetwhiz Damn, mine's 24.3, so it's most likely not that.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Intel QuadCore 2.7 GHz, 16 GB RAM, Seagate Momentus Hybrid @ 7200 RPM

Ok you've got better specs than mine, and my Firefox starts within one second typically. Since I can't reproduce your scenario, what would help is for you to install prior versions of uBlock Origin and see if there is one which can be identified for the slowness (use "binary search", i.e. install 0.9.6.0, then if issue is there install 0.9.4.0, if not 0.9.7.0 etc. both uBlock are same at 0.9.3.0)

If you do so, beware though: with uBlock/uBlock Origin, the first launch is always the slowest, because all filter lists need to be compiled. For subsequent launches, it will be faster because the compiled versions are cached. And when a selfie is available -- which will happen after a few minutes with no change/update to the filters lists -- the launch time will be even faster. As said, uBlock/uBlock origin loading code is still pretty much the same, so to get such a large gap is difficult to explain.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

I have ~530 tabs in tab groups and it takes about that long to load the browser generally

Not sure what "tab groups" are. Are they tabs with content in them? I mean if you would go to uBlock's logger, would these tabs be reported in the logger's dropdown tab list without having to bring these tabs forth first? (in other words, are they merely some sort of bookmarks until you open them?)

@jetwhiz
Copy link
Author

jetwhiz commented May 29, 2015

Here is what I get for the different uBlock Origin versions:

v0.9.6.0: ~15 seconds (same as no add-ons and uBlock)
v0.9.7.0: ~15 seconds
v0.9.7.5: 60+ seconds (browser freezes up every time I start, consistently takes over 60 seconds to start)
v0.9.8.1.1: 35-45 seconds (much better than 0.9.7.5, but still much slower than uBlock)

There is something going on with the 0.9.7.5 version that is causing all kinds of havoc with my browser. Whatever was changed between that and 0.9.8.1.1 helped the issue, but is still much slower than before.

For tab groups, they are treated similar to open windows/tabs -- meaning that their sessions are restored when you restart the browser with "Show my windows and tabs from last time" selected in options.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Thanks for taking the time to narrow this.

I will code review all the changes between 0.9.7.0 and 0.9.7.5 and see if there is something.

@gitarra
Copy link

gitarra commented May 29, 2015

Tab groups can be opened by pressing CTRL + SHIFT + E. There is also a menu button for it in customize menu and if you have overflowing tabs in the tab list dropdown.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Ok, for now the only spot I can see which could be responsible is e0284b8#diff-ce215d94a52d449f1a34f292126608d7, which is code to fetch a tab title. The fact that you launch with over 500 live tabs makes this even more likely to be the issue. (by the way, why not have the tabs load only when you activate them? i.e. "Don’t load tabs until selected")

I will see if and what can be improved, but the title fetching is already done in a lazy way in the core code, I suspect the overhead is rather on the platform-dependent code for Firefox.

@jetwhiz
Copy link
Author

jetwhiz commented May 29, 2015

I do have "Don't load tabs until selected" checked, and none of the tabs load until they are activated (when I focus on their tab). The slow startup in general is mainly because the session is so large (almost 1MB in size), so the fact that all of the tabs exist must be loaded into the browser (along with their session data, etc.). With the session cleared (all of the tabs closed) my browser only takes about 1 second to start.

Hopefully this is the issue though ... if you need me to do any other testing just let me know and I'll help out where I can. Thanks for looking into this for me!

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

I do have "Don't load tabs until selected" checked, and none of the tabs load until they are activated (when I focus on their tab)

Ok, good to know, I will take this into account for the fix. There might be another area to also revise to help improve launch performance for your case.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

There might be another area to also revise to help improve launch performance for your case

I have to correct myself: the Firefox platform-dependent code is correct, it will mind only the tabs which are not pending, i.e. the tab title code above should not be an issue -- only one tab will be worked on at launch even if 500+ more are pending.

In doubt, I d/l Firefox 38.0.5 to see if it worked as expected and it was fine. So now I wonder if the fact that you used "grouped tabs" is how the issue manifest it self. I never used this feature, I will have to understand how this work first.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Kind of back to square one, as I can't see how the tab title code could be an issue.

The cause of 0.9.7.5 slow launch could be related to this silly regression bug, fixed in 0.9.8.0.

For 0.9.8.1 no being on par with 0.9.7.0, I will have to dig more, I can't think of anything for now.

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Well I looked at net changes between 0.9.7.0 and 0.9.8.1 (git diff 0.9.7.0 0.9.8.1) I can't see anything which could explain this.

Now like all bugs, it comes down to me being able to reproduce. I am nowhere near having access to a set of 500+ grouped tabs.

@jetwhiz
Copy link
Author

jetwhiz commented May 29, 2015

You might be right about the 0.9.7.5 just being related to the regression, since the browser freezes during loading and the 60+ second startup time could just be explained by that.

The thing that is strange to me is the issue doesn't exist in uBlock, even though they are so similar as you've said. Is there an easy way to compare the code between uBlock (latest) and uBlock Origin (0.9.8.1) to see if there's anything there?

Are there any plugins or settings I can install that can help to debug the issue and see where the slow startup is coming from?

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Did you look if the browser console (ctr-shift-j) says something noteworthy for the pathological case?

@jetwhiz
Copy link
Author

jetwhiz commented May 29, 2015

I don't see anything that stands out.

One surprising thing is that I think Firefox is requesting all of the favicons for my tabs upon browser startup, since I see a bunch of these errors for tabs that aren't activated:

This site makes use of a SHA-1 Certificate; it's recommended you use certificates with signature algorithms that use hash functions stronger than SHA-1.[Learn More] favicon.ico

Could uBlock be triggering upon favicon request?

@gorhill
Copy link
Owner

gorhill commented May 29, 2015

Could uBlock be triggering upon favicon request?

Doubful. I put a breakpoint in the code which is executed at launch to initialize the tabs, and only active tabs were seen by uBlock.

Favicons are pulled using behind-the-scene requests. Is it possible these behind-the-scene requests are blocked by uBlock and not uBlock Origin? (behind-the-scene is whitelisted by default).

@hairycactus
Copy link

Not sure if my experience is related ... My Firefox is configured to start with only 1 loaded tab (Google Search), so my FF starts up in 2–3 secs.

But since uBlock Origin v 0.9.7.5 (from GitHub) & v 0.9.8.1.1-signed (auto-updated via AMO), my FF has been experiencing relatively sustained spikes in RAM use, as well as periodic spikes in CPU usage (12–15%). During normal browsing (5–8 loaded tabs), my laptop's fan would rev up noticeably as long as uBlock Origin is enabled. It wasn't like this before v 0.9.7.5.

When I try uBlock 0.9.4.0 (from GitHub) with identical filter lists, everything behaves as per normal. There is no unexpectedly high RAM usage or periodic CPU spikes, & my laptop fan stays quiet (thankfully).

Below shows sample RAM usage (observed at 5 secs interval) as given by about:addons-memory (add-on), when only 1 tab is open (15–16 requests blocked) & FF is then left to idle.

  • uBlock 0.9.4.0:
    678 KB, 634 KB, 658 KB, 638 KB, 626 KB, 624 KB, 625 KB
  • uBlock Origin 0.9.8.1.1:
    1.53 MB, 1.24 MB, 870 KB, 675 KB, 604 KB, 591 KB, 660 KB
    [slightly worse trend (ie. even higher RAM use) observed for v 0.9.7.5]
  • Firefox: 39.5 MB
  • Next Highest RAM Consumer (the add-on varies): 1.48 MB

Remarks:-

  1. In between testing the RAM usage of uBlock vs uBlock Origin, I cleared the browser cache, as well as performed Global Garbage Collection, Cycle Collection, & Minimize Memory Usage.
  2. The above is when only 1 tab is loaded. With 5–8 tabs periodically opened & closed, uBlock Origin's RAM use can hit double digits (MB), such that it easily becomes the highest RAM consumer after Firefox itself.
  3. My specs: FF 33.1.1, Win 7 SP1 (x64). I was thinking that the unusual behaviour is perhaps because uBlock Origin isn't fully-compatible with legacy FF versions anymore. It could be a total coincidence that the sudden change occurred only since v 0.9.7.5, as also experienced by jetwhiz but with FF 38.0.5 (start-up slowness).

@gorhill
Copy link
Owner

gorhill commented May 30, 2015

uBlock Origin isn't fully-compatible with legacy FF versions anymore

Can you elaborate?

@gorhill
Copy link
Owner

gorhill commented May 30, 2015

When I try uBlock 0.9.4.0 (from GitHub) with identical filter lists, everything behaves as per normal. There is no unexpectedly high RAM usage or periodic CPU spikes, & my laptop fan stays quiet (thankfully).

It's the same core code. I sense with all these statements some new myths in the making. Let's stick to very hard measured data please, I never relied on "computer fan" test to benchmark uBlock against other blockers, only hard objective data which others can replicate. The benchmark which I did come up with I ensure I could replicate them all the times myself first by following the steps I wrote down. It's a whole lot more work, but you can trust you are closer to reality as a result, not fantasy.

What you offer is no methodology, there is no way anybody can replicate this, there a lot of factors which would need to be spelled out first, including whether there is a selfie, whether the filter lists are all compiled, whether the update kicks in at exactly the same time in all tests, and whether there are filter lists marked as obsolete, and exactly which URL is open, did you restart Firefox after enabling the add-on, etc.

Here is an example of a reproducible benchmark: https://github.com/gorhill/uBlock/wiki/Firefox-version:-benchmarking-memory-footprint. You can try it and you will get the same results. There is way too many missing details in the figures you offer. You need to provide a very detailed step-by-step that anybody else can follow, which is not the case with what you offer. Also, about:addons-memory is unreliable, it does not report the proper memory footprint, there is no way uBlock uses less than 1 MB, more like 20-something MB on Firefox 64-bit. To use about:addons-memory just show how easily people are fooled into trusting blindly stuff out there, and worst to draw conclusion from flawed tools.

There are a lot of people who thinks Adblock Edge is much more performant than Adblock Plus (acceptable ads disabled), this shows that you can't trust subjectivity, only very rigorous tests. If you come up with something which yourself and others can replicate, with exact steps and all relevant configuration details, that is usable, short of this is to wander in myth-making realm.

@hairycactus
Copy link

@gorhill — A few sub-versions ago, I recall reading something to effect in README.md at your Changelog & then also at uBlock Origin's homepage.

Here it is ...

https://github.com/gorhill/uBlock#firefox
"Alternatively, you can install chrisaljoudi/uBlock from Firefox Add-ons homepage. Slightly different feature set, same performance, proper support for legacy Firefox-based browsers."

Did I wrongly interpret the last segment wrongly (highlighted in bold above) ?

Incidentally, I have this uBlock Origin toolbar badge notification-displacement since v 0.9.4.3 (mid-April 2015). Sometime after reading your README.md, I tried uBlock & its badge-display is OK (ie. no displacement) right up to the current stable version (0.9.4.0).

Nevertheless, I continued with uBlock Origin until 0.9.7.0. It was v 0.9.7.5 onwards (high RAM use) that made FF & my laptop not so conducive to use.

@gorhill
Copy link
Owner

gorhill commented May 30, 2015

Did I wrongly interpret the last segment wrongly (highlighted in bold above) ?

Yes.

You said:

uBlock Origin isn't fully-compatible with legacy FF versions anymore

It was never fully compatible. Full support for legacy FF was added to uBlock after the fork, and that full support was a UI thing, to have a button showing on the toolbar -- FF legacy versions were missing that button.

@gorhill
Copy link
Owner

gorhill commented May 30, 2015

It was v 0.9.7.5 onwards (high RAM use) that made FF & my laptop not so conducive to use.

Yes, I am pretty sure this was because of the regression bug pointed out above. This has been fixed in 0.9.8.0.

As said, I diff'ed 0.9.7.0 with 0.9.8.0, and if you leave out translation work and other unimportant UI stuff, there is nothing in core code which can support that uBlock Origin performs worst than uBlock. There is not many changes really in the core code, anyone can check: git diff 0.9.7.0 0.9.8.0 platform/firefox and git diff 0.9.7.0 0.9.8.0 src/js.

@gorhill
Copy link
Owner

gorhill commented May 30, 2015

One surprising thing is that I think Firefox is requesting all of the favicons for my tabs upon browser startup, since I see a bunch of these errors for tabs that aren't activated

You could put a break point into uBlock to validate that all these tabs are seen as being active by uBlock, which would explain the longer boot time. The line to which a breakpoint must be set is:

var µb = µBlock;

At this point, uBlock is fully loaded, and it's finding out which tabs are active, and for all active tabs, it will inject its content scripts + other housekeeping stuff (thus overhead).

If ever it is really going through all the tabs (i.e. the tab.hasAttribute('pending') is false), then the other step is to find out if the other uBlock is also seeing all the tabs.

@hairycactus
Copy link

@gorhill — Thanks for your advice & explanations. I wasn't aware that about:addons-memory is flawed. I shall study the benchmark page for reference.

However though, I wasn't really trying to benchmark uBlock Origin vs. uBlock per se. I'm more interested in how uBlock Origin has been evolving, & what actions I should take to adapt to uO's growth.

there is no way uBlock uses less than 1 MB, more like 20-something MB on Firefox 64-bit

My FF is 32-bit. So I'm not familiar with how uBlock behaves in 64-bit FF.

It was never fully compatible.

Tks for the info. Might it be good to put a note somewhere to indicate the FF versions (or the lowest FF version) that are fully-compatible with uO ? For instance, many add-ons provide such info at AMO, & I personally find that helpful.

As an end-user with no IT training, I don't expect or insist that my own user experience (or even awkward informal tests) necessarily extrapolate to other users. This is the 1st time that I'd ever mentioned high RAM use as of v 0.9.7.5. (I shall continue to monitor, since you reported that this has been resolved.)

Moreover, I have never discussed uO issues except at this GitHub page, where you can monitor & quickly dispel user errors or unintentional misconceptions — which in this case, unfortunately appear like "new myths in the making" ... & I'm glad you stopped the oven. :) I hope that this clarifies. Thanks !

@jetwhiz
Copy link
Author

jetwhiz commented May 30, 2015

I wish -- it would be a quick explanation -- but uBlock and uBlock Origin both have behind-the-scene set. I didn't customize anything in either addon except for the filter lists (and they both have the same filters selected).

@gorhill
Copy link
Owner

gorhill commented Jun 1, 2015

Can you test dev release? Some work has been done to fix #266, and there is good chance the slowness here is related to the same underlying issue.

@gorhill
Copy link
Owner

gorhill commented Jun 15, 2015

No feedback for more than two weeks, I will assume that in all likelihood it was related to #266.

@gorhill gorhill closed this as completed Jun 15, 2015
@ShadowDuke
Copy link

I have the same problem. I even did a clean chrome install and also new origin install. Without the addon my browser doesnt hang at startup. With addon enabled i cant to anything for almost a minute, like op said.

@gorhill
Copy link
Owner

gorhill commented Nov 29, 2017

@ShadowDuke you provide no actionable information. I can't reproduce your described behavior. There is likely something else specific on your side causing this, quite probably unrelated to uBO. You will have to investigate yourself and provide useful and actionable information if you make the case the issue is with uBO. Use the Gecko profiler to find out whether uBO is behind your slow down, that is the only way to move your issue forward. uBO makes use of indexedDB, so see if removing/reinstalling uBO (restarts the browser in between) solves your issue, I suppose it's possible a corrupted indexedDB may be causing all sort of negative issues (don't forget to back up your settings before un-installing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants