Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(avm): more stats and codegen cleanup #7475

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

fcarreiro
Copy link
Contributor

@fcarreiro fcarreiro commented Jul 15, 2024

  • Add trace size stats and proof sections time tracking
  • Use bb:constexpr_for instead of custom template that did the same

Example public transfer

bytecode size: 31218
calldata size: 6
public_inputs size: 481
hints.storage_value_hints size: 2
hints.note_hash_exists_hints size: 0
hints.nullifier_exists_hints size: 1
hints.l1_to_l2_message_exists_hints size: 0
hints.externalcall_hints size: 0
hints.contract_instance_hints size: 0
using cached crs of size 8388609 at "/mnt/user-data/facundo/.bb-crs/bn254_g1.dat"
Deserialized 2524 instructions
------- GENERATING TRACE -------
Trace sizes before padding:
        main_trace_size: 1638
        mem_trace_size: 3880
        alu_trace_size: 811
        range_check_size: 65536
        conv_trace_size: 1
        lookup_table_size: 0
        sha256_trace_size: 0
        poseidon2_trace_size: 0
        pedersen_trace_size: 4
        gas_trace_size: 1620
        fixed_gas_table_size: 65
        slice_trace_size: 7
Final trace size: 65537
------- PROVING EXECUTION -------
proof written to: "/mnt/user-data/facundo/tmp-8Q3xgk/proof"
vk written to: "/mnt/user-data/facundo/tmp-8Q3xgk/vk"
vk as fields written to: "/mnt/user-data/facundo/tmp-8Q3xgk/vk_fields.json"
------- STATS -------
incl_main_tag_err_ms: 78
incl_mem_tag_err_ms: 79
kernel_output_lookup_ms: 79
lookup_byte_lengths_ms: 75
lookup_byte_operations_ms: 81
lookup_cd_value_ms: 77
lookup_div_u16_0_ms: 100
lookup_div_u16_1_ms: 98
lookup_div_u16_2_ms: 99
lookup_div_u16_3_ms: 97
lookup_div_u16_4_ms: 99
lookup_div_u16_5_ms: 103
lookup_div_u16_6_ms: 97
lookup_div_u16_7_ms: 97
lookup_into_kernel_ms: 83
lookup_mem_rng_chk_hi_ms: 79
lookup_mem_rng_chk_lo_ms: 95
lookup_mem_rng_chk_mid_ms: 108
lookup_opcode_gas_ms: 78
lookup_pow_2_0_ms: 84
lookup_pow_2_1_ms: 79
lookup_ret_value_ms: 82
lookup_u16_0_ms: 107
lookup_u16_10_ms: 107
lookup_u16_11_ms: 96
lookup_u16_12_ms: 96
lookup_u16_13_ms: 97
lookup_u16_14_ms: 103
lookup_u16_1_ms: 95
lookup_u16_2_ms: 96
lookup_u16_3_ms: 97
lookup_u16_4_ms: 98
lookup_u16_5_ms: 111
lookup_u16_6_ms: 99
lookup_u16_7_ms: 97
lookup_u16_8_ms: 97
lookup_u16_9_ms: 96
lookup_u8_0_ms: 79
lookup_u8_1_ms: 77
perm_main_alu_ms: 82
perm_main_bin_ms: 76
perm_main_conv_ms: 75
perm_main_mem_a_ms: 80
perm_main_mem_b_ms: 77
perm_main_mem_c_ms: 75
perm_main_mem_d_ms: 77
perm_main_mem_ind_addr_a_ms: 76
perm_main_mem_ind_addr_b_ms: 77
perm_main_mem_ind_addr_c_ms: 74
perm_main_mem_ind_addr_d_ms: 76
perm_main_pedersen_ms: 75
perm_main_pos2_perm_ms: 79
perm_main_slice_ms: 74
perm_slice_mem_ms: 80
prove/check_circuit: 5120
prove/execute_log_derivative_inverse_commitments_round_ms: 532
prove/execute_log_derivative_inverse_round_ms: 5199
prove/execute_pcs_rounds_ms: 413
prove/execute_relation_check_rounds_ms: 1328
prove/execute_wire_commitments_round_ms: 1742
prove/gen_trace: 850
range_check_da_gas_hi_ms: 98
range_check_da_gas_lo_ms: 103
range_check_l2_gas_hi_ms: 100
range_check_l2_gas_lo_ms: 98

Copy link
Contributor Author

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

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

