dhowe / AdNauseam

AdNauseam: Fight back against advertising surveillance
GNU General Public License v3.0
4.58k stars 191 forks source link

Possible performance optimization #763

Open dhowe opened 7 years ago

dhowe commented 7 years ago

We often look process the same DOM element multiple times (in parser.js) when it is hit by multiple cosmetic filters. A simple example is this page: http://lab-lamp.scm.cityu.edu.hk/adntest/redirect-notice.html, where a single Ad is discovered 3 times (the last two are marked correctly as duplicates and ignored). But we may get some page-load speed gains (at the possible expense of memory) by keeping track of nodes we have looked at and not re-parsing them...

Testing this will requires profiling with and without

see #551

cqx931 commented 7 years ago

Can you explain more about what you mean by "a single Ad is discovered 3 times" ?

When I check the example page with debugging mode. This is what I see from the console: image

In this case, two nodes have been processed, the tag and the tag. Though it is the same ad, but different nodes...

dhowe commented 7 years ago

Looks like you are finding two (of the same) ads, when I tested before I was finding three (two duplicates), now I also see two ...

But the point is that once we examine a node, there is never a point in examining again, unless the DOM has changed, so we might, in the future, want to mark nodes as 'checked', so as not to revisit...

On hold for now