-
Notifications
You must be signed in to change notification settings - Fork 170
Allow custom resource storage backends, expose more debug info #526
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
base: 0.11.x
Are you sure you want to change the base?
Conversation
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: 20c30b1 | Previous: 1bfadd6 | Ratio |
---|---|---|---|
rule-match-browserlike/brave-list |
2224774239 ns/iter (± 8786760 ) |
2157327098 ns/iter (± 15833464 ) |
1.03 |
rule-match-first-request/brave-list |
1109097 ns/iter (± 8618 ) |
1067208 ns/iter (± 8765 ) |
1.04 |
blocker_new/brave-list |
151381104 ns/iter (± 1187448 ) |
175128732 ns/iter (± 2762769 ) |
0.86 |
blocker_new/brave-list-deserialize |
20834838 ns/iter (± 35702 ) |
73769476 ns/iter (± 854420 ) |
0.28 |
memory-usage/brave-list-initial |
10072539 ns/iter (± 3 ) |
18344503 ns/iter (± 3 ) |
0.55 |
memory-usage/brave-list-initial/max |
64817658 ns/iter (± 3 ) |
66961277 ns/iter (± 3 ) |
0.97 |
memory-usage/brave-list-initial/alloc-count |
1534723 ns/iter (± 3 ) |
1616082 ns/iter (± 3 ) |
0.95 |
memory-usage/brave-list-1000-requests |
2516487 ns/iter (± 3 ) |
2551890 ns/iter (± 3 ) |
0.99 |
memory-usage/brave-list-1000-requests/alloc-count |
66788 ns/iter (± 3 ) |
68816 ns/iter (± 3 ) |
0.97 |
url_cosmetic_resources/brave-list |
204827 ns/iter (± 789 ) |
189708 ns/iter (± 2713 ) |
1.08 |
cosmetic-class-id-match/brave-list |
15649919 ns/iter (± 4762393 ) |
5166097 ns/iter (± 1523809 ) |
3.03 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
⚠️ 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: 20c30b1 | Previous: 1bfadd6 | Ratio |
---|---|---|---|
cosmetic-class-id-match/brave-list |
15649919 ns/iter (± 4762393 ) |
5166097 ns/iter (± 1523809 ) |
3.03 |
This comment was automatically generated by workflow using github-action-benchmark.
4424d72
to
7a4eed6
Compare
unfortunately this requires duplicating some definitions to support additional `Send + Sync` trait bounds, since Rust does not natively support conditional supertraits.
7a4eed6
to
e454c54
Compare
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
# Can be removed once https://github.com/actions/runner-images/pull/13076 is released |
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.
Let's remove this to make the diff clear.
I've pushed the recent fixes from master
to 0.11.x
// Since the beginning of flatbuffer data is aligned to that size, | ||
// the alignment of the data must be a divisor of MIN_ALIGNMENT. | ||
assert!(MIN_ALIGNMENT % std::mem::size_of::<T>() == 0); | ||
assert!(MIN_ALIGNMENT.is_multiple_of(std::mem::size_of::<T>())); |
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.
the same, let's revert unrelated changes.
/// a custom [ResourceStorageBackend] if desired. | ||
pub struct ResourceStorage { | ||
#[cfg(not(feature = "single-thread"))] | ||
backend: Box<dyn ResourceStorageBackend + Sync + Send>, |
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.
hm, I'm not strongly again Box<dyn ..>
it makes the code less clear and may have some negative perf effect (if it's a hot path)
} | ||
} | ||
|
||
impl InMemoryResourceStorage { |
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.
That code have major conflicts with master
with #517.
/// Customizable backend for [Resource] storage. | ||
/// Custom implementations could be used to enable (for example) sharing of resources between | ||
/// multiple [crate::Engine]s, an on-disk backend, or special caching behavior. | ||
pub trait ResourceStorageBackend { |
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.
That trait looks internal to me. Can we don't make it public? I would say the best option is just to provide a few public methods to build ResourceStorage
without exposing the other struct/traits
Frankly, I can’t find the part that allow to shared the resources between multiple engines (the idea of my #519). |
supersedes #519
breaking API changes from this PR:
ResourceStorageBackend
. This trait can be implemented to use customized storage backend logic, including sharing between multiple engines, caching from disk, ability to dynamically add/remove resources at runtime, collecting metrics, etc.InMemoryResourceStorage
as a port of the originalResourceStorage
backend.Engine::add_resource
. If you still need the ability to add individual resources at runtime, use a customResourceStorageBackend
instead.regex-debug-info
feature has been named todebug-info
, as it now also enables a new API to get the size of theEngine
's internal flatbuffer at runtime.