AleoNet / snarkVM

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

[Benchmark] Add benchmarks of `LimitedWriter` #2446

Closed iamalwaysuncomfortable closed 6 months ago

iamalwaysuncomfortable commented 6 months ago

Motivation

LimitedWriter.write_le method is used to verify transaction sizes are below the minimum limit. Thus it makes sense to benchmark this method and the check_transaction method which encapsulates it.

This PR adds benchmarks of the following:

  1. LimitedWriter.write_le and for transfer_public, transfer_private methods within credits.aleo
  2. Benchmarks of both VM.check_transaction and LimitedWriter.write_le for a program called too_big.aleo that generates an execution transaction above 160kb.

Results (Mac OSX - M1 Max: 10-core CPU - Memory: 64GB)

LimitedWriter::new - transfer_public
                        time:   [11.136 µs 12.007 µs 13.021 µs]

Transaction::Execute(transfer_public) - verify
                        time:   [15.048 ms 19.123 ms 22.293 ms]

LimitedWriter::new - transfer_private
                        time:   [11.076 µs 12.442 µs 13.927 µs]

Transaction::Execute(transfer_private) - verify
                        time:   [14.654 ms 19.755 ms 25.494 ms]

LimitedWriter::new - too_big.aleo (164613 bytes)
                        time:   [2.1626 ms 2.4037 ms 2.6260 ms]

Transaction::Execute(too_big.aleo) - verify (164613)
                        time:   [2.0601 ms 2.2421 ms 2.4375 ms]

Results

  1. LimitedWriter for transactions over the maximum are about 15% of the total runtime.
  2. LimitedWriter.write_le for transfer_publics execution transactions (which are ~3kb) take %0.07 of the total runtime of the check_transaction check.
  3. For transactions over the size check limit - the total verification time is shortened.