ferranbt / fastssz

Fast Ethereum2.0 SSZ encoder/decoder
MIT License
74 stars 44 forks source link

Improve merkleizer #94

Closed ferranbt closed 2 years ago

ferranbt commented 2 years ago

This PR refactors the merkleizer logic using ideas from here. The new workflow is much simpler and has fewer code paths.

It speeds up the hashing by 10%.

Old

BenchmarkHashTreeRootFast
BenchmarkHashTreeRootFast-8        22938         52014 ns/op           0 B/op          0 allocs/op

New

BenchmarkHashTreeRootFast
BenchmarkHashTreeRootFast-8        24508         45571 ns/op           0 B/op          0 allocs/op