Skip to content

Commit

Permalink
feat: additional op count timing (#4722)
Browse files Browse the repository at this point in the history
Breaks down ivc_bench

To use
```
./scripts/benchmark_remote.sh ivc_bench "./ivc_bench --benchmark_filter=Full/6$"  op-count-time build-op-count-time
```

Example output:
```
--------------------------------------------------------------------------
Benchmark                Time             CPU   Iterations UserCounters...
--------------------------------------------------------------------------
IvcBench/Full/6      40041 ms        37593 ms            1 
batch_mul_with_endomorphism=30 batch_mul_with_endomorphism(t)=558.328M 
commit=804 commit(t)=8.09288G 
compute_combiner=11 compute_combiner(t)=7.9927G 
compute_perturbator=10 compute_perturbator(t)=1.58407G 
construct_mock_folding_kernel=5 construct_mock_folding_kernel(t)=2.3719G 
construct_mock_function_circuit=7 construct_mock_function_circuit(t)=5.2571G
```
  • Loading branch information
ludamad authored Feb 23, 2024
1 parent 6a8b2e2 commit f0cc760
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion barretenberg/cpp/scripts/collect_profile_information.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cd $(dirname $0)/..

# Configure and build with xray preset.
cmake --preset $PRESET
cmake --build --preset $PRESET
cmake --build --preset $PRESET --target $EXECUTABLE

cd build-$PRESET

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ BENCHMARK_DEFINE_F(IvcBench, Accumulate)(benchmark::State& state)

// Perform a specified number of iterations of function/kernel accumulation
for (auto _ : state) {
BB_REPORT_OP_COUNT_IN_BENCH(state);
perform_ivc_accumulation_rounds(state, ivc);
}
}
Expand All @@ -110,12 +111,12 @@ BENCHMARK_DEFINE_F(IvcBench, Decide)(benchmark::State& state)
{
ClientIVC ivc;

BB_REPORT_OP_COUNT_IN_BENCH(state);
// Perform a specified number of iterations of function/kernel accumulation
perform_ivc_accumulation_rounds(state, ivc);

// Construct eccvm proof, measure only translator proof construction
for (auto _ : state) {
BB_REPORT_OP_COUNT_IN_BENCH(state);
ivc.decider_prove();
}
}
Expand All @@ -128,12 +129,12 @@ BENCHMARK_DEFINE_F(IvcBench, ECCVM)(benchmark::State& state)
{
ClientIVC ivc;

BB_REPORT_OP_COUNT_IN_BENCH(state);
// Perform a specified number of iterations of function/kernel accumulation
perform_ivc_accumulation_rounds(state, ivc);

// Construct and measure eccvm only
for (auto _ : state) {
BB_REPORT_OP_COUNT_IN_BENCH(state);
ivc.goblin.prove_eccvm();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* simplify the codebase.
*/

#include "barretenberg/common/op_count.hpp"
#include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/numeric/bitop/pow.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
Expand Down Expand Up @@ -64,6 +65,7 @@ template <class Curve> class CommitmentKey {
*/
Commitment commit(std::span<const Fr> polynomial)
{
BB_OP_COUNT_TIME();
const size_t degree = polynomial.size();
ASSERT(degree <= srs->get_monomial_size());
return bb::scalar_multiplication::pippenger_unsafe<Curve>(
Expand Down
3 changes: 3 additions & 0 deletions barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "barretenberg/commitment_schemes/commitment_key.hpp"
#include "barretenberg/common/op_count.hpp"
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/crypto/merkle_tree/membership.hpp"
#include "barretenberg/crypto/merkle_tree/memory_store.hpp"
Expand Down Expand Up @@ -95,6 +96,7 @@ class GoblinMockCircuits {
*/
static void construct_mock_function_circuit(GoblinUltraBuilder& builder, bool large = false)
{
BB_OP_COUNT_TIME();
// Determine number of times to execute the below operations that constitute the mock circuit logic. Note that
// the circuit size does not scale linearly with number of iterations due to e.g. amortization of lookup costs
const size_t NUM_ITERATIONS_LARGE = 13; // results in circuit size 2^19 (521327 gates)
Expand Down Expand Up @@ -216,6 +218,7 @@ class GoblinMockCircuits {
const std::vector<FF>& function_fold_proof,
const std::vector<FF>& kernel_fold_proof)
{
BB_OP_COUNT_TIME();
using GURecursiveFlavor = GoblinUltraRecursiveFlavor_<GoblinUltraBuilder>;
using RecursiveVerifierInstances = ::bb::VerifierInstances_<GURecursiveFlavor, 2>;
using FoldingRecursiveVerifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ typename ExecutionTrace_<Flavor>::TraceData ExecutionTrace_<Flavor>::construct_t
// For each block in the trace, populate wire polys, copy cycles and selector polys
for (auto& block : trace_blocks) {
auto block_size = static_cast<uint32_t>(block.wires[0].size());
info("block size = ", block_size);

// Update wire polynomials and copy cycles
// NB: The order of row/column loops is arbitrary but needs to be row/column to match old copy_cycle code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "barretenberg/common/op_count.hpp"
#include "barretenberg/common/thread.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/flavor/flavor.hpp"
Expand Down Expand Up @@ -247,6 +248,7 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
static Polynomial<FF> compute_perturbator(const std::shared_ptr<Instance> accumulator,
const std::vector<FF>& deltas)
{
BB_OP_COUNT_TIME();
auto full_honk_evaluations = compute_full_honk_evaluations(
accumulator->prover_polynomials, accumulator->alphas, accumulator->relation_parameters);
const auto betas = accumulator->gate_challenges;
Expand Down Expand Up @@ -298,6 +300,7 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
*/
ExtendedUnivariateWithRandomization compute_combiner(const ProverInstances& instances, PowPolynomial<FF>& pow_betas)
{
BB_OP_COUNT_TIME();
size_t common_instance_size = instances[0]->instance_size;
pow_betas.compute_values();
// Determine number of threads for multithreading.
Expand Down

0 comments on commit f0cc760

Please sign in to comment.