Conversation
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;
…nflicts in NetworkFilter.
Support of $method option in filter rules.
… opt_not_to_domains, opt_to_entities, and opt_not_to_entities.
…entities, and opt_not_to_entities.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
⚠️ 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
force-pushed
the
0.13.x
branch
6 times, most recently
from
June 30, 2026 18:26
5dbc2d0 to
0b38737
Compare
antonok-edm
force-pushed
the
0.13.x
branch
5 times, most recently
from
July 9, 2026 18:27
68a9766 to
a71b805
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.