Closed Bug 1337782 Opened 7 years ago Closed 7 years ago

UA override web compat add-on caches all URIs ever

Categories

(Web Compatibility :: Interventions, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Gijs, Assigned: denschub)

References

Details

Attachments

(1 file)

This map:

https://dxr.mozilla.org/mozilla-central/source/browser/extensions/webcompat/content/lib/ua_overrider.jsm?q=path%3Aua_overrider&redirect_type=single#19

is process-global and never gets cleared. If you leave Firefox running a while, that map is going to have a lot of items.

We should probably FIFO limit it to something sane like 500 items.

Also, we're caching the entire URI. I think you just want the main domain, so probably just uri.prePath or something like that.
Also, that code is not private browsing aware and should either not cache private browsing URIs or store them separately or... something.
The main idea behind the cache was mainly to prevent having to look up items of the map for every request ever made and it totally made sense in the very first iteration we had. However, I now question the actual need for this cache.

The map is a map of base domains, and if we don't have an override for a given domain we exit pretty early (at [0] to be precise), which by no means is slower than the cache lookup. So we could, in theory, drop the cache at all.

The only possible downside is that if we have an override for a high-traffic domain like google.com or a subdomain in place, all requests would have to loop over the overrides for the given domain. In practice, the list of overrides probably will stay very small, and they won't stay in there for a long time.

Will do some performance measurements on how this would affect loading time in worse cases.

[0]: https://dxr.mozilla.org/mozilla-central/rev/f4f374622111022d41dd8d5eb9220624135c534a/browser/extensions/webcompat/content/lib/ua_overrider.jsm#110
Assignee: nobody → dschubert
Eric, I have removed the URI caching as mentioned above. I've done some local testing with 10.000 UA overrides and was not able to find any performance issues. When this gets a r+, I'll push the sources including the dummy overrides to try to double-check if we don't regress perf.
Attachment #8835038 - Flags: review?(etsai)
Blocks: 1337905
No longer blocks: 1308271
Comment on attachment 8835038 [details] [review]
Pull request, Version 1

Looks good for me now. Add real cache with :Gijs' comment if we need it in the future.
Attachment #8835038 - Flags: review?(etsai) → review+
Merged. Landing the new changes will be tracked in bug 1337905, closing this one.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: