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: batch simulate #6599

Merged
merged 7 commits into from
May 23, 2024
Merged

feat: batch simulate #6599

merged 7 commits into from
May 23, 2024

Conversation

Thunkar
Copy link
Contributor

@Thunkar Thunkar commented May 22, 2024

Closes: #6549

Also removes FunctionData from TxExecutionRequest and a bunch of other places, in favor of just the FunctionSelector(which is actually what's needed). This was missed from #3417 and was driving me crazy when trying to add a few more things to FunctionCall. It had also leaked somehow into the AVM enqueued calls.

@Thunkar Thunkar self-assigned this May 22, 2024
@Thunkar Thunkar requested review from LHerskind and sirasistant May 22, 2024 14:58
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

I like it 👍 Lets get CI happy and 🚢 it

const a = await contract.methods.get_shared_immutable_constrained_private().simulate();
const b = await contract.methods.get_shared_immutable_constrained_private_indirect().simulate();
const c = await contract.methods.get_shared_immutable().simulate();
const [a, b, c] = await new BatchCall(wallet, [
Copy link
Contributor

Choose a reason for hiding this comment

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

Noice Thats Nice GIF

@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • protocol_circuit_witness_generation_time_in_ms (base-parity): 1,996 (+37%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-setup): 244 (+57%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-app-logic): 146 (-48%)
  • protocol_circuit_proving_time_in_ms (base-parity): 3,046 (-20%)
  • protocol_circuit_proving_time_in_ms (public-kernel-teardown): 983 (+34%)
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 5,698 (-1%) 1,548 (-2%) 707 (-2%) 773 (+1%) 776

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 772 772 772
l1_rollup_calldata_gas 6,856 6,880 6,856
l1_rollup_execution_gas 587,396 587,420 587,396
l2_block_processing_time_in_ms 1,371 (+1%) 5,046 10,061
l2_block_building_time_in_ms 32,628 128,111 255,583
l2_block_rollup_simulation_time_in_ms 32,461 127,476 254,329
l2_block_public_tx_process_time_in_ms 17,036 (+1%) 70,643 (+1%) 142,737

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 15,210 (-1%) 28,451
node_database_size_in_bytes 21,258,320 38,158,416 (+1%)
pxe_database_size_in_bytes 29,868 12,535

Circuits stats

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

Circuit protocol_circuit_simulation_time_in_ms protocol_circuit_witness_generation_time_in_ms protocol_circuit_proving_time_in_ms protocol_circuit_input_size_in_bytes protocol_circuit_output_size_in_bytes protocol_circuit_proof_size_in_bytes protocol_circuit_num_public_inputs protocol_circuit_size_in_gates
private-kernel-init 157 (-2%) 3,391 (-12%) 24,521 19,985 61,999 86,720 2,643 1,048,576
private-kernel-inner 604 4,447 (-3%) 44,778 (-1%) 89,053 61,999 86,720 2,643 2,097,152
private-kernel-tail 532 2,792 (+3%) 43,839 (+1%) 86,849 78,838 10,624 265 2,097,152
base-parity 6.45 ⚠️ 1,996 (+37%) ⚠️ 3,046 (-20%) 128 64.0 2,208 2.00 131,072
root-parity 48.9 74.4 (+3%) 43,439 (-3%) 27,064 64.0 2,720 18.0 2,097,152
base-rollup 721 (-4%) 2,506 (+1%) 48,555 (-2%) 112,602 957 3,136 31.0 2,097,152
root-rollup 91.9 70.2 (+5%) 8,849 (+1%) 11,518 821 3,456 41.0 524,288
public-kernel-app-logic 242 ⚠️ 146 (-48%) 647 (-11%) 96,850 84,967 116,320 3,568 4,096
public-kernel-tail 862 625 (-2%) 1,034 (+15%) 388,084 7,691 10,112 249 256
private-kernel-reset-small 581 2,267 (-2%) 24,768 118,369 61,999 86,720 2,643 1,048,576
public-kernel-setup 214 (-3%) ⚠️ 244 (+57%) 777 (-1%) 143,141 84,967 116,320 3,568 4,096
public-kernel-teardown 219 (-2%) 219 (-14%) ⚠️ 983 (+34%) 143,141 84,967 116,320 3,568 4,096
merge-rollup 6.52 (+1%) 35.6 1,440 (-1%) 2,760 957 3,136 31.0 65,536
private-kernel-tail-to-public N/A 9,995 (-2%) 81,130 (-1%) N/A N/A 116,832 3,584 4,194,304

Stats on running time collected for app circuits

Function app_circuit_proof_size_in_bytes app_circuit_proving_time_in_ms app_circuit_size_in_gates app_circuit_num_public_inputs
SchnorrAccount:entrypoint 16,128 51,090 (+1%) 2,097,152 437
Test:emit_nullifier 16,128 2,393 (-1%) 65,536 437
FPC:fee_entrypoint_public 16,128 8,944 (-2%) 524,288 437
FPC:fee_entrypoint_private 16,128 9,591 (-1%) 524,288 437
Token:unshield 16,128 54,260 (+3%) 2,097,152 437
SchnorrAccount:spend_private_authwit 16,128 2,613 131,072 437
Token:transfer 16,128 38,935 (-2%) 2,097,152 437

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 11.0 17.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.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.640 0.550 (-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 51.7 (-1%) 82.3 (+2%) 268 (+3%) 506 (-1%) 984 1,950 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.528 0.508 (+2%) 0.486 (+2%) 0.473 (-1%) 0.467 0.466 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 61.3 (-1%) 119 380 (+1%) 743 1,462 2,917 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.535 (-1%) 0.535 0.516 (+1%) 0.511 0.507 0.507 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 67.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 108
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.589

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 84,611 664,965

Transaction size based on fee payment method

| Metric | |
| - | |

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 28,736 4,246 132,049 (-1%)
Metric 0 public data writes 1 public data writes 2 public data writes 3 public data writes 4 public data writes 8 public data writes
tx_sequencer_processing_time_ms 1,315 2,220 1,466 (-2%) 3,894 (-1%) 1,643 (-1%) 1,927

Copy link
Collaborator

@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.

FunctionData => selector changes LGTM!

@Thunkar Thunkar merged commit 8d54ac1 into master May 23, 2024
74 checks passed
@Thunkar Thunkar deleted the gj/batch_simulate branch May 23, 2024 08:05
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.

feat: Batch simulate
4 participants