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

feat(avm): sha256_compression #6452

Merged
merged 1 commit into from
May 29, 2024
Merged

Conversation

IlyasRidhuan
Copy link
Contributor

Please read contributing guidelines and remove this line.

Copy link
Contributor Author

IlyasRidhuan commented May 16, 2024

@AztecBot
Copy link
Collaborator

AztecBot commented May 16, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_simulation_time_in_ms (private-kernel-inner): 601 (+48%)
  • protocol_circuit_simulation_time_in_ms (public-kernel-setup): 428 (-35%)
  • protocol_circuit_simulation_time_in_ms (public-kernel-teardown): 378 (-33%)
  • protocol_circuit_input_size_in_bytes (public-kernel-setup): 86,385 (-18%)
  • protocol_circuit_input_size_in_bytes (public-kernel-teardown): 86,975 (-17%)
  • protocol_circuit_output_size_in_bytes (public-kernel-setup): 72,553 (-16%)
  • protocol_circuit_output_size_in_bytes (public-kernel-teardown): 72,990 (-16%)
  • app_circuit_proving_time_in_ms (Token:transfer): 59,564 (+28%)
  • protocol_circuit_witness_generation_time_in_ms (private-kernel-init): 3,468 (+592%)
  • protocol_circuit_witness_generation_time_in_ms (private-kernel-inner): 3,969 (+295%)
  • protocol_circuit_witness_generation_time_in_ms (base-parity): 743 (-42%)
  • protocol_circuit_witness_generation_time_in_ms (base-rollup): 7,083 (+205%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-app-logic): 986 (-69%)
  • protocol_circuit_witness_generation_time_in_ms (root-parity): 151 (+216%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-tail): 6,399 (-73%)
  • protocol_circuit_witness_generation_time_in_ms (root-rollup): 131 (+104%)
  • protocol_circuit_proving_time_in_ms (private-kernel-init): 24,632 (+105%)
  • protocol_circuit_proving_time_in_ms (private-kernel-inner): 50,119 (+27%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail): 42,460 (+16%)
  • protocol_circuit_proving_time_in_ms (base-parity): 7,714 (+168%)
  • protocol_circuit_proving_time_in_ms (public-kernel-app-logic): 13,451 (-72%)
  • protocol_circuit_proving_time_in_ms (base-rollup): 121,057 (+62%)
  • protocol_circuit_proving_time_in_ms (root-parity): 102,702 (+134%)
  • protocol_circuit_proving_time_in_ms (public-kernel-tail): 46,278 (-70%)
  • protocol_circuit_proof_size_in_bytes (public-kernel-app-logic): 83,960 (-28%)
  • protocol_circuit_size_in_gates (private-kernel-init): 1,048,576 (+100%)
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,754 1,556 711 745 768
proof_construction_time_sha256_30_ms 11,474 3,080 1,377 1,420 1,466
proof_construction_time_sha256_100_ms 44,019 11,798 5,522 5,641 5,365
proof_construction_time_poseidon_hash_ms 235 80.0 58.0 89.0 147
proof_construction_time_poseidon_hash_30_ms 5,755 1,571 721 778 793
proof_construction_time_poseidon_hash_100_ms 11,383 3,055 1,368 1,408 1,452

