Skip to content

Conversation

@atuchin-m
Copy link
Collaborator

@atuchin-m atuchin-m commented Nov 11, 2025

The PR removes impl NetworkMatchable for NetworkFilter and port the related tests to the flatbuffer impl (that we actually use in production)

@atuchin-m atuchin-m self-assigned this Nov 11, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Rust Benchmark

Benchmark suite Current: 9102886 Previous: e9299eb Ratio
rule-match-browserlike/brave-list 1778782824 ns/iter (± 2335270) 1972094868 ns/iter (± 5118480) 0.90
rule-match-first-request/brave-list 1125346 ns/iter (± 5335) 1114948 ns/iter (± 7936) 1.01
blocker_new/brave-list 152508811 ns/iter (± 1250572) 149920984 ns/iter (± 359157) 1.02
blocker_new/brave-list-deserialize 20873957 ns/iter (± 116935) 26447852 ns/iter (± 105485) 0.79
memory-usage/brave-list-initial 10212216 ns/iter (± 3) 10212216 ns/iter (± 3) 1
memory-usage/brave-list-initial/max 63149135 ns/iter (± 3) 63149135 ns/iter (± 3) 1
memory-usage/brave-list-initial/alloc-count 1231721 ns/iter (± 3) 1231721 ns/iter (± 3) 1
memory-usage/brave-list-1000-requests 2645922 ns/iter (± 3) 2645938 ns/iter (± 3) 1.00
memory-usage/brave-list-1000-requests/alloc-count 70984 ns/iter (± 3) 71016 ns/iter (± 3) 1.00
url_cosmetic_resources/brave-list 186713 ns/iter (± 553) 189954 ns/iter (± 1211) 0.98
cosmetic-class-id-match/brave-list 3502960 ns/iter (± 935804) 3389120 ns/iter (± 946890) 1.03

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

.compiled_regex_count,
0
);
// Regex can't be compiled, so no match.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the test case added here (already in the disabled state):
40b7815

regex crate can't parse such regex, so I changed the test to verify it doesn't match

@atuchin-m atuchin-m force-pushed the pr-dont-use-old-methods-in-tests branch 4 times, most recently from 1c5c5ec to fceebb0 Compare November 12, 2025 07:47
@atuchin-m atuchin-m force-pushed the pr-dont-use-old-methods-in-tests branch from fceebb0 to 9102886 Compare November 12, 2025 07:57
@atuchin-m atuchin-m marked this pull request as ready for review November 12, 2025 08:03
@atuchin-m atuchin-m requested a review from a team as a code owner November 12, 2025 08:03
Comment on lines +158 to +159
#[doc(hidden)]
pub(crate) fn check_exceptions(&self, request: &Request) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to include #[doc(hidden)] on pub(crate) items

}

#[doc(hidden)]
pub fn matches_test(&self, request: &request::Request) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

#[cfg(test)]?

let mut regex_manager = RegexManager::default();
regex_manager.update_time();
let engine = make_engine("||geo*.hltv.org^");
engine.borrow_regex_manager();
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment would also be useful here to explain why the extra borrows are necessary

Comment on lines +274 to +275
#[cfg(test)]
pub fn borrow_regex_manager(&self) -> crate::blocker::RegexManagerRef<'_> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment describing why this is necessary would be helpful

(I can tell from the diffs below, but later it won't be as obvious)

Comment on lines -996 to -997
impl NetworkMatchable for NetworkFilter {
fn matches(&self, request: &request::Request, regex_manager: &mut RegexManager) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

fwiw, this is a breaking API change and will require another bump up to 0.12.x

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