DescriptionOn most domains like example.com, manishjethani.com, and so on (domains that don't have any filters or exceptions associated with them), we inject the exact same style sheet. But we generate the last part of this style sheet each time in the generateStyleSheetForDomain function.
This patch keeps a cache of known domains. If the given domain is not known (technically does not have any suffix that's known), it returns a complete cached "common" style sheet.
For example, with the following filters:
##.foo
~bar.example.com##.not-bar
bar.example.com##.bar
On foo.example.com, we don't have a known suffix. In that case, we can just return the common style sheet (which includes two selectors, .foo and .not-bar). On bar.example.com, on the other hand, we must compute the selectors to include; here we use the existing code path, which concatenates the default style sheet (containing only .foo) to the dynamically generated style sheet (containing .bar, but not .not-bar).
This adds ~320 KB to the memory footprint, but for a tremendous performance gain. It speeds up the generateStyleSheetForDomain function for unknown domains by ~50%.
The follow-up patch to this will speed up the function by another ~80%, thus making the net gain ~90%.
Patch Set 1 #Patch Set 2 : Minor improvements #Patch Set 3 : Maintain only known exception domains #Patch Set 4 : Slightly refactored #MessagesTotal messages: 6
|