Skip to content
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

Merged
merged 4 commits into from
Dec 22, 2023

Conversation

AshwinSekar
Copy link
Contributor

@AshwinSekar AshwinSekar commented Nov 29, 2023

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

@AshwinSekar AshwinSekar force-pushed the erasure-meta-dirty branch 2 times, most recently from e149f88 to 4f95a50 Compare November 29, 2023 17:32
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (368852d) 81.8% compared to head (bf107c9) 81.8%.

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     

@@ -731,7 +731,7 @@ impl Blockstore {

fn try_shred_recovery(
&self,
erasure_metas: &HashMap<ErasureSetId, ErasureMeta>,
erasure_metas: &HashMap<ErasureSetId, (ErasureMeta, bool)>,
Copy link
Contributor

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),
}

Comment on lines 160 to 161
Dirty(T),
Clean(T),
Copy link
Contributor

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?!

Comment on lines 165 to 176
fn unwrap(&self) -> &T {
match self {
Self::Dirty(value) => value,
Self::Clean(value) => value,
}
}
Copy link
Contributor

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 { ...

Copy link
Contributor Author

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.

behzadnouri
behzadnouri previously approved these changes Dec 22, 2023
Comment on lines 165 to 176
/// Returns a reference to the underlying value
fn value(&self) -> &T {
match self {
Self::Dirty(value) => value,
Self::Clean(value) => value,
}
}
Copy link
Contributor

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

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(),
Copy link
Contributor

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().

Copy link
Contributor Author

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>

@AshwinSekar AshwinSekar merged commit cc584a0 into solana-labs:master Dec 22, 2023
35 checks passed
@AshwinSekar AshwinSekar deleted the erasure-meta-dirty branch December 22, 2023 22:06
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.

2 participants