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

[Feature] Unordered parallel graph walk V3 #3474

Merged
merged 27 commits into from
Sep 13, 2023
Merged

[Feature] Unordered parallel graph walk V3 #3474

merged 27 commits into from
Sep 13, 2023

Conversation

ruseinov
Copy link
Contributor

@ruseinov ruseinov commented Sep 8, 2023

Summary of changes

Changes introduced in this pull request:

  • Introduced unordered parallel graph traversal to speed up operations that don't care about the block order.

Reference issue to close (if applicable)

Work on #3314

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@ruseinov ruseinov marked this pull request as ready for review September 11, 2023 16:30
@ruseinov ruseinov requested a review from a team as a code owner September 11, 2023 16:30
@ruseinov ruseinov requested review from jdjaustin and elmattic and removed request for a team September 11, 2023 16:30
@ruseinov
Copy link
Contributor Author

unordered without "has"            traversed 87.43 GiB at 368.23 MiB/s in 00:04:03
unordered with "has"               traversed 87.43 GiB at 387.18 MiB/s in 00:03:51
unordered without parallel part    traversed 13.70 GiB at 252.89 MiB/s in 00:00:55
ordered                            traversed 87.43 GiB at 214.33 MiB/s in 00:06:57
ordered only sequential part       traversed 13.70 GiB at 257.50 MiB/s in 00:00:54

src/ipld/util.rs Outdated Show resolved Hide resolved
src/ipld/util.rs Outdated Show resolved Hide resolved
src/ipld/util.rs Outdated
@@ -437,3 +438,259 @@ impl<DB: Blockstore, T: Iterator<Item = Tipset> + Unpin> Stream for ChainStream<
}
}
}

enum UnorderedTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use an enum here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a leftover, will remove it for good. Thanks for spotting this.

src/ipld/util.rs Outdated
tipset_iter: T,
stateroot_limit: ChainEpoch,
) -> UnorderedChainStream<DB, T> {
let (sender, receiver) = kanal::bounded(2048);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering how did you pick this 2048 value? Does the value has any impact on performances or memory usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's somewhat arbitrary, 2048 worked well on my machine and memory usage for 2048 items is negligible. I'll introduce a constant to be more transparent.

task::spawn(async move {
let mut handles = JoinSet::new();

for _ in 0..num_cpus::get() {
Copy link
Contributor

@elmattic elmattic Sep 13, 2023

Choose a reason for hiding this comment

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

Should I observe some speedup/slowdown if I increase/decrease the number of cores here? For example testing on a calibnet snapshot, I don't see a big difference in performances. Or should I run the benchmark command on a mainnet snapshot maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calibnet is too small of a snapshot, yeah. I have tested this and this setup worked better than others.

src/ipld/util.rs Outdated
}
}

// // Process block messages.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can remove comment here.

@ruseinov ruseinov enabled auto-merge September 13, 2023 11:49
@ruseinov ruseinov disabled auto-merge September 13, 2023 11:49
@ruseinov ruseinov enabled auto-merge September 13, 2023 12:04
@ruseinov ruseinov added this pull request to the merge queue Sep 13, 2023
Merged via the queue into main with commit f92b14e Sep 13, 2023
@ruseinov ruseinov deleted the ru/feature/u-g-t-v3 branch September 13, 2023 12:47
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.

3 participants