aztec-packages icon indicating copy to clipboard operation
aztec-packages copied to clipboard

refactor(avm): separate alu finalization

Open fcarreiro opened this issue 1 year ago • 2 comments

PIL

  • Moved ALU lookups to alu.pil. These are mostly range checks and I expect them to be different once @IlyasRidhuan finishes setting up the gadget changes.

CPP

  • Made ALU entry smaller and encapsulated finalize.

fcarreiro avatar Aug 19 '24 14:08 fcarreiro

  • #8069 Graphite 👈
  • master

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @fcarreiro and the rest of your teammates on Graphite Graphite

fcarreiro avatar Aug 19 '24 14:08 fcarreiro

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:mint_public): 68.8 (+60%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 43.1 (-35%)
Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256_ms 5,790 (+1%) 1,556 707 759 770 (-1%)
proof_construction_time_sha256_30_ms 11,840 3,166 (-1%) 1,412 (-1%) 1,437 1,467 (-1%)
proof_construction_time_sha256_100_ms 45,435 11,880 (-1%) 5,425 (-2%) 5,417 (-1%) 5,360 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 56.0 (-5%) 88.0 (+1%)
proof_construction_time_poseidon_hash_30_ms 1,537 421 202 233 265 (-1%)
proof_construction_time_poseidon_hash_100_ms 5,676 (+1%) 1,516 682 737 (+2%) 747 (-1%)

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 4,324 7,844 14,852
l1_rollup_calldata_gas 49,696 92,436 177,680
l1_rollup_execution_gas 1,383,190 2,130,898 3,958,181
l2_block_processing_time_in_ms 259 (+5%) 434 (-1%) 821
l2_block_building_time_in_ms 9,005 (+1%) 17,372 (-1%) 35,066 (+2%)
l2_block_rollup_simulation_time_in_ms 9,005 (+1%) 17,372 (-1%) 35,065 (+2%)
l2_block_public_tx_process_time_in_ms 7,604 (+1%) 15,867 (-1%) 33,532 (+2%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 8 txs.

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 2,827 3,690 (-4%)
node_database_size_in_bytes 12,607,568 16,711,760
pxe_database_size_in_bytes 16,254 26,813

Circuits stats

Stats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.

Circuit simulation_time_in_ms witness_generation_time_in_ms input_size_in_bytes output_size_in_bytes proving_time_in_ms
private-kernel-init 82.8 (-7%) 400 (+1%) 21,502 44,858 N/A
private-kernel-inner 158 (+2%) 728 (+3%) 72,180 45,005 N/A
private-kernel-reset-tiny 471 891 (+2%) 65,502 44,844 N/A
private-kernel-tail 200 (+1%) 161 (-1%) 50,606 52,256 N/A
base-parity 5.59 (+1%) N/A 160 96.0 N/A
root-parity 33.2 N/A 69,084 96.0 N/A
base-rollup 2,749 N/A 187,817 664 N/A
root-rollup 39.0 N/A 54,525 716 N/A
public-kernel-setup 83.0 (-1%) N/A 103,760 71,222 N/A
public-kernel-app-logic 95.1 (-1%) N/A 103,599 71,222 N/A
public-kernel-tail 555 N/A 409,190 16,414 N/A
private-kernel-reset-small 466 (-1%) N/A 66,085 45,629 N/A
private-kernel-tail-to-public 990 (-4%) 649 (-1%) 473,529 1,697 N/A
public-kernel-teardown 82.4 N/A 104,005 71,222 N/A
merge-rollup 19.1 (-1%) N/A 35,742 664 N/A
undefined N/A N/A N/A N/A 66,591 (+2%)

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms
ContractClassRegisterer:register 1,344 11,731 343
ContractInstanceDeployer:deploy 1,408 11,731 18.3
MultiCallEntrypoint:entrypoint 1,920 11,731 421
FeeJuice:deploy 1,376 11,731 390
SchnorrAccount:constructor 1,312 11,731 104 (-1%)
SchnorrAccount:entrypoint 2,304 11,731 429
Token:privately_mint_private_note 1,280 11,731 138 (-1%)
FPC:fee_entrypoint_public 1,344 11,731 26.9
Token:transfer 1,312 11,731 274 (+1%)
Benchmarking:create_note 1,344 11,731 100 (-3%)
SchnorrAccount:verify_private_authwit 1,280 11,731 27.4 (-1%)
Token:unshield 1,376 11,731 553 (-1%)
FPC:fee_entrypoint_private 1,376 11,731 749 (+1%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 54.0 (+2%) 7,739
FeeJuice:set_portal 11.8 (-1%) 2,354
Token:constructor 79.8 26,525
FPC:constructor 51.4 (-2%) 18,383
FeeJuice:mint_public 38.6 (+2%) 5,877
Token:mint_public :warning: 68.8 (+60%) 10,917
Token:assert_minter_and_mint :warning: 43.1 (-35%) 7,512
AuthRegistry:set_authorized 46.4 (+2%) 4,391
FPC:prepare_fee 237 (+2%) 7,712
Token:transfer_public 34.4 (+27%) 39,946
FPC:pay_refund 55.6 (-4%) 10,811
Benchmarking:increment_balance 929 (-1%) 6,929
Token:_increase_public_balance 39.4 (-1%) 8,433
FPC:pay_refund_with_shielded_rebate 64.2 (-1%) 11,360

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.155 (-6%)

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 256 leaves 512 leaves 1024 leaves
batch_insert_into_append_only_tree_16_depth_ms 2.22 (+1%) 3.93 (+1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.116 (+1%) 0.112 (+1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.7 17.9 (+1%) 31.7 (+4%) 58.4 (-1%) 115 (+1%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.113 0.104 (+1%) 0.103 (+3%) 0.101 (-1%) 0.102
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.5 25.8 (+1%) 44.5 (+3%) 81.8 (-1%) 162
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.111 0.104 (+1%) 0.108 (+3%) 0.102 (-1%) 0.103
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.5 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 132 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.106 N/A N/A N/A N/A

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 64,779 668,997

Transaction size based on fee payment method

| Metric | | | - | |

AztecBot avatar Aug 19 '24 15:08 AztecBot