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: New script to output table of benchmarks for README pasting. #2780

Merged
merged 27 commits into from
Oct 28, 2023

Conversation

charlielye
Copy link
Contributor

@charlielye charlielye commented Oct 10, 2023

Benchmarks are cool man. They let you see how fast the thing goes.

This adds a tiny benchmark lib to barretenberg. Use it e.g.

    Timer proof_timer;
    auto proof = acir_composer.create_proof(constraint_system, witness, recursive);
    write_benchmark("proof_construction_time", proof_timer.milliseconds(), "acir_test", current_dir);

The write_benchmark function takes a name, value, and then an arbitrary number of label/value pairs.
The output data is very raw. The library will auto set the type to number/string/bool.
The output data is JSONL in the form e.g.

{"timestamp": "2023-10-10T22:17:10Z", "name": "pk_construction_time", "type": "number", "value": 234, "threads": 128, "acir_test": "1_mul"}
{"timestamp": "2023-10-10T22:17:10Z", "name": "proof_construction_time", "type": "number", "value": 173, "threads": 128, "acir_test": "1_mul"}
{"timestamp": "2023-10-10T22:17:10Z", "name": "vk_construction_time", "type": "number", "value": 74, "threads": 128, "acir_test": "1_mul"}

The labels are for ingesters to group/slice the data as they wish.

To enable benchmarking, set the env var e.g BENCHMARK_FD=3, then redirect the given file descriptor number to wherever you want the benchmarks, e.g.

BENCHMARK_FD=3 ./run_acir_tests.sh 1_mul 3>&1 > /dev/null

Sends them to FD1 (stdout) and sends stdout to /dev/null. Thus this just prints out the benchmarks like above. Or:

BENCHMARK_FD=3 ./run_acir_tests.sh 1_mul 3>>benchmarks.jsonl

Appends them to file benchmarks.jsonl

Longer term vision for benchmarks is that our TS code (or any other code), outputs benchmarks in the same style. The build-system will expect benchmarks, if enabled, to be have been written to a specific file in the container (or mounted volume), and will then upload the benchmarks to S3 for later, async processing (using e.g. glue -> athena -> quicksight/grafana).
Both the container itself could manipulate the JSONL to inject properties specific to the test run, and the build-system could inject properties prior to upload such as job-name or commit-hash (although structured file-naming might solve this better).

@ludamad
Copy link
Collaborator

ludamad commented Oct 11, 2023

How does it compare to our existing benchmarks?

Base automatically changed from cl/acir_format_cleanup to master October 11, 2023 14:53
Copy link
Contributor

@codygunton codygunton left a comment

Choose a reason for hiding this comment

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

I tried this out in some of the honk tests and it worked like a charm. One minor annoyance was I had to include three headers: timer.hpp, benchmark.hpp and <filesystem>. Something to consider is that including <filesystem> is quite expensive according to https://github.com/s9w/cpp-lit.

@AztecBot
Copy link
Collaborator

AztecBot commented Oct 11, 2023

Benchmark results

Metrics with a significant change:

  • node_history_sync_time_in_ms (5): 14,278 (+17%)
  • node_history_sync_time_in_ms (10): 27,394 (+25%)
  • note_history_successful_decrypting_time_in_ms (5): 3,093 (+20%)
  • note_history_successful_decrypting_time_in_ms (10): 6,111 (+27%)
  • note_history_trial_decrypting_time_in_ms (10): 252 (+66%)
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 db3fa62e 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 128 txs
l1_rollup_calldata_size_in_bytes 45,444 179,588 716,132
l1_rollup_calldata_gas 222,900 867,848 3,449,420
l1_rollup_execution_gas 841,987 3,594,956 22,204,789
l2_block_processing_time_in_ms 1,004 (-2%) 3,840 (-2%) 15,160 (-1%)
note_successful_decrypting_time_in_ms 329 (-2%) 1,018 (-2%) 3,705 (-6%)
note_trial_decrypting_time_in_ms 33.0 (-15%) 109 (+1%) 137
l2_block_building_time_in_ms 8,852 35,450 (-1%) 156,045 (-1%)
l2_block_rollup_simulation_time_in_ms 6,527 26,149 104,136 (-1%)
l2_block_public_tx_process_time_in_ms 2,283 (-1%) 9,179 (-1%) 51,270 (-1%)

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,278 (+17%) ⚠️ 27,394 (+25%)
note_history_successful_decrypting_time_in_ms ⚠️ 3,093 (+20%) ⚠️ 6,111 (+27%)
note_history_trial_decrypting_time_in_ms 127 (+3%) ⚠️ 252 (+66%)
node_database_size_in_bytes 1,661,949 1,199,660
pxe_database_size_in_bytes 27,188 54,187

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 52.1 (+9%) 61,697 18,841
private-kernel-ordering 25.9 (+8%) 24,233 8,089
base-rollup 939 (+10%) 639,797 811
root-rollup 42.3 (+11%) 4,072 1,097
private-kernel-inner 47.4 (+8%) 81,504 18,841
public-kernel-private-input 53.0 (+11%) 41,455 18,841
public-kernel-non-first-iteration 34.2 (+7%) 41,497 18,841
merge-rollup 1.00 (+23%) 2,592 873

