-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flat buffers #416
Open
boocmp
wants to merge
45
commits into
master
Choose a base branch
from
flat_buffers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Flat buffers #416
Conversation
This file contains 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
e515e7b
to
2dca480
Compare
…ource_assembler.rs
…oved direct deps on NetworkFilter from RegexManager and matchers.
…k.rs to network_matchers.rs
Removed AnyOr trait.
…chers for flat filters.
There was a problem hiding this 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: a2a8f5a | Previous: 7919bdd | Ratio |
---|---|---|---|
rule-match-browserlike/brave-list |
1917794686 ns/iter (± 20902834 ) |
1745226241 ns/iter (± 10688991 ) |
1.10 |
rule-match-first-request/brave-list |
1052414 ns/iter (± 13996 ) |
1003256 ns/iter (± 7610 ) |
1.05 |
blocker_new/brave-list |
159015429 ns/iter (± 3655404 ) |
210108247 ns/iter (± 7007989 ) |
0.76 |
memory-usage/brave-list-initial |
21457739 ns/iter (± 3 ) |
41409969 ns/iter (± 3 ) |
0.52 |
memory-usage/brave-list-after-1000-requests |
24064706 ns/iter (± 3 ) |
44005995 ns/iter (± 3 ) |
0.55 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
This pull request marks the first stage of optimizing the ad blocker’s memory usage. It introduces the ability to store network request blocking rules in
FlatBuffers
. At this stage, memory consumption is reduced by half (a 2x improvement) with the same lookup performance. Future enhancements will focus on optimizations like eliminatingHashMap
s, aiming to achieve a 3x overall improvement in memory efficiency.abstract_network.rs
. This reduces the amount of code in thenetwork.rs
file.RegexManager
. This is preparation for breaking the direct dependency ofRegexManager
onNetworkFilter
.network_matchers.rs
. Also in this commit, loops in the macthing functions have also been replaced with any and all. Additionally, a traitAnyOrExt
was introduced, adding anany_or
method to iterators. However, this turned out to be an good solution, and in subsequent commits, it was removed in favor of using early returns.url_lower_cased
field has been added to thestruct Request
. This reduces the number of memory allocations during filter lookup and speeds up the matching. Astruct Tokens
has been introduced, and tokens are now calculated once and stored as a field in thestruct Request
. This simplifies and speeds up the code. A methodcheckable_tokens_iter
has been added toRequest
that returns the sequence of tokens that need to be checked. Theobject-pooling
feature has been removed.struct NetworkFilterList
has been moved fromblocker.rs
to a separate file,network_filter_list.rs
. Corresponding tests have been relocated totests/unit/network_filter_list.rs
include
andexclude
domains now stored asu16
indices instead ofu64
hashes in a separate sorted arrayunique_domains_hashes
FlatNetworkFilter
intoBlocker
. Added aNetworkFilterMaskHelper trait
, into which the boolean getters have been moved.check
,check_all
, andfilter_exists
. Now, there is a single loop iterates over sequence fromRequest::checkable_tokens_iter()
.Blocker
has been renamed toGenericBlocker<NetworkFilterListType>
, which may depends on the type of list:NetworkFilterList
orFlatNetworkFilterList
. Added an implementation forFlatNetworkFilterList
.FlatNetworkFilterList
to ensure that the results match in terms of speed and filter lookups with the implementation based onNetworkFilterList
.FlatNetworkFilterList
. Rules are optimized during creation. NowFlatNetworkFilterList
doesn't depend onNetworkFilterList
.