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] Reduce allocations in ToBits for Plaintext #2458

Closed ljedrz closed 6 months ago

ljedrz commented 6 months ago

Calls to Plaintext::write_bits_le are responsible for a large number of allocations when performing deployments and executions; using a few simple tweaks we can reduce that number by as much as ~18% in some scenarios (my run was performed on a large deployment and execution).

Also, since we are dealing with OnceCell here, the additional calls to Vec::shrink_to_fit should be perfectly acceptable and slightly reduce heap use.

howardwu commented 6 months ago

We need CI here