Miscellaneous

Transaction sizes based on how many contracts are deployed in the tx.

Metric 0 deployed contracts 1 deployed contracts
tx_size_in_bytes 8,723 27,508

@codygunton
Copy link
Contributor

This new benchmarking system taking 30 mins at the end of the pipeline is kind of painful though 😬

@charlielye
Copy link
Contributor Author

This new benchmarking system taking 30 mins at the end of the pipeline is kind of painful though 😬

The 30m benchmark run was actually nothing to do with this PR, but I raised with Palla last week and I believe he's reduced it to 10m, so no longer than our worst case e2e test.

@charlielye
Copy link
Contributor Author

I tried this out in some of the honk tests and it worked like a charm. One minor annoyance was I had to include three headers: timer.hpp, benchmark.hpp and <filesystem>. Something to consider is that including <filesystem> is quite expensive according to https://github.com/s9w/cpp-lit.

Unless I'm missing something, you only need to include timer.hpp if you're writing a benchmark that needed the timer (I guess we could include timer in the benchmark header as it's likely you'll have a time based benchmark, but it's not a given, and normal practice would not be for benchmark.hpp to import timer.hpp given that it doesn't use it).

And you only need filesystem if your doing filesystem stuff, which my example above does (it uses it to determine the name of the acir test), but there maybe ways of achieving the same without using filesystem.

@charlielye charlielye merged commit 6c20b45 into master Oct 28, 2023
80 checks passed
@charlielye charlielye deleted the cl/bb_bench2 branch October 28, 2023 10:21
rahul-kothari pushed a commit that referenced this pull request Oct 31, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.13.0</summary>

##
[0.13.0](aztec-packages-v0.12.0...aztec-packages-v0.13.0)
(2023-10-31)


### ⚠ BREAKING CHANGES

