Skip to content

feat(avm): brillig CONST of size > u128#5217

Merged
fcarreiro merged 1 commit into
masterfrom
fc/brillig-const-big-field
Mar 15, 2024
Merged

feat(avm): brillig CONST of size > u128#5217
fcarreiro merged 1 commit into
masterfrom
fc/brillig-const-big-field

Conversation

@fcarreiro

@fcarreiro fcarreiro commented Mar 14, 2024

Copy link
Copy Markdown
Contributor

The AVM cannot support setting constants of field size (because the whole instruction has to fit in a field). To align Brillig with AVM bytecode, I'm changing bytecode emission for the case where the constant is > 128 bits.

The current change splits the field into two 128bit limbs, and then multiplies and adds.

fcarreiro commented Mar 14, 2024

Copy link
Copy Markdown
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

@fcarreiro fcarreiro force-pushed the fc/brillig-const-big-field branch from 3f45ed2 to b40cf95 Compare March 14, 2024 16:04
@fcarreiro fcarreiro requested a review from sirasistant March 14, 2024 16:06
@fcarreiro fcarreiro marked this pull request as ready for review March 14, 2024 16:06
@AztecBot

Copy link
Copy Markdown
Collaborator

Benchmark results

Metrics with a significant change:

  • note_trial_decrypting_time_in_ms (64): 140 (+96%)
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 c34a299e 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 5,668 18,820 36,356
l1_rollup_calldata_gas 66,316 239,056 470,000
l1_rollup_execution_gas 666,997 953,966 1,337,357
l2_block_processing_time_in_ms 1,244 (-7%) 4,764 (-2%) 9,136 (-4%)
note_successful_decrypting_time_in_ms 217 (-4%) 471 (-15%) 1,011 (+8%)
note_trial_decrypting_time_in_ms 24.0 (-26%) 88.9 (+22%) ⚠️ 140 (+96%)
l2_block_building_time_in_ms 18,402 (-1%) 69,215 139,868 (+2%)
l2_block_rollup_simulation_time_in_ms 8,296 29,239 (+1%) 57,503 (+2%)
l2_block_public_tx_process_time_in_ms 10,083 (-2%) 39,915 (-1%) 82,266 (+3%)

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 14,358 (+4%) 27,577 (+4%)
note_history_successful_decrypting_time_in_ms 1,333 (+13%) 2,427 (-2%)
note_history_trial_decrypting_time_in_ms 142 (+75%) 126 (-27%)
node_database_size_in_bytes 19,038,288 35,676,240
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 284 44,370 27,700
private-kernel-ordering 218 52,324 14,326
base-parity 1,841 (+2%) 128 311
base-rollup 729 (+1%) 177,083 925
root-parity 1,696 (+7%) 1,244 311
root-rollup 68.6 (-1%) 4,487 789
private-kernel-inner 638 73,229 27,700
public-kernel-app-logic 451 35,262 28,215
public-kernel-tail 178 (+1%) 40,926 28,215
merge-rollup 8.30 (+1%) 2,696 925

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.1 (+1%) 16.1 (+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.587 (+1%) 0.497 (+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.1 (-1%) 77.3 (+7%) 230 443 860 (-1%) 1,758 (+3%) 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.473 (-1%) 0.477 (+7%) 0.419 0.415 0.410 (-1%) 0.422 (+3%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 53.6 (-2%) 111 (+4%) 334 (-2%) 660 1,307 (-1%) 2,597 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 104 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.478 (-3%) 0.499 (+3%) 0.455 (-1%) 0.455 0.453 (-1%) 0.452 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.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 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.536

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes
tx_size_in_bytes 22,014

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes
tx_pxe_processing_time_ms 3,259 (-2%) 1,750
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 12.1 (+6%) 1,262

@sirasistant sirasistant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

fcarreiro commented Mar 15, 2024

Copy link
Copy Markdown
Contributor Author

Merge activity

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