Closed Bug 1746080 Opened 3 years ago Closed 3 years ago

Improve performance of common url name lookups

Categories

(Firefox :: Bookmarks & History, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: bdahl, Assigned: bdahl)

Details

Attachments

(1 file)

Currently, we iterate over all possible matches and run a regex. This can be slow when run on many URLs.

Instead of matching URL hostnames with a regex in a loop, work backwards
from the end of the hostname and build a substring at each "."
separator in the hostname. Using the substring, lookup to see if there's a
common name match.

In the common case of <x>.<tld> this will complete in one map lookup.
For two part TLDs (e.g. "example.co.uk"), it will take two lookups.

Running the current tests in a loop 24k times:

Current New
3.7437879999998813 3.4763289999999643
2633.073231 60.42609900000002
1.7031870000000708 1.6397720000001073
2821.003696 177.723479
2876.997405 63.73837200000003
2821.1009919999997 60.183937000000014

The numbers where performance didn't change are where we have metadata and we don't look up the custom name.

For potential future work:
As far as I can tell, creating the JS URL is now the expensive part. There's also still a slow path for getting the domain name part. The TLD stripping part is expensive according to comments in the method.

Pushed by bdahl@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1be05a8289d8 Improve performance of common url name lookups. r=mossop
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: