decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
731 stars 289 forks source link

mixing: Reduce slot reservation mix pads allocs. #3387

Closed davecgh closed 1 month ago

davecgh commented 1 month ago

This significantly reduces the number of allocations needed to create a vector of exponential DC-net pads by reusing a digest slice prior to converting the result to a big integer.

Specifically, it reduces the allocations for the digest calculation from quadratic in the number of participants to a single alloc. The big integers themselves are still predominantly linear in the number of participants, however, they are not entirely linear because the big ints involve multiple allocations as the numbers grow larger prior to the modular reduction.

For a concrete example, with 15 participants, the total number of overall allocations with this change is reduced from 257 down to 47.