Skip to content

support $to= option#673

Draft
boocmp wants to merge 29 commits into
masterfrom
to_option
Draft

support $to= option#673
boocmp wants to merge 29 commits into
masterfrom
to_option

Conversation

@boocmp

@boocmp boocmp commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

atuchin-m and others added 28 commits June 2, 2026 00:10
The PR:
* removes IS_BADFILTER from NetworkFilterMask
* adds NetworkFilterFeatureMask to store parse-only features
* rids off get_id_without_badfilter in favor of get_id()
* removes impl NetworkFilterMaskHelper for CheckedResult
The PR refactors `NetworkFilterMask` by moving some parse-only bits to `NetworkFilterFeaturesMask`.
* Refactor IS_REMOVEPARAM
* Refactor IS_GENERIC_HIDE
* Refactor IS_CSP
* Refactor IS_REDIRECT + ALSO_BLOCK_REDIRECT
* Fix compilation and tests
* remove unused import
* Add feature_mask to get_id()
The PR adjusts mask default value to consume less memory.
Flatbuffer builder doesn't serialize the mask if it's equal to the default.
The current default covers about 50% of the network rules and saves 200KB+ of memory.
…3.x) (#643)

The PR optimizes memory usage and building time by adding a simplified pattern storage.

Most filters (95%+) have patterns.len() <= 1. Despite that fact we always store patterns as a vector.
This implies storing an extra pointer (to the vector itself) + the vector length.

The PR adds an optional ability to store pattern as a single string eliminating the overhead above.
The PR introduces a new API to move from Vec<SomeFilter> in FilterSet.
This is a necessary step to make streaming parsing work.
The PR refactor the filter parsing code to allow processing filters one-by-one.
* new_with_filter_set parses filter one by one and immediately drops them after processing.
* The filters, matched to bad filters, are always serialized. The offsets are dropped from the hash table on the last stage. The negative impact is minimal, because $badfilter is rare thing.
* get_tokens uses an extra output param tokens_buffer to avoid unwanted allocations.

The PR dramatically reduces allocation count (-25%) and peak memory usage (about -50%).
The PR makes NetworkFilter::parse reuse the original string via &str or Cow<>
* removes an extra String alloc in get_id();
* uses rustc-hash as the impl which is more reliable and a little bit faster;
Support of $method option in filter rules.
… opt_not_to_domains, opt_to_entities, and opt_not_to_entities.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Rust Benchmark

Details
Benchmark suite Current: b2ccbfb Previous: d789160 Ratio
rule-match-browserlike/brave-list 3519848855 ns/iter (± 19792112) 2294657228 ns/iter (± 16160555) 1.53
rule-match-first-request/brave-list 2566961 ns/iter (± 30469) 1251222 ns/iter (± 4974) 2.05
blocker_new/brave-list 127629424 ns/iter (± 562945) 138752639 ns/iter (± 1395429) 0.92
blocker_new/brave-list-deserialize 32393053 ns/iter (± 436941) 32916216 ns/iter (± 223578) 0.98
memory-usage-final/brave-list-initial 10858740 B/iter (± 0) 11354668 B/iter (± 0) 0.96
memory-usage-final/brave-list-1000-requests 3926712 B/iter (± 0) 2612449 B/iter (± 0) 1.50
memory-usage-max/brave-list-initial/max 29635337 B/iter (± 0) 63576547 B/iter (± 0) 0.47
memory-usage-alloc-count/brave-list-initial/alloc-count 328700 allocs/iter (± 0) 859915 allocs/iter (± 0) 0.38
memory-usage-alloc-count/brave-list-1000-requests/alloc-count 106878 allocs/iter (± 0) 74018 allocs/iter (± 0) 1.44
url_cosmetic_resources/brave-list 187424 ns/iter (± 3562) 201452 ns/iter (± 708) 0.93
cosmetic-class-id-match/brave-list 3359931 ns/iter (± 915382) 3345009 ns/iter (± 905142) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: b2ccbfb Previous: d789160 Ratio
rule-match-browserlike/brave-list 3519848855 ns/iter (± 19792112) 2294657228 ns/iter (± 16160555) 1.53
rule-match-first-request/brave-list 2566961 ns/iter (± 30469) 1251222 ns/iter (± 4974) 2.05
memory-usage-final/brave-list-1000-requests 3926712 B/iter (± 0) 2612449 B/iter (± 0) 1.50
memory-usage-alloc-count/brave-list-1000-requests/alloc-count 106878 allocs/iter (± 0) 74018 allocs/iter (± 0) 1.44

This comment was automatically generated by workflow using github-action-benchmark.

@antonok-edm antonok-edm changed the title 1 support $to= option Jun 26, 2026
@antonok-edm
antonok-edm force-pushed the 0.13.x branch 6 times, most recently from 5dbc2d0 to 0b38737 Compare June 30, 2026 18:26
@antonok-edm
antonok-edm force-pushed the 0.13.x branch 5 times, most recently from 68a9766 to a71b805 Compare July 9, 2026 18:27
Base automatically changed from 0.13.x to master July 9, 2026 18:53
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

Successfully merging this pull request may close these issues.

3 participants