-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
blockstore: write only dirty erasure meta and merkle root metas #34269
blockstore: write only dirty erasure meta and merkle root metas #34269
Conversation
e149f88
to
4f95a50
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34269 +/- ##
=======================================
Coverage 81.8% 81.8%
=======================================
Files 824 824
Lines 222128 222151 +23
=======================================
+ Hits 181742 181789 +47
+ Misses 40386 40362 -24 |
ledger/src/blockstore.rs
Outdated
@@ -731,7 +731,7 @@ impl Blockstore { | |||
|
|||
fn try_shred_recovery( | |||
&self, | |||
erasure_metas: &HashMap<ErasureSetId, ErasureMeta>, | |||
erasure_metas: &HashMap<ErasureSetId, (ErasureMeta, bool)>, |
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 use an enum
instead of bool
? something like
enum Wrapper<T> {
New(T),
Old(T),
}
4f95a50
to
a9701c4
Compare
ledger/src/blockstore.rs
Outdated
Dirty(T), | ||
Clean(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.
Can you please add a comment here what each represents?
Clean
means we read from blockstore, right?
Dirty
means it should be stored to blockstore?!
ledger/src/blockstore.rs
Outdated
fn unwrap(&self) -> &T { | ||
match self { | ||
Self::Dirty(value) => value, | ||
Self::Clean(value) => value, | ||
} | ||
} |
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.
This seems a confusing overload of unwrap
.
Can we instead implement From
?
https://doc.rust-lang.org/std/convert/trait.From.html
something like:
impl<T> From<WorkingStatus<T>> for 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.
I can't implement From
as it violates the orphan rule. I've changed the names a bit to WorkingEntry
and fn value
hopefully that's less confusing.
a9701c4
to
28d7a20
Compare
ledger/src/blockstore.rs
Outdated
/// Returns a reference to the underlying value | ||
fn value(&self) -> &T { | ||
match self { | ||
Self::Dirty(value) => value, | ||
Self::Clean(value) => value, | ||
} | ||
} |
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.
This could implement AsRef
instead:
https://doc.rust-lang.org/std/convert/trait.AsRef.html
28d7a20
to
bf107c9
Compare
write_batch.put::<cf::ErasureMeta>((slot, u64::from(fec_set_index)), &erasure_meta)?; | ||
write_batch.put::<cf::ErasureMeta>( | ||
(slot, u64::from(fec_set_index)), | ||
working_erasure_meta.as_ref(), |
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.
I think you can just write & working_erasure_meta
.
&
will do the .as_ref()
.
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.
hmm it doesn't seem to work it only recognizes it as a &WorkingEntry<ErasureMeta>
Problem
We commit the in memory maps to blockstore every iteration which results in a lot of rewrites.
Summary of Changes
Explicitly track which entries are dirty and only commit those.
Contributes to #33644