L2 block published to L1

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

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 1,412 1,412 1,412
l1_rollup_calldata_gas 9,464 9,476 9,476
l1_rollup_execution_gas 616,105 616,117 616,117
l2_block_processing_time_in_ms 1,288 (-1%) 4,795 (-2%) 9,530 (-1%)
l2_block_building_time_in_ms 45,601 (-1%) 180,874 (-1%) 362,066 (-1%)
l2_block_rollup_simulation_time_in_ms 45,432 (-1%) 180,241 (-1%) 360,810 (-1%)
l2_block_public_tx_process_time_in_ms 24,498 (-1%) 102,459 (-1%) 210,134

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 9,444 (-1%) 14,352 (-1%)
node_database_size_in_bytes 14,475,344 21,397,584
pxe_database_size_in_bytes 18,071 29,868

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 159 (+20%) ⚠️ 3,468 (+592%) ⚠️ 24,632 (+105%) 20,497 (-1%) 63,343 (-2%) 89,536 2,731 ⚠️ 1,048,576 (+100%)
private-kernel-inner ⚠️ 601 (+48%) ⚠️ 3,969 (+295%) ⚠️ 50,119 (+27%) 90,644 (-2%) 63,099 (-2%) 89,536 2,731 2,097,152
private-kernel-tail 564 (-3%) 2,704 (-10%) ⚠️ 42,460 (+16%) 96,541 77,732 11,648 297 2,097,152
base-parity 7.51 (+14%) ⚠️ 743 (-42%) ⚠️ 7,714 (+168%) 128 64.0 2,208 2.00 131,072
root-parity 50.4 (+1%) ⚠️ 151 (+216%) ⚠️ 102,702 (+134%) 27,080 64.0 2,720 18.0 2,097,152
base-rollup 736 (+2%) ⚠️ 7,083 (+205%) ⚠️ 121,057 (+62%) 119,174 766 (+1%) 3,285 (-10%) 47.0 4,194,304
root-rollup 105 (-6%) ⚠️ 131 (+104%) 19,346 22,989 (-9%) 648 (+5%) 3,440 41.0 1,048,576
public-kernel-app-logic 518 (-3%) ⚠️ 986 (-69%) ⚠️ 13,451 (-72%) 104,291 (-1%) 85,836 (-1%) ⚠️ 83,960 (-28%) 3,582 2,097,152
public-kernel-tail 1,094 (-2%) ⚠️ 6,399 (-73%) ⚠️ 46,278 (-70%) 390,075 (-3%) 7,648 10,496 (-10%) 297 8,388,608
private-kernel-reset-small 586 (-1%) 1,959 (-12%) 49,980 (+10%) 120,733 64,614 89,536 2,731 2,097,152
private-kernel-reset 612 N/A N/A 210,456 41,446 N/A N/A N/A
private-kernel-ordering 342 N/A N/A 61,368 39,490 N/A N/A N/A
public-kernel-setup ⚠️ 428 (-35%) 318 458 ⚠️ 86,385 (-18%) ⚠️ 72,553 (-16%) 73,024 N/A N/A
public-kernel-teardown ⚠️ 378 (-33%) 277 393 ⚠️ 86,975 (-17%) ⚠️ 72,990 (-16%) 73,024 N/A N/A
merge-rollup 28.5 (-1%) 128 3,380 16,534 756 3,104 N/A N/A
private-kernel-tail-to-public N/A 8,065 (-6%) 102,084 (+12%) N/A N/A 116,768 3,582 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 458 (-3%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 40.8 (-3%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,485 (+2%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,070 (+8%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,101 (-1%) 16,768 54,155 (+11%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,073 (-6%) N/A N/A N/A N/A
Token:transfer 1,376 9,944 3,992 (-2%) 16,768 ⚠️ 59,564 (+28%) 2,097,152 457
Benchmarking:create_note 1,312 9,944 952 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 229 (+2%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.6 (-7%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,243 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,036 N/A N/A N/A N/A

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 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.7 (+2%) 17.3 (+2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.7 31.8 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.623 (+2%) 0.531 (+2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 50.0 (+2%) 75.9 (-1%) 246 (-1%) 474 (-1%) 925 (-2%) 1,835 (-1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.512 (+2%) 0.468 (-1%) 0.447 (-1%) 0.442 (-1%) 0.438 (-2%) 0.438 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 61.0 (+4%) 113 (-1%) 354 (-1%) 697 (-1%) 1,380 (-1%) 2,747 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 107 (+1%) 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.523 (+3%) 0.505 (-1%) 0.480 (-1%) 0.479 (-1%) 0.477 (-1%) 0.477 (-1%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 64.0 (+1%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 107
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.562

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 82,782 (-2%) 759,695 (+14%)

Transaction size based on fee payment method

| Metric | |
| - | |

@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch 2 times, most recently from 5d23f5d to da3dc4a Compare May 16, 2024 11:33
Copy link
Contributor

@jeanmon jeanmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

barretenberg/cpp/pil/avm/avm_main.pil Show resolved Hide resolved
barretenberg/cpp/pil/avm/avm_main.pil Outdated Show resolved Hide resolved
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from da3dc4a to 4e10cfd Compare May 17, 2024 11:55
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from 4e10cfd to 56a59d1 Compare May 22, 2024 11:51
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from 56a59d1 to 7be5bda Compare May 22, 2024 16:21
@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review May 23, 2024 08:21
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch 2 times, most recently from dc2aac0 to 59d97c1 Compare May 28, 2024 08:53
Copy link
Contributor

@jeanmon jeanmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work. Please look at my comments.

@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from 59d97c1 to 2fcf252 Compare May 29, 2024 14:10
Copy link
Contributor

Changes to circuit sizes

Generated at commit: 90ef856fd960ac0495f3185e03b0d3c04ed9af44, compared to commit: defd2ba1474dacff6b0bfdbadc31d963450ef9cd

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_init +200,795 ❌ +660.90% +474,088 ❌ +121.12%
private_kernel_inner +212,933 ❌ +401.69% +500,509 ❌ +39.02%
private_kernel_tail +8,432 ❌ +4.41% +7,418 ❌ +0.51%
private_kernel_tail_to_public +8,432 ❌ +1.50% +7,417 ❌ +0.34%
public_kernel_setup +1,247 ❌ +0.55% +1,241 ❌ +0.08%
public_kernel_app_logic +1,344 ❌ +0.51% +1,338 ❌ +0.08%
public_kernel_teardown +1,344 ❌ +0.51% +1,338 ❌ +0.08%
public_kernel_tail +1,976 ❌ +0.20% +1,166 ❌ +0.03%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_init 231,177 (+200,795) +660.90% 865,493 (+474,088) +121.12%
private_kernel_inner 265,942 (+212,933) +401.69% 1,783,212 (+500,509) +39.02%
private_kernel_tail 199,822 (+8,432) +4.41% 1,465,208 (+7,418) +0.51%
private_kernel_tail_to_public 569,878 (+8,432) +1.50% 2,177,882 (+7,417) +0.34%
public_kernel_setup 226,165 (+1,247) +0.55% 1,550,783 (+1,241) +0.08%
public_kernel_app_logic 266,789 (+1,344) +0.51% 1,697,614 (+1,338) +0.08%
public_kernel_teardown 267,146 (+1,344) +0.51% 1,698,012 (+1,338) +0.08%
public_kernel_tail 981,773 (+1,976) +0.20% 4,470,699 (+1,166) +0.03%

@IlyasRidhuan IlyasRidhuan merged commit 5596bb3 into master May 29, 2024
85 checks passed
@IlyasRidhuan IlyasRidhuan deleted the 05-14-feat_avm_sha256_compression branch May 29, 2024 14:54
TomAFrench added a commit that referenced this pull request May 29, 2024
* master:
  chore: add linting to avm-transpiler CI (#6732)
  feat(avm): poseidon2 gadget (#6504)
  chore(ci): try a different ubuntu runner (#6740)
  feat(nargo): hidden option to show contract artifact paths written by `nargo compile` (#6131)
  feat(avm): sha256_compression (#6452)
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