gecko-dev/modules
dlee 8370cfe1bf Bug 1542744 - P2. Improve performance of MakePrefixSet by using different algorithm according to the number of prefixes. r=gcp
The goal of this patch is to reduce the number of memory reallocation during
|MakePrefixSet|[1].

Here is the number of nsTArray memory reallocation occur during |MakePrefixSet|
(test in my local platform):
googpub-phish-proto: 58k times
goog-malware-proto: 9k times
goog-unwanted-proto: 25k times
goog-badbinurl-proto: 6k times

This patch improves the performance by:
1. For tables whose prefixes are less than 128*1024(malware, unwanted,
badinurl).

Store prefixes directly without dividing allocation into smaller chunks.
Because the maximum size to store all the prefixes in a single array for
these tables will be less than 512k, we can avoid Bug 1046038.

This simplifies the internal prefixset data structure generation and total
memory usage is also saved:
goog-malware-proto  : 437K -> 163k
goog-unwanted-proto : 658k -> 446k
goog-badbinurl-proto: 320k -> 110k

The single largest allocated continuous memory size is:
goog-malware-proto  : 86k -> 163k
goog-unwanted-proto : 86k -> 446k
goog-badbinurl-proto: 77k -> 110k

A further improvement can be done for this part is for tables with fewer
prefixes, we can use an one-dimension delta array to reduce the size of a
single continuous memory allocation.

2. For tables with more prefixes:

According to experiment, when prefixes are more than 400k
the delta arrays have very high chance that are full, in the case of
phishing table, we can estimate the capacity accurately before
applying delta algorithm.

The shortcoming of this part is when prefixes are between 130k~400k,
the capacity estimation is not accurate.

[1] https://searchfox.org/mozilla-central/rev/b2015fdd464f598d645342614593d4ebda922d95/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp#99

Differential Revision: https://phabricator.services.mozilla.com/D30046

--HG--
extra : moz-landing-system : lando
2019-05-14 21:05:41 +00:00
..
brotli Bug 1512504 - Remove support for MSVC. r=froydnj 2019-02-14 21:45:27 +00:00
fdlibm Bug 1380031: Ensure Math.exp(1) returns Math.E. r=arai 2019-03-25 09:15:27 +00:00
freetype2
libjar Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan 2019-05-01 08:47:10 +00:00
libmar Bug 1539176 - modules/ manual ESLint no-throw-literal fixes. r=rstrong 2019-04-02 13:41:10 +00:00
libpref Bug 1542744 - P2. Improve performance of MakePrefixSet by using different algorithm according to the number of prefixes. r=gcp 2019-05-14 21:05:41 +00:00
woff2
xz-embedded
zlib No bug - add a comment explaining why zlib's sources can't be unified. DONTBUILD 2019-01-18 22:03:40 -05:00
moz.build