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

fix: Attach Brillig function ids to TS errors #7930

Merged
merged 10 commits into from
Aug 13, 2024

Conversation

vezenovm
Copy link
Contributor

@vezenovm vezenovm commented Aug 12, 2024

After noir-lang/noir#5696 Brillig locations have been split out from ACIR locations in the DebugMetadata. As to maintain appropriate call stacks in the simulator we need to attach a possible brillig function id (if we error'd out in a Brillig function) to our TS errors. The resolution of debug metadata locations was also updated to account for the additional optional brillig function id.

@AztecBot
Copy link
Collaborator

AztecBot commented Aug 12, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_simulation_time_in_ms (root-parity): 31.5 (-71%)
  • protocol_circuit_simulation_time_in_ms (root-rollup): 37.8 (-61%)
  • protocol_circuit_simulation_time_in_ms (private-kernel-tail-to-public): 2,718 (+21%)
  • protocol_circuit_simulation_time_in_ms (merge-rollup): 18.7 (-68%)
  • avm_simulation_time_ms (FeeJuice:_increase_public_balance): 54.5 (-42%)
  • avm_simulation_time_ms (Token:constructor): 85.7 (-37%)
  • avm_simulation_time_ms (FPC:constructor): 55.2 (-41%)
  • avm_simulation_time_ms (FeeJuice:mint_public): 42.1 (-48%)
  • avm_simulation_time_ms (Token:mint_public): 45.3 (-51%)
  • avm_simulation_time_ms (Token:transfer_public): 22.0 (-48%)
  • avm_simulation_time_ms (FPC:pay_refund_with_shielded_rebate): 96.1 (-31%)
  • protocol_circuit_witness_generation_time_in_ms (base-parity): 281 (-55%)
  • protocol_circuit_witness_generation_time_in_ms (root-parity): 51.3 (-62%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-tail): 25,222 (-20%)
  • protocol_circuit_witness_generation_time_in_ms (root-rollup): 53.0 (-55%)
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,784 1,560 693 (-2%) 758 (-1%) 770 (-1%)
proof_construction_time_sha256_30_ms 11,875 (-1%) 3,172 (-1%) 1,408 (-1%) 1,448 1,469 (-1%)
proof_construction_time_sha256_100_ms 44,150 (-1%) 12,364 (-1%) 5,649 (-2%) 5,536 (-2%) 5,485 (-1%)
proof_construction_time_poseidon_hash_ms 78.0 (-1%) 34.0 (-3%) 34.0 58.0 (-2%) 88.0 (+1%)
proof_construction_time_poseidon_hash_30_ms 1,536 421 201 (+1%) 231 284 (+6%)
proof_construction_time_poseidon_hash_100_ms 5,672 1,537 678 743 (-1%) 751 (-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,708 92,458 177,764
l1_rollup_execution_gas 1,294,371 2,042,089 3,869,434
l2_block_processing_time_in_ms 268 (+3%) 453 (+1%) 840 (+2%)
l2_block_building_time_in_ms 9,430 (-2%) 18,765 37,088 (-2%)
l2_block_rollup_simulation_time_in_ms 9,430 (-2%) 18,765 37,088 (-2%)
l2_block_public_tx_process_time_in_ms 7,950 (-1%) 17,130 (+1%) 35,449 (-1%)

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 3,034 3,988 (+4%)
node_database_size_in_bytes 12,705,872 16,900,176
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 100 (+5%) 421 (+7%) 21,846 44,858 N/A N/A N/A N/A
private-kernel-inner 168 (-4%) 743 (+8%) 72,545 45,005 N/A N/A N/A N/A
private-kernel-tail 663 774 (+4%) 52,710 52,256 N/A N/A N/A N/A
base-parity 6.09 ⚠️ 281 (-55%) 160 96.0 1,080 (-4%) 13,188 19.0 65,536
root-parity ⚠️ 31.5 (-71%) ⚠️ 51.3 (-62%) 69,084 96.0 26,717 (-11%) 13,188 19.0 4,194,304
base-rollup 2,979 (-1%) 5,881 (+4%) 187,824 664 83,472 (-13%) 14,020 45.0 16,777,216
root-rollup ⚠️ 37.8 (-61%) ⚠️ 53.0 (-55%) 54,525 716 24,433 (-14%) 13,988 44.0 4,194,304
public-kernel-setup 91.5 (+2%) 2,731 (-3%) 103,782 71,222 14,826 (-13%) 129,220 3,645 2,097,152
public-kernel-app-logic 107 (+1%) 4,142 103,598 71,222 8,489 (-15%) 129,220 3,645 1,048,576
public-kernel-tail 578 (+2%) ⚠️ 25,222 (-20%) 409,190 16,414 90,907 (-14%) 34,308 679 16,777,216
private-kernel-reset-tiny 182 (-6%) 900 (+9%) 68,621 44,750 N/A N/A N/A N/A
private-kernel-tail-to-public ⚠️ 2,718 (+21%) 1,597 (+6%) 931,564 1,697 N/A N/A N/A N/A
public-kernel-teardown 87.3 (+2%) 4,180 104,005 71,222 16,004 (-13%) 129,220 3,645 2,097,152
merge-rollup ⚠️ 18.7 (-68%) N/A 35,742 664 N/A N/A N/A N/A
undefined N/A N/A N/A N/A 65,019 (-3%) 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,344 11,731 346 (+1%) N/A N/A
ContractInstanceDeployer:deploy 1,408 11,731 18.9 (+6%) N/A N/A
MultiCallEntrypoint:entrypoint 1,920 11,731 469 (-1%) N/A N/A
FeeJuice:deploy 1,376 11,731 395 (+2%) N/A N/A
SchnorrAccount:constructor 1,312 11,731 172 (-2%) N/A N/A
SchnorrAccount:entrypoint 2,304 11,731 508 (-4%) N/A N/A
Token:privately_mint_private_note 1,280 11,731 226 (+5%) N/A N/A
FPC:fee_entrypoint_public 1,344 11,731 22.6 (-6%) N/A N/A
Token:transfer 1,312 11,731 423 (+5%) N/A N/A
AuthRegistry:set_authorized (avm) 18,491 N/A N/A 146,400 2,243 (+4%)
FPC:prepare_fee (avm) 22,958 N/A N/A 146,464 2,600 (+4%)
Token:transfer_public (avm) 61,614 N/A N/A 146,464 9,054 (-13%)
AuthRegistry:consume (avm) 41,719 N/A N/A 146,432 4,759 (-7%)
FPC:pay_refund (avm) 26,227 N/A N/A 146,432 4,403 (-11%)
Benchmarking:create_note 1,344 11,731 165 (-2%) N/A N/A
SchnorrAccount:verify_private_authwit 1,280 11,731 32.7 (+19%) N/A N/A
Token:unshield 1,376 11,731 636 N/A N/A
FPC:fee_entrypoint_private 1,376 11,731 842 (+2%) N/A N/A

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance ⚠️ 54.5 (-42%) 8,139
FeeJuice:set_portal 9.68 (-11%) 2,362
Token:constructor ⚠️ 85.7 (-37%) 31,107
FPC:constructor ⚠️ 55.2 (-41%) 22,380
FeeJuice:mint_public ⚠️ 42.1 (-48%) 6,150
Token:mint_public ⚠️ 45.3 (-51%) 11,720
Token:assert_minter_and_mint 72.8 (-9%) 8,028
AuthRegistry:set_authorized 7.43 (+13%) 4,537
FPC:prepare_fee 258 (-4%) 8,812
Token:transfer_public ⚠️ 22.0 (-48%) 47,374
FPC:pay_refund 58.9 (+1%) 12,114
Benchmarking:increment_balance 1,021 7,450
Token:_increase_public_balance 11.5 (+18%) 8,960
FPC:pay_refund_with_shielded_rebate ⚠️ 96.1 (-31%) 12,663

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.157 (-4%)

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.21 (+2%) 3.92 (+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.115 (+2%) 0.111 (+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.5 17.9 (+1%) 31.2 (-1%) 60.5 (+3%) 119 (+3%)
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.110 0.104 (+1%) 0.101 (-1%) 0.104 (+3%) 0.106 (+3%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.7 (+1%) 25.8 (+1%) 45.4 (+2%) 83.2 (+2%) 164 (-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.113 (+3%) 0.104 0.105 (-1%) 0.103 (+2%) 0.103 (-2%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.7 (+1%) 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.107 (+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 64,756 668,997

Transaction size based on fee payment method

| Metric | |
| - | |

BTreeMap<OpcodeLocation, Vec<Location>>,
> = BTreeMap::new();
for (brillig_function_id, opcode_locations_map) in
patched_debug_info.brillig_locations.iter()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the crux of the AVM changes in this PR @fcarreiro. All Brillig debug locations are going to be contained within a separate per function brillig locations map now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could just fetch at id 0 here as we make the assumption already that we have a single brillig function. Let me know what you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it works I don't mind the solution! The transpiler is not a bottleneck now.

@vezenovm vezenovm marked this pull request as ready for review August 13, 2024 13:50
Copy link
Contributor

@sirasistant sirasistant left a comment

Choose a reason for hiding this comment

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

Looks good on my side

BTreeMap<OpcodeLocation, Vec<Location>>,
> = BTreeMap::new();
for (brillig_function_id, opcode_locations_map) in
patched_debug_info.brillig_locations.iter()
Copy link
Contributor

Choose a reason for hiding this comment

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

If it works I don't mind the solution! The transpiler is not a bottleneck now.

@vezenovm vezenovm merged commit 29d4e66 into sync-noir Aug 13, 2024
21 of 23 checks passed
@vezenovm vezenovm deleted the mv/brillig-id-ts-errors branch August 13, 2024 14:24
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.

4 participants