-
Notifications
You must be signed in to change notification settings - Fork 241
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: Benchmark commit function #4178
Merged
Merged
Changes from 3 commits
Commits
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
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
18 changes: 18 additions & 0 deletions
18
barretenberg/cpp/src/barretenberg/benchmark/commit_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,18 @@ | ||
# Each source represents a separate benchmark suite | ||
set(BENCHMARK_SOURCES | ||
commit.bench.cpp | ||
) | ||
|
||
# Required libraries for benchmark suites | ||
set(LINKED_LIBRARIES | ||
commitment_schemes | ||
benchmark::benchmark | ||
) | ||
|
||
# Add executable and custom target for each suite, e.g. ultra_honk_bench | ||
foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) | ||
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension | ||
add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) | ||
target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) | ||
add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
endforeach() |
38 changes: 38 additions & 0 deletions
38
barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp
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,38 @@ | ||
|
||
#include "barretenberg/commitment_schemes/commitment_key.hpp" | ||
#include <benchmark/benchmark.h> | ||
|
||
namespace bb { | ||
|
||
template <typename Curve> | ||
std::shared_ptr<honk::pcs::CommitmentKey<Curve>> create_commitment_key(const size_t num_points) | ||
{ | ||
std::string srs_path; | ||
if constexpr (std::same_as<Curve, curve::BN254>) { | ||
srs_path = "../srs_db/ignition"; | ||
} else { | ||
static_assert(std::same_as<Curve, curve::Grumpkin>); | ||
srs_path = "../srs_db/grumpkin"; | ||
} | ||
std::shared_ptr<bb::srs::factories::CrsFactory<Curve>> crs_factory( | ||
new bb::srs::factories::FileCrsFactory<Curve>(srs_path, num_points)); | ||
return std::make_shared<honk::pcs::CommitmentKey<Curve>>(num_points, crs_factory); | ||
} | ||
|
||
constexpr size_t MAX_LOG_NUM_POINTS = 24; | ||
constexpr size_t MAX_NUM_POINTS = 1 << 24; | ||
|
||
auto key = create_commitment_key<curve::BN254>(MAX_NUM_POINTS); | ||
|
||
template <typename Curve> void bench_commit(::benchmark::State& state) | ||
{ | ||
const size_t num_points = 1 << state.range(0); | ||
const auto polynomial = Polynomial<typename Curve::ScalarField>(num_points); | ||
for (auto _ : state) { | ||
benchmark::DoNotOptimize(key->commit(polynomial)); | ||
} | ||
} | ||
|
||
BENCHMARK(bench_commit<curve::BN254>)->DenseRange(10, MAX_LOG_NUM_POINTS)->Unit(benchmark::kMillisecond); | ||
|
||
} // namespace bb |
3 changes: 3 additions & 0 deletions
3
barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp
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,3 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
BENCHMARK_MAIN(); |
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
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.
Did you mean to use
MAX_LOG_NUM_POINTS
here instead of 24?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.
Oh yes should have done, thanks