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

Increase performance of repeat proving. #168

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

mcdee
Copy link
Contributor

@mcdee mcdee commented Jun 29, 2024

Repeatedly running Prove() against the same node can take a long time, as hashes are unconditionally recomputed. This simple change checks for the presence of a value in an intermediate node before rehashing.

Performance difference as follows:

goos: linux
goarch: amd64
pkg: github.com/ferranbt/fastssz
cpu: 12th Gen Intel(R) Core(TM) i7-1265U
         │    before.txt    │              after.txt               │
         │      sec/op      │    sec/op     vs base                │
Prove-12   247529.077µ ± 5%   4.283µ ± 34%  -100.00% (p=0.002 n=6)

This also returns the value being proved even if it is an intermediate node.

Test for repeated proving and a benchmark for repeated proving included.

@ferranbt ferranbt self-requested a review June 29, 2024 09:40
@ferranbt ferranbt merged commit eac385e into ferranbt:main Jun 29, 2024
1 check passed
olegrok pushed a commit to NilFoundation/fastssz that referenced this pull request Jul 4, 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