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

Reduce filter list size by using domain popularity, updating encoding, and removing unapplicable rules #587

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dharb
Copy link
Collaborator

@dharb dharb commented Jan 9, 2025

This PR makes substantial changes to rebuild-filterlist.mjs and compile-filterlist.mjs in an effort to reduce the size of the filter list and ultimately the injected bundle with minimal impact to coverage.

Notable changes:

  • Use Tranco domain popularity data to filter long-tail domain-specific rules (rank 100k+) from relevant easylist cookie lists
  • Encode bundle using Uint16Array instead of Uint8Array

Through these change we're able to reduce the resulting filterlist-engine.ts by over 60% (4.2M -> 1.8M), which should help significantly with performance.

@dharb dharb requested review from muodov and sammacbeth January 9, 2025 22:39
@muodov muodov added minor Increment the minor version when merged performance Improve performance of an existing feature labels Jan 10, 2025
@@ -81,6 +81,7 @@
"dependencies": {
"@ghostery/adblocker": "^2.0.4",
"@ghostery/adblocker-content": "^2.0.4",
"csv-parse": "^5.6.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to devDependencies?

Comment on lines +37 to +42
!line.startsWith('!') &&
!line.startsWith('##') &&
!line.startsWith('||') &&
!line.includes(':remove') &&
!line.includes(':upward') &&
!line.includes('redirect-rule'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some comments on what each of these prefixes mean and why we're filtering them out?

*/
async function rebuildFilterList() {
await loadTrancoList();
await processFilterList('easylist_cookie_specific_uBO.txt');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call processFilterlist() on all input files, not just "specific" ones?

Comment on lines +45 to +46
for (const line in filteredLines) {
const rule = filteredLines[line];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const line in filteredLines) {
const rule = filteredLines[line];
for (const rule of filteredLines) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged performance Improve performance of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants