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

feat: adds parallelization to SenderRecovery and TxLookup using SnapshotProvider #6654

Merged
merged 24 commits into from
Feb 20, 2024

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented Feb 18, 2024

Changes

  • closes SnapshotProvider should be Arc<SnapshotProviderInner> #6249
  • make transaction_hashes_by_range on static files parallel: each rayon worker reads the file(and deserializes) on their own vs mdbx where reading and deserialization is done on the main thread before sending it to rayon workers for hashing.
  • SenderRecovery reads from snapshot provider in parallel as well.
  • chunk_size on parallelization is set to 100: Kinda arbitrary. The way it was before it was too high and there were a bunch of rayon threads waiting for work. (image comparison incoming)

Benches

holesky maxperf @ block 925555

TransactionLookup went from [57s-59s] to [47s-50s].
SenderRecovery didn't benefit from static files (heavily cpu bound), but the chunk_size reduction helped it go from 49s to 44s.

@joshieDo joshieDo added A-staged-sync Related to staged sync (pipelines and stages) A-static-files Related to static files labels Feb 18, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, nits

pending @shekhirin

bin/reth/src/commands/stage/run.rs Outdated Show resolved Hide resolved
bin/reth/src/commands/stage/run.rs Outdated Show resolved Hide resolved
Comment on lines +43 to +44
#[derive(Debug, Default, Clone)]
pub struct SnapshotProvider(Arc<SnapshotProviderInner>);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, this now closes the other pr that adds this main

Comment on lines +99 to +101
pub fn with_filters(self) -> Self {
let mut provider =
Arc::try_unwrap(self.0).expect("should be called when initializing only.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for followup, this should be called during SnapshotProvider::new

joshieDo and others added 2 commits February 18, 2024 15:34
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
@shekhirin shekhirin force-pushed the feat/static-files branch 6 times, most recently from d75d4e3 to 043f07d Compare February 19, 2024 21:44
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only nits

bin/reth/src/commands/stage/run.rs Outdated Show resolved Hide resolved
bin/reth/src/commands/stage/run.rs Outdated Show resolved Hide resolved
crates/stages/src/stages/sender_recovery.rs Show resolved Hide resolved
crates/stages/src/stages/sender_recovery.rs Outdated Show resolved Hide resolved
@@ -194,18 +194,26 @@ impl TestStageDB {
/// Insert ordered collection of [SealedBlock] into corresponding tables.
/// Superset functionality of [TestStageDB::insert_headers].
///
/// If tx_offset is set to `None`, then transactions will be stored on static files, otherwise
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof imo it's easy to misuse. Maybe an explicit enum?

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
@joshieDo joshieDo merged commit acecfd3 into feat/static-files Feb 20, 2024
21 of 25 checks passed
@joshieDo joshieDo deleted the joshie/concurrent-range-fetch branch February 20, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-staged-sync Related to staged sync (pipelines and stages) A-static-files Related to static files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants