I profiled the hash_4 function in poseidon377 -- previously (in #21) I had focused on profiling the permute method where I had assumed 99% of the computation would be happening -- and it appears we've been using once_cell wrong in this repo. The docs state that using const for the Lazy variable will compile however it "works wrong" - instead static must be used. In our case this meant that every time we accessed the parameters struct, we were actually creating it all over again, resulting in a ton of wasted computation.
tl;dr This means I think that the speedup should not be not 30% as reported in #21 but closer to 30X - from testing on my M1 it's about 615us before vs 22us after (per hash)
I profiled the
hash_4
function inposeidon377
-- previously (in #21) I had focused on profiling thepermute
method where I had assumed 99% of the computation would be happening -- and it appears we've been usingonce_cell
wrong in this repo. The docs state that usingconst
for theLazy
variable will compile however it "works wrong" - insteadstatic
must be used. In our case this meant that every time we accessed the parameters struct, we were actually creating it all over again, resulting in a ton of wasted computation.tl;dr This means I think that the speedup should not be not 30% as reported in #21 but closer to 30X - from testing on my M1 it's about 615us before vs 22us after (per hash)