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 issue when looking up a cosmetic filter's origin in the logger #3101

Closed
gorhill opened this issue Oct 6, 2017 · 3 comments
Closed

Comments

@gorhill
Copy link
Owner

gorhill commented Oct 6, 2017

Issue first raised in #2664 (comment):

2c9c98e introduced regression in logger.
On my system (Firefox ~85k cosmetic filters) up to 7 seconds is needed for cosmetic filter details layer/dialog to appear after I click on it.

In Chromium, this is about 2s.

@gorhill gorhill changed the title Investigate performance issue of looking up a cosmetic filter origin in logger Investigate performance issue when looking up a cosmetic filter's origin in the logger Oct 6, 2017
@gorhill
Copy link
Owner Author

gorhill commented Oct 6, 2017

@gwarser,

I transcribed what I see in your screenshot at #2664 (comment):

Regex of filter to lookup: /[^\n]*\\*"\.googad\\*"[^\n]*/.

Content of compiled EasyList which is scanned with above regex:

compiled-easylist-cosmetic-filters.txt

When I paste/try the regex and content at https://regex101.com/, after selecting "javascript" in the left hand sidebar, I get a timing of 30-40 ms without the g flag, and 250-300 ms with the g flag (your screenshot shows over 500 ms -- edit: ok, it's 500+ ms for all filter lists, here I am testing only with EasyList). The (only) matching line is about 1/3 down from the beginning of the scanned content.

The result with the g flag is curious, given that there is only one match for that regex. Can you tell me what kind of timing you get on your side with this test?

@gorhill
Copy link
Owner Author

gorhill commented Oct 6, 2017

Interesting... If I add ^ and $ at the start and beginning of the regex and use the m flag, the timing decreases dramatically when using the g flag, 15-30 ms:

/^[^\n]*\\*"\.googad\\*"[^\n]*$/gm

@gwarser
Copy link
Contributor

gwarser commented Oct 6, 2017

64ms without global /[^\n]*\\*"\.googad\\*"[^\n]*/
517ms with global /[^\n]*\\*"\.googad\\*"[^\n]*/g

36ms with ^...$ and mg /^[^\n]*\\*"\.googad\\*"[^\n]*$/gm

@gorhill gorhill closed this as completed in 4639d75 Oct 6, 2017
@gorhill gorhill changed the title Investigate performance issue when looking up a cosmetic filter's origin in the logger Performance issue when looking up a cosmetic filter's origin in the logger Oct 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants