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.
There was a problem hiding this comment.
Rust Benchmark
Details
| Benchmark suite | Current: f466e19 | Previous: 5d182e5 | Ratio |
|---|---|---|---|
rule-match-browserlike/brave-list |
2377131164 ns/iter (± 12597630) |
2241363322 ns/iter (± 47317273) |
1.06 |
rule-match-first-request/brave-list |
980119 ns/iter (± 4019) |
1216052 ns/iter (± 6861) |
0.81 |
blocker_new/brave-list |
105874415 ns/iter (± 958314) |
138839767 ns/iter (± 844690) |
0.76 |
blocker_new/brave-list-deserialize |
31383767 ns/iter (± 157085) |
31752836 ns/iter (± 821884) |
0.99 |
memory-usage-final/brave-list-initial |
10881484 B/iter (± 0) |
11355668 B/iter (± 0) |
0.96 |
memory-usage-final/brave-list-1000-requests |
2818515 B/iter (± 0) |
2612449 B/iter (± 0) |
1.08 |
memory-usage-max/brave-list-initial/max |
27809166 B/iter (± 0) |
63576475 B/iter (± 0) |
0.44 |
memory-usage-alloc-count/brave-list-initial/alloc-count |
281692 allocs/iter (± 0) |
859963 allocs/iter (± 0) |
0.33 |
memory-usage-alloc-count/brave-list-1000-requests/alloc-count |
81523 allocs/iter (± 0) |
74018 allocs/iter (± 0) |
1.10 |
url_cosmetic_resources/brave-list |
156738 ns/iter (± 2936) |
191870 ns/iter (± 955) |
0.82 |
cosmetic-class-id-match/brave-list |
2630633 ns/iter (± 682053) |
3552152 ns/iter (± 986336) |
0.74 |
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: f466e19 | Previous: 5d182e5 | Ratio |
|---|---|---|---|
memory-usage-alloc-count/brave-list-1000-requests/alloc-count |
81523 allocs/iter (± 0) |
74018 allocs/iter (± 0) |
1.10 |
This comment was automatically generated by workflow using github-action-benchmark.
boocmp
force-pushed
the
to_op
branch
4 times, most recently
from
July 1, 2026 11:23
fa735eb to
e742aca
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.