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

avoid copies - 20% hash_tree_root speedup #53

Merged
merged 2 commits into from
Jul 20, 2023
Merged

avoid copies - 20% hash_tree_root speedup #53

merged 2 commits into from
Jul 20, 2023

Conversation

arnetheduck
Copy link
Member

  • use 64-byte buffer to pass a full sha256 block at a time to digest, thus avoiding internal buffer copies
  • avoid several unnecessary zeroMem calls via {.noinit.} / etc
  • process blobs 64 bytes at a time instead of splitting into 32-byte chunks

Merkle proof generation could be sped up the same way.

HTR of recent state - pre:

[arnetheduck@praeceps ncli]$ time ./ncli hashTreeRoot capella_state
./state.20230609.ssz
51f87eb876461ba7f3fea40e0c248b3de6db7c035501b3ec71f8449185fc0ac8

real	0m1.056s
user	0m0.942s
sys	0m0.111s

post:

[arnetheduck@praeceps ncli]$ time ./ncli hashTreeRoot capella_state
./state.20230609.ssz
51f87eb876461ba7f3fea40e0c248b3de6db7c035501b3ec71f8449185fc0ac8

real	0m0.832s
user	0m0.726s
sys	0m0.104s

Needs status-im/nim-stew#193

* use 64-byte buffer to pass a full sha256 block at a time to `digest`,
thus avoiding internal buffer copies
* avoid several unnecessary `zeroMem` calls via {.noinit.} / etc
* process blobs 64 bytes at a time instead of splitting into 32-byte
chunks

Merkle proof generation could be sped up the same way.

HTR of recent state - pre:
```
[arnetheduck@praeceps ncli]$ time ./ncli hashTreeRoot capella_state
./state.20230609.ssz
51f87eb876461ba7f3fea40e0c248b3de6db7c035501b3ec71f8449185fc0ac8

real	0m1.056s
user	0m0.942s
sys	0m0.111s
```

post:
```
[arnetheduck@praeceps ncli]$ time ./ncli hashTreeRoot capella_state
./state.20230609.ssz
51f87eb876461ba7f3fea40e0c248b3de6db7c035501b3ec71f8449185fc0ac8

real	0m0.832s
user	0m0.726s
sys	0m0.104s
```
+1 not needed
@zah zah merged commit 61e4806 into master Jul 20, 2023
12 checks passed
@zah zah deleted the avoid-copies branch July 20, 2023 08:09
arnetheduck added a commit to status-im/nimbus-eth2 that referenced this pull request Jul 21, 2023
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.

None yet

2 participants