AztecProtocol / aztec-packages

Apache License 2.0
155 stars 157 forks source link

chore: generate PIL constants from via constants gen #7258

Closed dbanks12 closed 3 days ago

dbanks12 commented 4 days ago

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

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

AztecBot commented 4 days ago

Benchmark results

Metrics with a significant change:

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](https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/benchmarks-v1/pulls/7258.json). ### 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_30_ms | 11,892 (-1%) | 3,223 | 1,778 (-4%) | 1,452 (-10%) | 1,487 (-5%) | proof_construction_time_sha256_100_ms | 44,518 (-1%) | 12,022 | 5,544 | 5,511 | 5,444 | proof_construction_time_poseidon_hash_ms | 79.0 (-1%) | 35.0 | 34.0 (-3%) | 58.0 (-2%) | 88.0 | proof_construction_time_poseidon_hash_30_ms | 1,527 (-2%) | 420 (-1%) | 201 (-1%) | 229 (-1%) | 271 | proof_construction_time_poseidon_hash_100_ms | 5,811 (-1%) | 1,582 (-1%) | 727 (-1%) | 785 (+1%) | 801 (-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 | 1,412 | 1,412 | 1,412 | l1_rollup_calldata_gas | 9,476 | 9,474 | 9,452 | l1_rollup_execution_gas | 611,215 | 611,364 | 611,493 | l2_block_processing_time_in_ms | 756 (-3%) | 1,410 (-1%) | 2,761 (-1%) | l2_block_building_time_in_ms | 25,046 (-5%) | 49,468 | 98,791 (-5%) | l2_block_rollup_simulation_time_in_ms | 25,046 (-5%) | 49,468 | 98,791 (-5%) | l2_block_public_tx_process_time_in_ms | 21,587 (-5%) | 45,778 | 95,131 (-5%) | ### 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 | 7,043 | 9,874 | node_database_size_in_bytes | 12,238,928 | 16,154,704 | 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 | proving_time_in_ms | input_size_in_bytes | output_size_in_bytes | proof_size_in_bytes | num_public_inputs | size_in_gates | | - | - | - | - | - | - | - | - | - | private-kernel-init | 115 (-1%) | 495 (+8%) | 12,653 (-5%) | 20,634 | 67,190 | 92,352 | 2,819 | 524,288 | private-kernel-inner | 361 (-1%) | 926 (-14%) | 49,757 (+2%) | 94,902 | 67,190 | 92,352 | 2,819 | 2,097,152 | private-kernel-tail | 301 (-1%) | 1,756 | 47,663 (-3%) | 99,121 | 71,733 | 14,912 | 399 | 2,097,152 | base-parity | 6.39 (+2%) | 1,825 (+1%) | 2,742 (-3%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 49.0 (-2%) | 72.0 (-4%) | 40,243 (-3%) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | 7,787 (-1%) | 5,024 (+1%) | 84,933 | 170,330 | 728 | 3,648 | 47.0 | 4,194,304 | root-rollup | 111 (-1%) | 85.2 (-7%) | 24,437 (+4%) | 25,253 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | 637 | 3,790 | 45,613 (+1%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-app-logic | 587 (-2%) | 4,914 (+3%) | 46,696 (-4%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-tail | 1,397 (-1%) | 39,772 (+2%) | 192,599 (+4%) | 511,910 | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | 552 (-1%) | 2,089 (+7%) | 47,929 | 123,313 | 67,190 | 92,352 | 2,819 | 2,097,152 | public-kernel-teardown | 573 | 4,889 | 47,992 (-1%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | merge-rollup | 29.2 (-2%) | N/A | N/A | 16,486 | 728 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 7,105 (+2%) | 97,158 (+2%) | N/A | N/A | 125,344 | 3,850 | 4,194,304 | Stats on running time collected for app circuits | Function | input_size_in_bytes | output_size_in_bytes | witness_generation_time_in_ms | proof_size_in_bytes | proving_time_in_ms | size_in_gates | num_public_inputs | | - | - | - | - | - | - | - | - | ContractClassRegisterer:register | 1,344 | 9,944 | 406 (-2%) | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 9,944 | 39.9 | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 9,944 | 1,311 | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 9,944 | 958 (-1%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 9,944 | 502 (+1%) | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 9,944 | 1,891 | 16,768 | 54,389 (-2%) | 2,097,152 | 457 | Token:privately_mint_private_note | 1,280 | 9,944 | 638 (-1%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 9,944 | 303 (-1%) | 16,768 | 11,431 (-1%) | 524,288 | 457 | Token:transfer | 1,312 | 9,944 | 2,918 (+1%) | 16,768 | 23,142 (+2%) | 1,048,576 | 457 | AuthRegistry:set_authorized (avm) | 20,954 | N/A | N/A | 94,336 | 1,336 (-6%) | N/A | N/A | FPC:prepare_fee (avm) | 28,396 | N/A | N/A | 94,400 | 2,978 (-6%) | N/A | N/A | Token:transfer_public (avm) | 44,612 | N/A | N/A | 94,400 | 3,906 (-3%) | N/A | N/A | AuthRegistry:consume (avm) | 34,832 | N/A | N/A | 94,336 | 2,927 (-2%) | N/A | N/A | FPC:pay_refund (avm) | 38,561 | N/A | N/A | 94,368 | 23,245 (-2%) | N/A | N/A | Benchmarking:create_note | 1,344 | 9,944 | 481 (-1%) | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 9,944 | 72.5 | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 9,944 | 2,709 (+1%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 9,944 | 3,470 | N/A | N/A | N/A | N/A | ### AVM Simulation Time to simulate various public functions in the AVM. | Function | time_ms | bytecode_size_in_bytes | | - | - | - | GasToken:_increase_public_balance | 71.5 (-11%) | 13,790 | GasToken:set_portal | 19.6 (+4%) | 3,305 | Token:constructor | 97.9 (-1%) | 23,658 | FPC:constructor | 62.6 (-1%) | 13,592 | GasToken:mint_public | 52.2 (+2%) | 10,158 | Token:mint_public | :warning: 587 (**+711%**) | 19,000 | Token:assert_minter_and_mint | :warning: 57.6 (**-74%**) | 12,891 | AuthRegistry:set_authorized | 31.6 (-4%) | 7,812 | FPC:prepare_fee | 140 (+5%) | 15,062 | Token:transfer_public | :warning: 39.3 (**-46%**) | 31,184 | FPC:pay_refund | 152 (+3%) | 25,260 | Benchmarking:increment_balance | 2,615 (-2%) | 15,233 | Token:_increase_public_balance | 58.1 (+4%) | 14,972 | FPC:pay_refund_with_shielded_rebate | 133 (-27%) | 26,347 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.158 (-2%) | ### 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 | 10.5 (-1%) | 16.9 (-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.604 (-1%) | 0.517 (-1%) | N/A | N/A | N/A | N/A | N/A | batch_insert_into_append_only_tree_32_depth_ms | N/A | N/A | 48.8 (-1%) | 76.5 (-1%) | 131 (-4%) | 245 | 480 (-2%) | 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.498 (-1%) | 0.469 (-2%) | 0.450 (-4%) | 0.444 (-1%) | 0.447 (-2%) | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.7 (-2%) | 112 (-2%) | 183 (-4%) | 353 (-1%) | 712 (-1%) | 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.504 (-2%) | 0.502 (-2%) | 0.484 (-4%) | 0.478 (-1%) | 0.484 (-2%) | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 72.9 (-1%) | N/A | N/A | N/A | N/A | batch_insert_into_indexed_tree_40_depth_hash_count | N/A | N/A | 133 | N/A | N/A | N/A | N/A | batch_insert_into_indexed_tree_40_depth_hash_ms | N/A | N/A | 0.519 (-1%) | 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 | 85,707 | 670,983 | Transaction size based on fee payment method | Metric | | | - | |
Maddiaa0 commented 3 days ago

Great initiative @dbanks12 I am approving but please have a look at my comment. Furthermore, I suggest that whether we add some output messages about the need to run bb_pil whenever a relevant constant is modified. Alternatively, we could integrate bb_pil, format.sh as part of this script. Keeping it like this will lead to people getting issues down the road (unit tests failure, etc...) without understanding what they did wrong.

There is a script within barretenberg called rebuild_avm.sh / that we need to educate people to run once constants are generated