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

chore: evaluate expressions in constant gen #6813

Merged
merged 1 commit into from
Jun 1, 2024
Merged

Conversation

fcarreiro
Copy link
Contributor

@fcarreiro fcarreiro commented May 31, 2024

Closes #6808.

Copy link
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 requested review from benesjan and ludamad May 31, 2024 21:43
@fcarreiro fcarreiro force-pushed the fc/evaluate-constants branch 2 times, most recently from 1bbad22 to a91fc50 Compare May 31, 2024 21:52
if (CPP_CONSTANTS.includes(key) && !(value.startsWith('0x') || value.includes('0_0'))) {
code.push(`const size_t ${key} = ${value};`);
if (CPP_CONSTANTS.includes(key)) {
code.push(`#define ${key} ${value}`);
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'm using defines so that we don't need to worry about the size here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But a big number will still need ll suffix no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC it's not needed, but in any case really big constants will fail on use because c++ cannot hold anything > 64 bits natively. See "The type of a literal".

The type of the integer literal is the first type in which the value can fit, from the list of types which depends on which numeric base and which integer-suffix was used.

@fcarreiro fcarreiro force-pushed the fc/evaluate-constants branch from a91fc50 to 9276954 Compare May 31, 2024 22:47
Copy link
Collaborator

@AztecBot AztecBot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 9276954 Previous: fab3145 Ratio
nativeconstruct_proof_ultrahonk_power_of_2/20 5891.689166999996 ms/iter 5509.585072999997 ms/iter 1.07

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

@fcarreiro fcarreiro changed the title chore: evaluate constants in constant gen chore: evaluate expressions in constant gen May 31, 2024
@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • protocol_circuit_witness_generation_time_in_ms (private-kernel-inner): 1,119 (+18%)
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,701 (-1%) 1,543 (-1%) 700 748 (-2%) 782
proof_construction_time_sha256_30_ms 11,705 (-2%) 3,132 (-1%) 1,402 (-2%) 1,429 (-1%) 1,459
proof_construction_time_sha256_100_ms 44,638 (-1%) 12,044 (-1%) 5,658 (-5%) 5,599 (-3%) 5,504 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 58.0 88.0 (+2%)
proof_construction_time_poseidon_hash_30_ms 1,516 422 (+1%) 202 238 (+6%) 267 (+1%)
proof_construction_time_poseidon_hash_100_ms 5,702 (-1%) 1,556 (-1%) 723 (-2%) 785 (+1%) 790

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,452 9,452 9,476
l1_rollup_execution_gas 607,988 (-1%) 607,988 (-1%) 608,012 (-1%)
l2_block_processing_time_in_ms 1,313 (+2%) 4,850 (+2%) 9,617 (+1%)
l2_block_building_time_in_ms 43,906 174,265 347,719
l2_block_rollup_simulation_time_in_ms 43,709 173,529 346,272
l2_block_public_tx_process_time_in_ms 40,481 170,224 342,953

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,343 (-4%) 14,316 (-3%)
node_database_size_in_bytes 14,475,344 21,356,624
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 135 (-1%) 469 (-1%) 12,744 (-2%) 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 408 ⚠️ 1,119 (+18%) 49,563 (-4%) 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 582 (-1%) 2,650 (-1%) 50,300 (-14%) 96,545 77,732 11,648 297 2,097,152
base-parity 6.46 1,718 (-8%) 2,738 128 64.0 2,208 2.00 131,072
root-parity 49.1 62.7 (+2%) 40,399 (-1%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 11,940 (-1%) 2,378 (-4%) 79,648 (-2%) 119,738 756 3,648 47.0 4,194,304
root-rollup 109 (-1%) 76.5 22,989 (-2%) 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 569 (-1%) 3,532 (-1%) 45,580 (-1%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,117 (-1%) 24,427 (+4%) 183,360 (-2%) 403,238 7,646 11,648 297 8,388,608
private-kernel-reset-small 588 (-1%) 2,000 (+2%) 46,734 (-3%) 120,737 64,614 89,536 2,731 2,097,152
public-kernel-setup 665 (+1%) 2,745 (-2%) 44,111 (-2%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-teardown 569 (+1%) 3,567 (-1%) 46,175 (+1%) 108,073 86,550 116,768 3,582 2,097,152
merge-rollup 28.7 (-1%) N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 8,679 (-3%) 99,140 (-10%) 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 459 (-2%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 40.9 (-2%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,756 (-1%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,427 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,816 (+2%) 16,768 53,865 (-3%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,569 (-3%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 1,041 16,768 10,837 524,288 457
Token:transfer 1,376 9,944 5,290 16,768 51,687 (-4%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,395 (-1%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.4 N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,906 N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,780 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.4 (-1%) 17.4 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.602 (-1%) 0.522 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 48.5 (-1%) 76.5 (-1%) 247 472 (-3%) 934 (+1%) 1,856 (+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.495 (-1%) 0.471 (-1%) 0.448 0.441 (-3%) 0.442 (+1%) 0.442 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.1 (-1%) 112 (-1%) 357 (+1%) 695 (-3%) 1,394 (+1%) 2,779 (+1%) 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.502 (-1%) 0.503 (-1%) 0.483 (+1%) 0.477 (-3%) 0.481 (+1%) 0.482 (+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 62.5 (-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.553 (-1%)

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,053 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

Copy link
Collaborator

@ludamad ludamad left a comment

Choose a reason for hiding this comment

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

Minor readability regressions but lgtm

@fcarreiro fcarreiro merged commit c2a50f4 into master Jun 1, 2024
89 checks passed
@fcarreiro fcarreiro deleted the fc/evaluate-constants branch June 1, 2024 00:39
Copy link
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.

Improve Rollup Constant Management
3 participants