AleoNet / snarkVM

A Virtual Machine for Zero-Knowledge Executions
https://snarkvm.org
Apache License 2.0
1.08k stars 1.5k forks source link

[Perf] Reserve the exact capacity in ToBits for BigIntegers #2514

Closed ljedrz closed 1 month ago

ljedrz commented 4 months ago

While heap-profiling the loading of the Canary ledger, I was surprised by the number of temporary allocations pointing to the ToBits impl for BigInteger256; it appears that the Extend impl that's used there is not able to take advantage of the ExactSizeIterator impl for BitIteratorLE, and we need to be more explicit in order to avoid them.

The results at height 330598 are as follows:

ljedrz commented 4 months ago

CI run link