@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:assert_minter_and_mint): 69.3 (+43%)
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,712 (-1%) 1,542 (-1%) 700 (-1%) 751 (+1%) 768 (-1%)
proof_construction_time_sha256_30_ms 11,723 (-2%) 3,141 (-1%) 1,401 1,442 1,468 (+1%)
proof_construction_time_sha256_100_ms 43,779 (-1%) 11,713 (-1%) 5,922 (+9%) 5,408 5,353
proof_construction_time_poseidon_hash_ms 78.0 (-1%) 34.0 34.0 58.0 89.0 (+1%)
proof_construction_time_poseidon_hash_30_ms 1,517 (-1%) 415 (-2%) 200 225 (+3%) 264 (-3%)
proof_construction_time_poseidon_hash_100_ms 5,623 (-1%) 1,514 (-1%) 679 731 (+1%) 748 (-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 708 708 708
l1_rollup_calldata_gas 6,600 6,592 6,600
l1_rollup_execution_gas 583,062 583,205 583,364
l2_block_processing_time_in_ms 759 (+1%) 1,430 (+2%) 2,688 (-1%)
l2_block_building_time_in_ms 13,179 (+3%) 26,228 (+1%) 51,142 (+2%)
l2_block_rollup_simulation_time_in_ms 13,178 (+3%) 26,228 (+1%) 51,142 (+2%)
l2_block_public_tx_process_time_in_ms 11,055 (+3%) 23,848 (+1%) 48,775 (+3%)

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,077 (+1%) 10,045 (+3%)
node_database_size_in_bytes 12,468,304 16,355,408
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 proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 116 (+1%) 399 (-1%) 21,732 54,085 N/A N/A N/A N/A
private-kernel-inner 230 (+1%) 720 81,199 54,264 N/A N/A N/A N/A
private-kernel-tail 1,135 (+2%) 2,498 (+1%) 61,808 61,554 N/A N/A N/A N/A
base-parity 6.51 (+1%) 804 (-2%) 160 96.0 1,389 (-1%) 12,676 3.00 131,072
root-parity 108 (+2%) 121 (+2%) 64,860 96.0 30,935 (-2%) 12,676 3.00 4,194,304
base-rollup 4,251 (+1%) 4,983 (+1%) 180,315 632 44,691 (+1%) 13,476 28.0 4,194,304
root-rollup 152 (+1%) 121 (-3%) 51,261 652 28,913 (+1%) 13,412 26.0 4,194,304
public-kernel-setup 195 (+1%) 2,455 (+1%) 112,536 80,310 19,345 (+3%) 118,916 3,323 2,097,152
public-kernel-app-logic 151 (+1%) 3,398 (+2%) 112,536 80,310 10,369 (-2%) 118,916 3,323 1,048,576
public-kernel-tail 899 (+1%) 26,352 (+8%) 409,413 10,046 67,181 (-1%) 24,868 384 8,388,608
private-kernel-reset-tiny 299 (+1%) 1,011 77,007 53,954 N/A N/A N/A N/A
private-kernel-tail-to-public 6,796 2,926 (+3%) 777,415 1,632 N/A N/A N/A N/A
public-kernel-teardown 139 3,287 (-2%) 112,536 80,310 19,402 (+3%) 118,916 3,323 2,097,152
merge-rollup 57.5 (-2%) N/A 33,566 632 N/A N/A N/A N/A
undefined N/A N/A N/A N/A 163,476 (-1%) N/A N/A N/A

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
ContractClassRegisterer:register 1,312 9,344 398 (+1%) N/A N/A
ContractInstanceDeployer:deploy 1,376 9,344 25.2 (+1%) N/A N/A
MultiCallEntrypoint:entrypoint 1,888 9,344 628 N/A N/A
GasToken:deploy 1,344 9,344 578 (+2%) N/A N/A
SchnorrAccount:constructor 1,280 9,344 428 (-2%) N/A N/A
SchnorrAccount:entrypoint 2,272 9,344 768 (+1%) N/A N/A
Token:privately_mint_private_note 1,248 9,344 497 (-3%) N/A N/A
FPC:fee_entrypoint_public 1,312 9,344 99.7 N/A N/A
Token:transfer 1,280 9,344 1,467 N/A N/A
AuthRegistry:set_authorized (avm) 19,222 N/A N/A 95,392 2,086 (-7%)
FPC:prepare_fee (avm) 26,664 N/A N/A 95,456 2,765 (-7%)
Token:transfer_public (avm) 42,914 N/A N/A 95,456 3,173 (-5%)
AuthRegistry:consume (avm) 33,100 N/A N/A 95,424 2,753 (-6%)
FPC:pay_refund (avm) 36,829 N/A N/A 95,424 10,916 (-3%)
Benchmarking:create_note 1,312 9,344 425 N/A N/A
SchnorrAccount:verify_private_authwit 1,248 9,344 42.3 (+2%) N/A N/A
Token:unshield 1,344 9,344 1,181 N/A N/A
FPC:fee_entrypoint_private 1,344 9,344 1,537 (-1%) 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 101 (+2%) 13,790
GasToken:set_portal 11.6 (-7%) 3,339
Token:constructor 134 (+11%) 23,692
FPC:constructor 93.7 (+2%) 13,592
GasToken:mint_public 81.2 (+1%) 10,158
Token:mint_public 370 (+11%) 19,034
Token:assert_minter_and_mint ⚠️ 69.3 (+43%) 12,925
AuthRegistry:set_authorized 44.6 7,812
FPC:prepare_fee 101 (-3%) 15,062
Token:transfer_public 40.3 (-5%) 31,218
FPC:pay_refund 119 (-11%) 25,260
Benchmarking:increment_balance 1,357 (+2%) 15,267
Token:_increase_public_balance 16.4 (+10%) 15,006
FPC:pay_refund_with_shielded_rebate 177 (-1%) 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.4 (+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.600 (+1%) 0.518 (+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.2 (+1%) 75.7 (+1%) 131 (+2%) 249 (+2%) 469
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.492 (+1%) 0.466 (+1%) 0.449 (+2%) 0.450 (+2%) 0.438
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 59.7 (+1%) 112 (+2%) 182 (+1%) 355 (+1%) 691
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 (+1%) 0.501 (+1%) 0.483 (+1%) 0.479 (+1%) 0.475
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 73.1 (+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 76,847 667,838

Transaction size based on fee payment method

| Metric | |
| - | |

@fcarreiro fcarreiro force-pushed the fc/avm-stats-codegen branch from 6d5c26d to 5cc33d0 Compare July 15, 2024 20:38
@fcarreiro fcarreiro merged commit 1a6c7f2 into master Jul 15, 2024
92 checks passed
Copy link
Contributor Author

Merge activity

@fcarreiro fcarreiro deleted the fc/avm-stats-codegen branch July 15, 2024 21:25
rahul-kothari pushed a commit that referenced this pull request Jul 16, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](#7421))
([103f099](103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

<details><summary>barretenberg.js: 0.46.7</summary>

##
[0.46.7](barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.7</summary>

##
[0.46.7](aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](#7448))
([699fb79](699fb79))
* Add unconstrained getters to sharedmutable
([#7429](#7429))
([c0ff566](c0ff566))
* Devnet updates
([#7421](#7421))
([103f099](103f099))
* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))
* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](#7481))
([a3f6feb](a3f6feb))
* Fix msg_sender direct call exploit
([#7404](#7404))
([1dcae45](1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](#7493))
([b209fad](b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](#7336))
([0c7459b](0c7459b))
* Validate gas used
([#7459](#7459))
([6dc7598](6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](#7491))
([1e8a597](1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](71960d4))
* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Jul 17, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

<details><summary>barretenberg.js: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](AztecProtocol/aztec-packages#7448))
([699fb79](AztecProtocol/aztec-packages@699fb79))
* Add unconstrained getters to sharedmutable
([#7429](AztecProtocol/aztec-packages#7429))
([c0ff566](AztecProtocol/aztec-packages@c0ff566))
* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))
* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))
* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](AztecProtocol/aztec-packages#7481))
([a3f6feb](AztecProtocol/aztec-packages@a3f6feb))
* Fix msg_sender direct call exploit
([#7404](AztecProtocol/aztec-packages#7404))
([1dcae45](AztecProtocol/aztec-packages@1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](AztecProtocol/aztec-packages#7493))
([b209fad](AztecProtocol/aztec-packages@b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](AztecProtocol/aztec-packages#7336))
([0c7459b](AztecProtocol/aztec-packages@0c7459b))
* Validate gas used
([#7459](AztecProtocol/aztec-packages#7459))
([6dc7598](AztecProtocol/aztec-packages@6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](AztecProtocol/aztec-packages#7491))
([1e8a597](AztecProtocol/aztec-packages@1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](AztecProtocol/aztec-packages@71960d4))
* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants