-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Manual ClientIVC breakdown (#4778)
Add timers to more functions used in client IVC scheme. Add scripts to get benchmarks and analyze them, giving a coarse profile of client IVC execution in x86. Small cleanup: rename ivc_bench module to client_ivc_bench for uniformity and because we will have other IVC schemes. Results on commit c2ab55e ``` Benchmarking lock created at ~/BENCHMARK_IN_PROGRESS. client_ivc_bench 100% 16MB 49.3MB/s 00:00 2024-02-27T14:44:25+00:00 Running ./client_ivc_bench Run on (16 X 3597.59 MHz CPU s) CPU Caches: L1 Data 32 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1024 KiB (x8) L3 Unified 36608 KiB (x1) Load Average: 0.00, 0.00, 0.00 -------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------- ClientIVCBench/Full/6 39503 ms 37113 ms 1 Decider::construct_proof=1 Decider::construct_proof(t)=759.097M ECCVMComposer::create_prover=1 ECCVMComposer::create_prover(t)=3.77773G ECCVMProver::construct_proof=1 ECCVMProver::construct_proof(t)=1.76856G Goblin::merge=12 Goblin::merge(t)=153.269M GoblinTranslatorCircuitBuilder::constructor=1 GoblinTranslatorCircuitBuilder::constructor(t)=61.9766M GoblinTranslatorComposer::create_prover=1 GoblinTranslatorComposer::create_prover(t)=114.006M GoblinTranslatorProver::construct_proof=1 GoblinTranslatorProver::construct_proof(t)=939.454M ProtogalaxyProver::fold_instances=11 ProtogalaxyProver::fold_instances(t)=18.0888G UltraComposer::create_prover_instance=12 UltraComposer::create_prover_instance(t)=6.31421G batch_mul_with_endomorphism=30 batch_mul_with_endomorphism(t)=563.904M commit=804 commit(t)=8.10774G compute_combiner=11 compute_combiner(t)=7.92258G compute_perturbator=10 compute_perturbator(t)=1.52886G construct_mock_folding_kernel=5 construct_mock_folding_kernel(t)=2.33398G construct_mock_function_circuit=7 construct_mock_function_circuit(t)=5.16551G Benchmarking lock deleted. client_ivc_bench.json 100% 3063 85.5KB/s 00:00 label ms % total construct_mock_function_circuit(t) 5166 13.08% construct_mock_folding_kernel(t) 2334 5.91% UltraComposer::create_prover_instance(t) 6314 15.98% ProtogalaxyProver::fold_instances(t) 18089 45.79% Decider::construct_proof(t) 759 1.92% ECCVMComposer::create_prover(t) 3778 9.56% GoblinTranslatorComposer::create_prover(t) 114 0.29% ECCVMProver::construct_proof(t) 1769 4.48% GoblinTranslatorProver::construct_proof(t) 939 2.38% Goblin::merge(t) 153 0.39% ```
- Loading branch information
1 parent
61067a5
commit b4cfc89
Showing
16 changed files
with
98 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
PREFIX = Path("build-op-count-time") | ||
IVC_BENCH_JSON = Path("client_ivc_bench.json") | ||
BENCHMARK = "ClientIVCBench/Full/6" | ||
|
||
# Single out an independent set of functions accounting for most of BENCHMARK's real_time | ||
to_keep = [ | ||
"construct_mock_function_circuit(t)", | ||
"construct_mock_folding_kernel(t)", | ||
"UltraComposer::create_prover_instance(t)", | ||
"ProtogalaxyProver::fold_instances(t)", | ||
"Decider::construct_proof(t)", | ||
"ECCVMComposer::create_prover(t)", | ||
"GoblinTranslatorComposer::create_prover(t)", | ||
"ECCVMProver::construct_proof(t)", | ||
"GoblinTranslatorProver::construct_proof(t)", | ||
"Goblin::merge(t)" | ||
] | ||
with open(PREFIX/IVC_BENCH_JSON, "r") as read_file: | ||
read_result = json.load(read_file) | ||
for _bench in read_result["benchmarks"]: | ||
if _bench["name"] == BENCHMARK: | ||
bench = _bench | ||
bench_components = dict(filter(lambda x: x[0] in to_keep, bench.items())) | ||
|
||
# For each kept time, get the proportion over all kept times. | ||
sum_of_kept_times_ms = sum(float(time) | ||
for _, time in bench_components.items())/1e6 | ||
MAX_LABEL_LENGTH = max(len(label) for label in to_keep) | ||
column = {"function": "function", "ms": "ms", "%": "% sum"} | ||
print( | ||
f"{column['function']:<{MAX_LABEL_LENGTH}}{column['ms']:>8} {column['%']:>8}") | ||
for key in to_keep: | ||
time_ms = bench[key]/1e6 | ||
print(f"{key:<{MAX_LABEL_LENGTH}}{time_ms:>8.0f} {time_ms/sum_of_kept_times_ms:>8.2%}") | ||
|
||
# Validate that kept times account for most of the total measured time. | ||
total_time_ms = bench["real_time"] | ||
totals = '\nTotal time accounted for: {:.0f}ms/{:.0f}ms = {:.2%}' | ||
totals = totals.format( | ||
sum_of_kept_times_ms, total_time_ms, sum_of_kept_times_ms/total_time_ms) | ||
print(totals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
TARGET="client_ivc_bench" | ||
FILTER="ClientIVCBench/Full/6$" | ||
BUILD_DIR=build-op-count-time | ||
|
||
# Move above script dir. | ||
cd $(dirname $0)/.. | ||
|
||
# Measure the benchmarks with ops time counting | ||
./scripts/benchmark_remote.sh client_ivc_bench\ | ||
"./client_ivc_bench --benchmark_filter=$FILTER\ | ||
--benchmark_out=$TARGET.json\ | ||
--benchmark_out_format=json"\ | ||
op-count-time\ | ||
build-op-count-time | ||
|
||
# Retrieve output from benching instance | ||
cd $BUILD_DIR | ||
scp $BB_SSH_KEY $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build/$TARGET.json . | ||
|
||
# Analyze the results | ||
cd $(dirname $0)/.. | ||
python3 ./scripts/analyze_client_ivc_bench.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
barretenberg_module(client_ivc_bench client_ivc stdlib_recursion stdlib_sha256 crypto_merkle_tree stdlib_primitives) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
barretenberg/cpp/src/barretenberg/benchmark/ivc_bench/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters