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: 82d4cce Previous: 1e93800 Ratio
rule-match-browserlike/brave-list 1919195927 ns/iter (± 5761544) 2051836000 ns/iter (± 9414636) 0.94
rule-match-first-request/brave-list 1155935 ns/iter (± 9498) 1112038 ns/iter (± 6293) 1.04
blocker_new/brave-list 163477165 ns/iter (± 777263) 143433250 ns/iter (± 539931) 1.14
blocker_new/brave-list-deserialize 24306380 ns/iter (± 466997) 23670075 ns/iter (± 229117) 1.03
memory-usage/brave-list-initial 10213328 ns/iter (± 3) 10213344 ns/iter (± 3) 1.00
memory-usage/brave-list-initial/max 60612203 ns/iter (± 3) 60612235 ns/iter (± 3) 1.00
memory-usage/brave-list-initial/alloc-count 1231663 ns/iter (± 3) 1231711 ns/iter (± 3) 1.00
memory-usage/brave-list-1000-requests 2692648 ns/iter (± 3) 2692712 ns/iter (± 3) 1.00
memory-usage/brave-list-1000-requests/alloc-count 71527 ns/iter (± 3) 71607 ns/iter (± 3) 1.00
url_cosmetic_resources/brave-list 195617 ns/iter (± 1933) 191829 ns/iter (± 505) 1.02
cosmetic-class-id-match/brave-list 3636081 ns/iter (± 981615) 3415862 ns/iter (± 942750) 1.06

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
}

#[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)]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

matches_test was used tests/matching.rs for exception checking.
I've adjusted the tests to use directly engine.check_network_request and added #[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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, we don't need this with thread-local mock time. Removed.

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just a test wrapper for blocker.borrow_regex_manager, so I added a doc comment to borrow_regex_manager() there.

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

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.

⚠️ 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: 82d4cce Previous: 1e93800 Ratio
blocker_new/brave-list 163477165 ns/iter (± 777263) 143433250 ns/iter (± 539931) 1.14

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

@atuchin-m
Copy link
Collaborator Author

merged to pre-0.12.x instead: #572

@atuchin-m atuchin-m closed this Nov 20, 2025
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