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

Performance regression Lite vs no extension #73

Closed
heubergen opened this issue Sep 17, 2023 · 9 comments
Closed

Performance regression Lite vs no extension #73

heubergen opened this issue Sep 17, 2023 · 9 comments
Labels
external Firefox Specific to Firefox

Comments

@heubergen
Copy link

heubergen commented Sep 17, 2023

I think I found a reproducible performance regression and wanted to know if you see anything from your side that you can fix or if I would have to report it to Mozilla.

Always tested with a fresh profile, only setting changed was "Enhanced Tracking Protection" to Strict (except for the first line). No extensions installed unless specified, no hard refresh:

Test Case Load Event DOMContentLoaded Finish
Firefox fresh profile, no settings changed at all, no extension, first reload of page 4.23s 1.47s 18.5s
Firefox enabling strict tracking test 1 3.38s 1.49s 8.83s
Firefox enabling strict tracking test 2 4.22s 1.69s 9.5s
Ublock Lite basic protection, no filter list changes test 1  10.45s  1.51s  14.37s
Ublock Lite basic protection, no filter list changes test 2  9.47s 1.11s 14.02s
Ublock Lite No protection, permission for all websites revoked test 1 10.27s 1.55s 16.87s
Ublock Lite No protection, permission for all websites revoked test 2  11.20s 1.67s 17.03s
Ublock Lite disabled  2.92s 1.20s 8.22s
Firefox enabling strict tracking test 3  3.89s 1.58s 8.78s 
Ublock Origin, no filter list or setting changes test 1 4.91s 1.38s 9.41s
Ublock Origin, no filter list or setting changes test 2  8.54s 1.34s  15s
Ublock Origin, no filter list or setting changes test 3  5.12s 1.47s 9.67s

Summary: DOMContentLoaded is not affected, Finish has some irregularities so I think Load Event is the best to use for judgement. It seems that Lite has the worst regression, while Origin only has a minor one.

I took the numbers from the network tab of the developer tools.

Tested URL: https://www.tripadvisor.ch/Restaurant_Review-g186338-d10460592-Reviews-Bonoo-London_England.html

Impact: While I only did the extensive testing with that specific URL (because I could feel the longest loading time on tripadvisor), I think that Firefox in general feels slower. But I wanted to give you specifics so I made this tests.

Firefox: 115.2.1esr
OS: macOS 12.6.9

@gorhill
Copy link
Member

gorhill commented Sep 17, 2023

Please use the Firefox profiler to find out whether the issue is in uBO's code or elsewhere.

@heubergen
Copy link
Author

I did check them, but can only see that it spends most of the time with __psynch_cvwait, not sure how one can check what the trigger is of that. I made two recordings and uploaded them:

With Lite: https://share.firefox.dev/3riWPKy
Without Lite: https://share.firefox.dev/3Rpmj3F

@gwarser
Copy link

gwarser commented Sep 17, 2023

Look at parent process. It's in Firefox DNR code.

@heubergen
Copy link
Author

Ah right, so a bug in Firefox or does uBlock use the code incorrectly?

@gwarser
Copy link

gwarser commented Sep 17, 2023

AFAIK if you did not enable anything uBOL only delivers filter list and that's all. All work is done in browser.

@heubergen
Copy link
Author

I've opened https://bugzilla.mozilla.org/show_bug.cgi?id=1853569, hopefully they confirm the issue.

Feel free to edit it if you have a better description/summary etc.

@gorhill
Copy link
Member

gorhill commented Sep 17, 2023

I see at least two obvious performance issues in Firefox's code:

For each network request, it iterates through all the rules to find best match:
https://searchfox.org/mozilla-central/rev/0afa5b067589195a45ed5e858b51a4ee30c8c0a7/toolkit/components/extensions/ExtensionDNR.sys.mjs#1676

For some of the rules containing long list of domains, it potentially (and likely) iterates through all the domains to find a match:
https://searchfox.org/mozilla-central/rev/0afa5b067589195a45ed5e858b51a4ee30c8c0a7/toolkit/components/extensions/ExtensionDNR.sys.mjs#1792

For instance, there is one rule in default ruleset which requestDomains condition contains over 55.3K entries. So just for that one rule (out of over 17K rules), Firefox's code potentially loop over 55.3K entries to find a match against hostname for every single network request. Even without state of the art optimization, using a Set() to lookup matches would be far better as this would require only to loop at most as many times as there are labels in the hostname to match, i.e. single low digit number of iterations versus over 55.3K iterations.


It looks like Firefox's DNR implementation is a "minimal viable product" state, and no work has been done on it since April 2023.

@gorhill gorhill changed the title Performance regression Lite and Origin vs no extension Performance regression Lite vs no extension Sep 17, 2023
@gorhill
Copy link
Member

gorhill commented Sep 17, 2023

I am not seeing issues with uBO itself, so changing title. If you think there are performance issues with uBO, please provide supporting profiling data.

@gorhill gorhill added the Firefox Specific to Firefox label Nov 28, 2023
@gorhill
Copy link
Member

gorhill commented Mar 21, 2024

Follow progress at https://bugzilla.mozilla.org/show_bug.cgi?id=1853569.

@gorhill gorhill closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Firefox Specific to Firefox
Projects
None yet
Development

No branches or pull requests

3 participants