perf: use precomputed zero hashes in process_subtree
Stacked on https://github.com/ralexstokes/ssz-rs/pull/169
A lot of leaves are empty and we don't need to hash them or their parents.
Precomputing zero hashes for leafs
Prove Benchmark - File: benches/21315748.json - size 247/123
time: [96.891 ms 97.480 ms 98.564 ms]
change: [-36.824% -36.084% -35.371%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking Prove Benchmark - File: benches/21327802.json - size 261/130: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.3s or enable flat sampling.
Prove Benchmark - File: benches/21327802.json - size 261/130
time: [96.672 ms 97.006 ms 97.291 ms]
change: [-38.752% -37.874% -37.086%] (p = 0.00 < 0.05)
Performance has improved.
On the layer above we can do a similar thing; if both the leaves are zero hashes we can precompute their parent as well.
Precomputing hash for parent of zero leafs
Prove Benchmark - File: benches/21315748.json - size 247/123
time: [63.227 ms 63.584 ms 63.845 ms]
change: [-36.239% -35.537% -34.850%] (p = 0.00 < 0.05)
Performance has improved.
Prove Benchmark - File: benches/21327802.json - size 261/130
time: [64.678 ms 66.169 ms 66.956 ms]
change: [-33.989% -33.024% -31.938%] (p = 0.00 < 0.05)
Performance has improved.
Precomputing hash for grandparent of zero leafs
Prove Benchmark - File: benches/21315748.json - size 247/123
time: [48.241 ms 48.500 ms 48.906 ms]
change: [-24.267% -23.604% -22.946%] (p = 0.00 < 0.05)
Performance has improved.
Prove Benchmark - File: benches/21327802.json - size 261/130
time: [48.734 ms 48.919 ms 49.099 ms]
change: [-25.885% -24.824% -23.838%] (p = 0.00 < 0.05)
Performance has improved.
Precomputing hash for grandgrandparent of zero leafs
Prove Benchmark - File: benches/21315748.json - size 247/123
time: [43.100 ms 43.391 ms 43.802 ms]
change: [-11.776% -10.765% -9.7800%] (p = 0.00 < 0.05)
Performance has improved.
Prove Benchmark - File: benches/21327802.json - size 261/130
time: [42.164 ms 42.418 ms 42.634 ms]
change: [-14.061% -13.283% -12.492%] (p = 0.00 < 0.05)
Performance has improved.
Precomputing hash for 3grandparent of zero leafs
Prove Benchmark - File: benches/21315748.json - size 247/123
time: [37.652 ms 38.012 ms 38.278 ms]
change: [-13.360% -12.260% -11.088%] (p = 0.00 < 0.05)
Performance has improved.
Prove Benchmark - File: benches/21327802.json - size 261/130
time: [38.637 ms 38.999 ms 39.661 ms]
change: [-8.9076% -7.4886% -6.1347%] (p = 0.00 < 0.05)
Performance has improved.
Since PRs are stacked it is a bit difficult to see the new changes. Can you outline a changelog or specify what are the main new functions introduced and where are they used?
superseeded by https://github.com/ralexstokes/ssz-rs/pull/177