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

Merkle multiproofs optimization #1

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

Cesar199999
Copy link

Hi @intx4!

I'd like to propose the following changes to your Arkworks PR. The first one concerns the sample size in the benches. I've noticed that it's set to 10 by default. I assume you chose this value due to how slow verification is. However, the sample size for tree creation and (multi-)path proving can be increased by an order of magnitude, and every bench will take roughly the same time to execute.

The second change is refactoring the function prefix_encode_path using chained iterators. This approach is a bit more readable and even slightly more efficient. For reference, I get the following benches for the original implementation on my ThinkPad 14s machine:

Merkle Tree Generate Multi Proof (Leaves as [u8])
                        time:   [470.45 ms 471.29 ms 472.20 ms]

When using iterators, the performance seems to improve slightly:

Merkle Tree Generate Multi Proof (Leaves as [u8])
                        time:   [462.76 ms 463.66 ms 464.64 ms]
                        change: [-1.8909% -1.6180% -1.3512%] (p = 0.00 < 0.05)
                        Performance has improved.

@intx4
Copy link
Owner

intx4 commented Mar 25, 2024

hi @Cesar199999, thank you very much for your additions, it was indeed a good catch to use iterators :)

@intx4 intx4 merged commit 2d28bcf into intx4:main Mar 25, 2024
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