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

perf: make binary nodes compute their edges in parallel #24

Merged
merged 6 commits into from
Apr 12, 2024

Conversation

cchudant
Copy link
Member

@cchudant cchudant commented Apr 3, 2024

Hi 👋
I originally opened this PR here: massalabs#4 so that I could show it to @AurelienFT until multi trie is merged on this repo

During the commit of a MerkleTree, when we encounter a Binary node, we can compute the hash of both of the edges in parallel. It turns out, this speeds up the crate quite a lot

I also tried optimizing a little bit more: get a bit lower level with a rayon::join_context in a way that allows to reuse the destination array without having to make a new local one if the compute job for the right path did not get stolen
unfortunately it's unclear whether it has any impact on what the benches tell me so it's not included in the pr

it might because the machine I am currently using for benching has high variation in the results, i might reexplore this at some point

Copy link
Contributor

@tdelabro tdelabro left a comment

Choose a reason for hiding this comment

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

Love it

Cargo.toml Show resolved Hide resolved
src/trie/merkle_tree.rs Show resolved Hide resolved
@cchudant
Copy link
Member Author

@tdelabro I have applied your suggestions :)

@tdelabro tdelabro merged commit 2af0cb6 into madara-alliance:oss Apr 12, 2024
6 checks passed
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.

4 participants