zkBob / libzeropool-zkbob

Apache License 2.0
0 stars 2 forks source link

Reduce number of runtime allocations #5

Closed AllFi closed 1 year ago

AllFi commented 1 year ago

This PR tries to reduce the number of runtime memory allocations during state syncing. The following was done:

  1. Note, account, and shared secret decryption can now be executed in place if the preallocated buffer size is enough.
  2. ecdh.x serialization doesn't allocate anything anymore.
  3. Note hashes deserialization occurs only when it is necessary.

There are still a lot of allocations in try_from_slice and rayon but it isn't something that could be easily fixed. There is some PR: https://github.com/near/borsh-rs/pull/115 that tries to implement heapless deserialization but it's not ready yet.