-
Notifications
You must be signed in to change notification settings - Fork 236
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
improve sync header map #3391
improve sync header map #3391
Conversation
36fe267
to
c899c52
Compare
c899c52
to
94a1915
Compare
e6b4ef7
to
783f58c
Compare
86f05f1
to
035f625
Compare
035f625
to
76be468
Compare
76be468
to
d5ada78
Compare
use tempfile::TempDir; | ||
|
||
pub(crate) struct SledBackend { | ||
count: AtomicUsize, |
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.
Can we remove len
and is_empty
from KeyValueBackend
?
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.
No, this is used for short-circuiting, when the count is 0 we can skip the db operation, this will be reflected in the profiling.
If you mean can we use sled::len
or sled::is_empty
, although I haven't actually tried it, but it shouldn't work either, performs a full O(n) scan under the hood from docs
pub fn len(&self) -> usize {
self.iter().count()
}
/// Returns `true` if the `Tree` contains no elements.
pub fn is_empty(&self) -> bool {
self.iter().next().is_none()
}
pub(crate) fn next_inner(&mut self) -> Option<<Self as Iterator>::Item> {
let guard = pin();
let (mut pid, mut node) = if let (true, Some((pid, node))) =
(self.going_forward, self.cached_node.take())
{
(pid, node)
} else {
let view =
iter_try!(self.tree.view_for_key(self.low_key(), &guard));
(view.pid, view.deref().clone())
};
for _ in 0..MAX_LOOPS {
if self.bounds_collapsed() {
return None;
}
if !node.contains_upper_bound(&self.lo) {
...........
} else if !node.contains_lower_bound(&self.lo, true) {
........
} else {
........
}
}
}
let mut count = 0; | ||
for value in values { | ||
let key = value.hash(); | ||
let last_value = self |
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.
Have you compared the performance difference between consecutive insertions with apply_batch
?
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.
apply_batch has the same problem, it can't give feedback whether a key was overwritten or written directly,Here also tried to compare with transaction,transaction performs worse because of the extra overhead required to guarantee ACID.
Sled has the same memory usage after exiting sync, but has higher peak memory usage during sync. CC @quake |
bors r+ |
3470: fix(tests): get_ancestor_use_skip_list r=zhangsoledad a=zhangsoledad <!-- Thank you for contributing to nervosnetwork/ckb! If you haven't already, please read [CONTRIBUTING](https://github.com/nervosnetwork/ckb/blob/develop/CONTRIBUTING.md) document. If you're unsure about anything, just ask; somebody should be along to answer within a day or two. PR Title Format: 1. module [, module2, module3]: what's changed 2. *: what's changed --> ### What problem does this PR solve? test `get_ancestor_use_skip_list` was broken since #3391 ### What is changed and how it works? Make sure genesis skip_hash is none. ### Check List <!--REMOVE the items that are not applicable--> Tests <!-- At least one of them must be included. --> - Unit test - Integration test - Manual test (add detailed scripts or steps below) - No code ci-runs-only: [ quick_checks,linters ] ### Release note <!-- Choose from None, Title Only and Note. Bugfixes or new features need a release note. --> ```release-note None: Exclude this PR from the release note. ``` Co-authored-by: zhangsoledad <[email protected]>
What problem does this PR solve?
What is changed and how it works?
Check List
Tests
Release note