Skip to content

feat: Restore hashing args via slice for performance - #5539

Merged
sirasistant merged 1 commit into
masterfrom
arv/restore_args_slice
Apr 3, 2024
Merged

feat: Restore hashing args via slice for performance#5539
sirasistant merged 1 commit into
masterfrom
arv/restore_args_slice

Conversation

@sirasistant

Copy link
Copy Markdown
Contributor

I replaced the ArgsHasher struct with a BoundedVec because a noir version completely separated slices and generic arrays in the frontend, so we couldn't pass it to the hash_args fn that needed an array. This makes unconstrained fns slower since they have to allocate in memory the full max length that the arguments could have.
In this PR I instead move to a full slice approach, where hash_args takes a slice and hash_args_array just casts it to a slice. This avoids allocating memory unnecessarily in public functions.

@AztecBot

ghost commented Apr 3, 2024

Copy link
Copy Markdown
Collaborator

Benchmark results

Metrics with a significant change:

  • tx_sequencer_processing_time_ms (3): 911 (-22%)
  • tx_sequencer_processing_time_ms (5): 1,488 (-26%)
  • batch_insert_into_append_only_tree_32_depth_ms (512): 230 (-17%)
  • batch_insert_into_append_only_tree_32_depth_ms (2048): 868 (-35%)
  • batch_insert_into_append_only_tree_32_depth_hash_ms (2048): 0.413 (-35%)
  • batch_insert_into_indexed_tree_20_depth_ms (2048): 1,306 (-29%)
  • note_history_trial_decrypting_time_in_ms (10): 277 (+110%)
  • l2_block_processing_time_in_ms (32): 4,854 (-16%)
  • note_successful_decrypting_time_in_ms (32): 776 (+50%)
  • note_trial_decrypting_time_in_ms (32): 91.0 (+173%)
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.

Values are compared against data from master at commit 02524e13 and shown if the difference exceeds 1%.

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 676 676 676
l1_rollup_calldata_gas 6,412 6,400 6,424
l1_rollup_execution_gas 585,745 585,733 585,757
l2_block_processing_time_in_ms 1,300 (-6%) ⚠️ 4,854 (-16%) 8,994 (+1%)
note_successful_decrypting_time_in_ms 235 (-12%) ⚠️ 776 (+50%) 990 (-2%)
note_trial_decrypting_time_in_ms 39.3 (-45%) ⚠️ 91.0 (+173%) 119 (-8%)
l2_block_building_time_in_ms 11,349 (-3%) 41,945 (-2%) 82,556 (-4%)
l2_block_rollup_simulation_time_in_ms 7,379 (+3%) 26,073 (+5%) 50,789 (+2%)
l2_block_public_tx_process_time_in_ms 3,952 (-13%) 15,820 (-11%) 31,672 (-11%)

L2 chain processing

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

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 13,844 (-1%) 27,273 (+5%)
note_history_successful_decrypting_time_in_ms 1,192 (-2%) 2,412
note_history_trial_decrypting_time_in_ms 57.5 (-5%) ⚠️ 277 (+110%)
node_database_size_in_bytes 18,640,976 34,984,016
pxe_database_size_in_bytes 29,859 59,414

Circuits stats

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

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 180 (+1%) 44,379 28,214
private-kernel-ordering 166 (+1%) 52,880 14,296
base-parity 3,523 (-1%) 128 311
root-parity 1,199 (-2%) 1,244 311
base-rollup 14,937 (+3%) 165,760 861
root-rollup 49.5 (+2%) 4,359 725
private-kernel-inner 222 73,795 28,214
public-kernel-app-logic 97.1 (+4%) 35,252 28,217
public-kernel-tail 140 (+4%) 40,928 28,217
merge-rollup 8.39 (+5%) 2,568 861
public-kernel-teardown 91.5 (-3%) 35,252 28,217
public-kernel-setup 90.4 (-1%) 35,252 28,217

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.2 (+2%) 15.9 (-1%) 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.8 31.6 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.594 (+2%) 0.492 (-1%) 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 46.7 (+1%) 71.9 (-7%) ⚠️ 230 (-17%) 450 (+4%) ⚠️ 868 (-35%) 1,718 (+1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 96.0 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.478 (+1%) 0.443 (-7%) 0.420 (-16%) 0.421 (+5%) ⚠️ 0.413 (-35%) 0.412 (+2%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 53.9 (+2%) 106 (-5%) 334 (-11%) 662 (+4%) ⚠️ 1,306 (-29%) 2,598 (+3%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.476 (+2%) 0.479 (-5%) 0.456 (-10%) 0.456 (+4%) 0.454 (-29%) 0.452 (+3%) 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 61.6 (+2%)
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 109
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.539 (+2%)

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 14,968 495,320

Transaction size based on fee payment method

Metric none fee payment method native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 773 905 1,161 1,377

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 1,777 (+1%) 1,101 (-6%) 5,526 (-2%)
Metric 0 public data writes 1 public data writes 2 public data writes 3 public data writes 4 public data writes 5 public data writes 8 public data writes
tx_sequencer_processing_time_ms 11.1 (+3%) 490 (-13%) 381 (-15%) ⚠️ 911 (-22%) 564 (-3%) ⚠️ 1,488 (-26%) 552 (-1%)

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