* PXE.getNotes(...) + refactor of note types
([#3051](#3051))

### Features

* `FieldNote`
([#3037](#3037))
([3d1ffd0](3d1ffd0))
* Add Aztec Boxes page to docs
([#2569](#2569))
([997c15c](997c15c))
* Adding structure to Transcript
([#2937](#2937))
([db67aa1](db67aa1))
* Compile noir contracts with noir_wasm
([#2737](#2737))
([524cecf](524cecf))
* Dockerize aztec-cli
([#3031](#3031))
([ec2e3c2](ec2e3c2))
* Efficient ZM quotient computation
([#3016](#3016))
([ebda5fc](ebda5fc))
* **feature_branch:** Private Kernel Circuit
([#2740](#2740))
([f800a36](f800a36))
* Measure plonk rounds
([#3065](#3065))
([c8e1d8b](c8e1d8b))
* Migrate the init kernel CPP tests to noir
([#3091](#3091))
([906429f](906429f))
* New script to output table of benchmarks for README pasting.
([#2780](#2780))
([6c20b45](6c20b45))
* Pedersen in typescript.
([#3111](#3111))
([933f1b2](933f1b2))
* Protogalaxy folding of challenges
([#2935](#2935))
([7ed30e8](7ed30e8))
* PXE.getNotes(...) + refactor of note types
([#3051](#3051))
([16abb5a](16abb5a))
* Zeromorph with concatenation (Goblin Translator part 10)
([#3006](#3006))
([70b0f17](70b0f17))


### Bug Fixes

* Bad contract txs publishing contract data
([#2673](#2673))
([ccd4611](ccd4611))
* Better error message for compute_note_hash_and_nullifier.
([#3097](#3097))
([57bec53](57bec53))
* Broken `FieldNote` test
([#3135](#3135))
([fe78ecf](fe78ecf))
* Docker-compose up, rather than run.
([#3081](#3081))
([242f780](242f780))
* Formatting
([#3070](#3070))
([e1633d3](e1633d3))
* Minor stale naming fix
([#3117](#3117))
([a6786ae](a6786ae))
* Push cli docker image to docker hub
([#3120](#3120))
([ccad50f](ccad50f))
* Remove duplicate terraform resource definition
([#3066](#3066))
([d5abadb](d5abadb))
* Retry request spot
([#3116](#3116))
([82de5f1](82de5f1))


### Miscellaneous

* Add stdlib tests for pedersen commitment
([#3075](#3075))
([87fa621](87fa621))
* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](#3072))
([2e289a5](2e289a5))
* Cleanup remaining mentions of `compress` with pedersen in cpp and ts
([#3074](#3074))
([52cf383](52cf383))
* E2e on spots [ci rebuild]
([#3068](#3068))
([15db6bf](15db6bf))
* Fix dapp_testing e2e race condition
([#3094](#3094))
([89e7c21](89e7c21))
* Remove docs mirror
([#3122](#3122))
([3fa51e2](3fa51e2))
* Remove endomorphism coefficient from ecc_add_gate
([#3115](#3115))
([d294987](d294987))
* Remove unecessary calls to `pedersen__init`
([#3079](#3079))
([84f8db2](84f8db2))
* Remove unused pedersen c_binds
([#3058](#3058))
([e71e5f9](e71e5f9))
* Removes pedersen commit native pairs method
([#3073](#3073))
([69a34c7](69a34c7))
* Rename private-kernel subpackage to protocol-circuits
([#3134](#3134))
([3e07104](3e07104))


### Documentation

* Initial keys spec
([#3035](#3035))
([4b24c58](4b24c58))
</details>

<details><summary>barretenberg.js: 0.13.0</summary>

##
[0.13.0](barretenberg.js-v0.12.0...barretenberg.js-v0.13.0)
(2023-10-31)


### Features

* New script to output table of benchmarks for README pasting.
([#2780](#2780))
([6c20b45](6c20b45))


### Miscellaneous

* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](#3072))
([2e289a5](2e289a5))
* Remove unecessary calls to `pedersen__init`
([#3079](#3079))
([84f8db2](84f8db2))
* Remove unused pedersen c_binds
([#3058](#3058))
([e71e5f9](e71e5f9))
</details>

<details><summary>barretenberg: 0.13.0</summary>

##
[0.13.0](barretenberg-v0.12.0...barretenberg-v0.13.0)
(2023-10-31)


### Features

* Adding structure to Transcript
([#2937](#2937))
([db67aa1](db67aa1))
* Efficient ZM quotient computation
([#3016](#3016))
([ebda5fc](ebda5fc))
* Measure plonk rounds
([#3065](#3065))
([c8e1d8b](c8e1d8b))
* New script to output table of benchmarks for README pasting.
([#2780](#2780))
([6c20b45](6c20b45))
* Pedersen in typescript.
([#3111](#3111))
([933f1b2](933f1b2))
* Protogalaxy folding of challenges
([#2935](#2935))
([7ed30e8](7ed30e8))
* Zeromorph with concatenation (Goblin Translator part 10)
([#3006](#3006))
([70b0f17](70b0f17))


### Miscellaneous

* Add stdlib tests for pedersen commitment
([#3075](#3075))
([87fa621](87fa621))
* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](#3072))
([2e289a5](2e289a5))
* Cleanup remaining mentions of `compress` with pedersen in cpp and ts
([#3074](#3074))
([52cf383](52cf383))
* Remove endomorphism coefficient from ecc_add_gate
([#3115](#3115))
([d294987](d294987))
* Remove unecessary calls to `pedersen__init`
([#3079](#3079))
([84f8db2](84f8db2))
* Remove unused pedersen c_binds
([#3058](#3058))
([e71e5f9](e71e5f9))
* Removes pedersen commit native pairs method
([#3073](#3073))
([69a34c7](69a34c7))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Nov 7, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.13.0</summary>

##
[0.13.0](AztecProtocol/aztec-packages@aztec-packages-v0.12.0...aztec-packages-v0.13.0)
(2023-10-31)


### ⚠ BREAKING CHANGES

* PXE.getNotes(...) + refactor of note types
([#3051](AztecProtocol/aztec-packages#3051))

### Features

* `FieldNote`
([#3037](AztecProtocol/aztec-packages#3037))
([3d1ffd0](AztecProtocol/aztec-packages@3d1ffd0))
* Add Aztec Boxes page to docs
([#2569](AztecProtocol/aztec-packages#2569))
([997c15c](AztecProtocol/aztec-packages@997c15c))
* Adding structure to Transcript
([#2937](AztecProtocol/aztec-packages#2937))
([db67aa1](AztecProtocol/aztec-packages@db67aa1))
* Compile noir contracts with noir_wasm
([#2737](AztecProtocol/aztec-packages#2737))
([524cecf](AztecProtocol/aztec-packages@524cecf))
* Dockerize aztec-cli
([#3031](AztecProtocol/aztec-packages#3031))
([ec2e3c2](AztecProtocol/aztec-packages@ec2e3c2))
* Efficient ZM quotient computation
([#3016](AztecProtocol/aztec-packages#3016))
([ebda5fc](AztecProtocol/aztec-packages@ebda5fc))
* **feature_branch:** Private Kernel Circuit
([#2740](AztecProtocol/aztec-packages#2740))
([f800a36](AztecProtocol/aztec-packages@f800a36))
* Measure plonk rounds
([#3065](AztecProtocol/aztec-packages#3065))
([c8e1d8b](AztecProtocol/aztec-packages@c8e1d8b))
* Migrate the init kernel CPP tests to noir
([#3091](AztecProtocol/aztec-packages#3091))
([906429f](AztecProtocol/aztec-packages@906429f))
* New script to output table of benchmarks for README pasting.
([#2780](AztecProtocol/aztec-packages#2780))
([6c20b45](AztecProtocol/aztec-packages@6c20b45))
* Pedersen in typescript.
([#3111](AztecProtocol/aztec-packages#3111))
([933f1b2](AztecProtocol/aztec-packages@933f1b2))
* Protogalaxy folding of challenges
([#2935](AztecProtocol/aztec-packages#2935))
([7ed30e8](AztecProtocol/aztec-packages@7ed30e8))
* PXE.getNotes(...) + refactor of note types
([#3051](AztecProtocol/aztec-packages#3051))
([16abb5a](AztecProtocol/aztec-packages@16abb5a))
* Zeromorph with concatenation (Goblin Translator part 10)
([#3006](AztecProtocol/aztec-packages#3006))
([70b0f17](AztecProtocol/aztec-packages@70b0f17))


### Bug Fixes

* Bad contract txs publishing contract data
([#2673](AztecProtocol/aztec-packages#2673))
([ccd4611](AztecProtocol/aztec-packages@ccd4611))
* Better error message for compute_note_hash_and_nullifier.
([#3097](AztecProtocol/aztec-packages#3097))
([57bec53](AztecProtocol/aztec-packages@57bec53))
* Broken `FieldNote` test
([#3135](AztecProtocol/aztec-packages#3135))
([fe78ecf](AztecProtocol/aztec-packages@fe78ecf))
* Docker-compose up, rather than run.
([#3081](AztecProtocol/aztec-packages#3081))
([242f780](AztecProtocol/aztec-packages@242f780))
* Formatting
([#3070](AztecProtocol/aztec-packages#3070))
([e1633d3](AztecProtocol/aztec-packages@e1633d3))
* Minor stale naming fix
([#3117](AztecProtocol/aztec-packages#3117))
([a6786ae](AztecProtocol/aztec-packages@a6786ae))
* Push cli docker image to docker hub
([#3120](AztecProtocol/aztec-packages#3120))
([ccad50f](AztecProtocol/aztec-packages@ccad50f))
* Remove duplicate terraform resource definition
([#3066](AztecProtocol/aztec-packages#3066))
([d5abadb](AztecProtocol/aztec-packages@d5abadb))
* Retry request spot
([#3116](AztecProtocol/aztec-packages#3116))
([82de5f1](AztecProtocol/aztec-packages@82de5f1))


### Miscellaneous

* Add stdlib tests for pedersen commitment
([#3075](AztecProtocol/aztec-packages#3075))
([87fa621](AztecProtocol/aztec-packages@87fa621))
* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](AztecProtocol/aztec-packages#3072))
([2e289a5](AztecProtocol/aztec-packages@2e289a5))
* Cleanup remaining mentions of `compress` with pedersen in cpp and ts
([#3074](AztecProtocol/aztec-packages#3074))
([52cf383](AztecProtocol/aztec-packages@52cf383))
* E2e on spots [ci rebuild]
([#3068](AztecProtocol/aztec-packages#3068))
([15db6bf](AztecProtocol/aztec-packages@15db6bf))
* Fix dapp_testing e2e race condition
([#3094](AztecProtocol/aztec-packages#3094))
([89e7c21](AztecProtocol/aztec-packages@89e7c21))
* Remove docs mirror
([#3122](AztecProtocol/aztec-packages#3122))
([3fa51e2](AztecProtocol/aztec-packages@3fa51e2))
* Remove endomorphism coefficient from ecc_add_gate
([#3115](AztecProtocol/aztec-packages#3115))
([d294987](AztecProtocol/aztec-packages@d294987))
* Remove unecessary calls to `pedersen__init`
([#3079](AztecProtocol/aztec-packages#3079))
([84f8db2](AztecProtocol/aztec-packages@84f8db2))
* Remove unused pedersen c_binds
([#3058](AztecProtocol/aztec-packages#3058))
([e71e5f9](AztecProtocol/aztec-packages@e71e5f9))
* Removes pedersen commit native pairs method
([#3073](AztecProtocol/aztec-packages#3073))
([69a34c7](AztecProtocol/aztec-packages@69a34c7))
* Rename private-kernel subpackage to protocol-circuits
([#3134](AztecProtocol/aztec-packages#3134))
([3e07104](AztecProtocol/aztec-packages@3e07104))


### Documentation

* Initial keys spec
([#3035](AztecProtocol/aztec-packages#3035))
([4b24c58](AztecProtocol/aztec-packages@4b24c58))
</details>

<details><summary>barretenberg.js: 0.13.0</summary>

##
[0.13.0](AztecProtocol/aztec-packages@barretenberg.js-v0.12.0...barretenberg.js-v0.13.0)
(2023-10-31)


### Features

* New script to output table of benchmarks for README pasting.
([#2780](AztecProtocol/aztec-packages#2780))
([6c20b45](AztecProtocol/aztec-packages@6c20b45))


### Miscellaneous

* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](AztecProtocol/aztec-packages#3072))
([2e289a5](AztecProtocol/aztec-packages@2e289a5))
* Remove unecessary calls to `pedersen__init`
([#3079](AztecProtocol/aztec-packages#3079))
([84f8db2](AztecProtocol/aztec-packages@84f8db2))
* Remove unused pedersen c_binds
([#3058](AztecProtocol/aztec-packages#3058))
([e71e5f9](AztecProtocol/aztec-packages@e71e5f9))
</details>

<details><summary>barretenberg: 0.13.0</summary>

##
[0.13.0](AztecProtocol/aztec-packages@barretenberg-v0.12.0...barretenberg-v0.13.0)
(2023-10-31)


### Features

* Adding structure to Transcript
([#2937](AztecProtocol/aztec-packages#2937))
([db67aa1](AztecProtocol/aztec-packages@db67aa1))
* Efficient ZM quotient computation
([#3016](AztecProtocol/aztec-packages#3016))
([ebda5fc](AztecProtocol/aztec-packages@ebda5fc))
* Measure plonk rounds
([#3065](AztecProtocol/aztec-packages#3065))
([c8e1d8b](AztecProtocol/aztec-packages@c8e1d8b))
* New script to output table of benchmarks for README pasting.
([#2780](AztecProtocol/aztec-packages#2780))
([6c20b45](AztecProtocol/aztec-packages@6c20b45))
* Pedersen in typescript.
([#3111](AztecProtocol/aztec-packages#3111))
([933f1b2](AztecProtocol/aztec-packages@933f1b2))
* Protogalaxy folding of challenges
([#2935](AztecProtocol/aztec-packages#2935))
([7ed30e8](AztecProtocol/aztec-packages@7ed30e8))
* Zeromorph with concatenation (Goblin Translator part 10)
([#3006](AztecProtocol/aztec-packages#3006))
([70b0f17](AztecProtocol/aztec-packages@70b0f17))


### Miscellaneous

* Add stdlib tests for pedersen commitment
([#3075](AztecProtocol/aztec-packages#3075))
([87fa621](AztecProtocol/aztec-packages@87fa621))
* Automatic c_binds for commit should return a point instead of an Fr
element
([#3072](AztecProtocol/aztec-packages#3072))
([2e289a5](AztecProtocol/aztec-packages@2e289a5))
* Cleanup remaining mentions of `compress` with pedersen in cpp and ts
([#3074](AztecProtocol/aztec-packages#3074))
([52cf383](AztecProtocol/aztec-packages@52cf383))
* Remove endomorphism coefficient from ecc_add_gate
([#3115](AztecProtocol/aztec-packages#3115))
([d294987](AztecProtocol/aztec-packages@d294987))
* Remove unecessary calls to `pedersen__init`
([#3079](AztecProtocol/aztec-packages#3079))
([84f8db2](AztecProtocol/aztec-packages@84f8db2))
* Remove unused pedersen c_binds
([#3058](AztecProtocol/aztec-packages#3058))
([e71e5f9](AztecProtocol/aztec-packages@e71e5f9))
* Removes pedersen commit native pairs method
([#3073](AztecProtocol/aztec-packages#3073))
([69a34c7](AztecProtocol/aztec-packages@69a34c7))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants