-
Notifications
You must be signed in to change notification settings - Fork 292
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: Pippenger benchmarks compatible with wasmtime #6095
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
barretenberg/cpp/src/barretenberg/benchmark/basics_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 |
---|---|---|
@@ -1 +1 @@ | ||
barretenberg_module(basics_bench ecc) | ||
barretenberg_module(basics_bench ecc srs) |
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 |
---|---|---|
|
@@ -20,9 +20,11 @@ | |
* sequential_copy: 3.3 | ||
* | ||
*/ | ||
#include "barretenberg/commitment_schemes/commitment_key.hpp" | ||
#include "barretenberg/common/op_count.hpp" | ||
#include "barretenberg/common/thread.hpp" | ||
#include "barretenberg/ecc/curves/bn254/bn254.hpp" | ||
#include "barretenberg/srs/global_crs.hpp" | ||
#include <benchmark/benchmark.h> | ||
|
||
using namespace benchmark; | ||
|
@@ -304,7 +306,7 @@ void projective_point_doubling(State& state) | |
*@details ~50000 ns | ||
* @param state | ||
*/ | ||
void scalar_multiplication(State& state) | ||
void scalar_multiplication_bench(State& state) | ||
{ | ||
numeric::RNG& engine = numeric::get_debug_randomness(); | ||
Curve::Element element = Curve::Element::random_element(&engine); | ||
|
@@ -364,6 +366,47 @@ void sequential_copy(State& state) | |
} | ||
} | ||
} | ||
|
||
/** | ||
* @brief Load srs for pippenger | ||
* | ||
*/ | ||
static void DoPippengerSetup(const benchmark::State&) | ||
{ | ||
bb::srs::init_crs_factory("../srs_db/ignition"); | ||
} | ||
|
||
/** | ||
* @brief Run pippenger benchmarks (can be used with wasmtime) | ||
* | ||
*@details(Wasmtime) ----------------------------------------------- | ||
Benchmark Time CPU Iterations | ||
-------------------------------------------------------------------- | ||
pippenger/16/iterations:5 133089 us 1.3309e+11 us 5 | ||
pippenger/17/iterations:5 255069 us 2.5507e+11 us 5 | ||
pippenger/18/iterations:5 481599 us 4.8160e+11 us 5 | ||
pippenger/19/iterations:5 892886 us 8.9289e+11 us 5 | ||
pippenger/20/iterations:5 1706423 us 1.7064e+12 us 5 | ||
*/ | ||
void pippenger(State& state) | ||
{ | ||
numeric::RNG& engine = numeric::get_debug_randomness(); | ||
for (auto _ : state) { | ||
state.PauseTiming(); | ||
size_t num_cycles = 1 << static_cast<size_t>(state.range(0)); | ||
Polynomial<Fr> pol(num_cycles); | ||
for (size_t i = 0; i < num_cycles; i++) { | ||
*(uint256_t*)&pol[i] = engine.get_random_uint256(); | ||
pol[i].self_reduce_once(); | ||
pol[i].self_reduce_once(); | ||
pol[i].self_reduce_once(); | ||
} | ||
|
||
auto ck = std::make_shared<CommitmentKey<curve::BN254>>(num_cycles); | ||
state.ResumeTiming(); | ||
benchmark::DoNotOptimize(ck->commit(pol)); | ||
} | ||
} | ||
} // namespace | ||
|
||
BENCHMARK(parallel_for_field_element_addition)->Unit(kMicrosecond)->DenseRange(0, MAX_REPETITION_LOG); | ||
|
@@ -377,7 +420,8 @@ BENCHMARK(ff_reduce)->Unit(kMicrosecond)->DenseRange(12, 29); | |
BENCHMARK(projective_point_addition)->Unit(kMicrosecond)->DenseRange(12, 22); | ||
BENCHMARK(projective_point_accidental_doubling)->Unit(kMicrosecond)->DenseRange(12, 22); | ||
BENCHMARK(projective_point_doubling)->Unit(kMicrosecond)->DenseRange(12, 22); | ||
BENCHMARK(scalar_multiplication)->Unit(kMicrosecond)->DenseRange(12, 18); | ||
BENCHMARK(scalar_multiplication_bench)->Unit(kMicrosecond)->DenseRange(12, 18); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scalar_multiplication name has already been used internally, so I had to rename |
||
BENCHMARK(cycle_waste)->Unit(kMicrosecond)->DenseRange(20, 30); | ||
BENCHMARK(sequential_copy)->Unit(kMicrosecond)->DenseRange(20, 25); | ||
BENCHMARK(pippenger)->Unit(kMicrosecond)->DenseRange(16, 20)->Setup(DoPippengerSetup)->Iterations(5); | ||
BENCHMARK_MAIN(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to go through slow division to sample random elements