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

[5.0 -> main] Benchmark BLS host functions, Do not require trailing = for base64 encoded strings #1898

Merged
merged 20 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c2951f3
plumbing a webassembly::interface object for benchmarking BLS host fu…
linh2931 Nov 9, 2023
be7dcc0
benchmark bls_g1_add, bls_g2_add, bls_g1_mul, bls_g2_mul
linh2931 Nov 9, 2023
6f3b7de
support benchmarked function specific limit of number of runs
linh2931 Nov 9, 2023
b2e214d
benchmark bls_pairing, bls_g1_exp, bls_g2_exp
linh2931 Nov 9, 2023
63b90eb
benchmark bls_g1_map, bls_g2_map, and bls_fp_mod
linh2931 Nov 9, 2023
181d242
print number of runs right aligned since now the numbers can be diffe…
linh2931 Nov 9, 2023
4b65a4f
use a single eosio::benchmark for BLS while still being a friend of e…
linh2931 Nov 9, 2023
ec1e594
remove little used control as a member of interface_in_benchmark, use…
linh2931 Nov 9, 2023
a53e6fc
set max block and transaction cpu to 999'999'999 such that expensive …
linh2931 Nov 9, 2023
f54724f
revert benchmarked function specific limit of number of runs changes,…
linh2931 Nov 9, 2023
a96d6de
improve and add more comments
linh2931 Nov 9, 2023
f0ae929
Merge branch 'release/5.0' into bls_host_funcs_benchmark
linh2931 Nov 10, 2023
bce1b0b
GH-1461 Do not require trailing `=` for base64 encoded strings to sup…
heifner Nov 13, 2023
8a9d841
Merge pull request #1889 from AntelopeIO/GH-1461-base64-3.2
heifner Nov 13, 2023
78181c4
Merge remote-tracking branch 'origin/release/3.2' into GH-1461-base64…
heifner Nov 13, 2023
e41fbb7
Merge pull request #1892 from AntelopeIO/GH-1461-base64-4.0
heifner Nov 13, 2023
92ba6d4
Merge remote-tracking branch 'origin/release/4.0' into GH-1461-base64…
heifner Nov 13, 2023
65cc325
Merge pull request #1884 from AntelopeIO/bls_host_funcs_benchmark
arhag Nov 14, 2023
f1919a0
Merge pull request #1894 from AntelopeIO/GH-1461-base64-5.0
heifner Nov 14, 2023
1b8e184
Merge remote-tracking branch 'origin/release/5.0' into GH-1461-base64…
heifner Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
file(GLOB BENCHMARK "*.cpp")
add_executable( benchmark ${BENCHMARK} )

target_link_libraries( benchmark fc Boost::program_options bn256)
target_link_libraries( benchmark eosio_testing fc Boost::program_options bn256)
target_include_directories( benchmark PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/../unittests/include"
)
2 changes: 1 addition & 1 deletion benchmark/alt_bn_128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

using bytes = std::vector<char>;
using g1g2_pair = std::vector<std::string>;
Expand Down
11 changes: 7 additions & 4 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

// update this map when a new feature is supported
// key is the name and value is the function doing benchmarking
Expand All @@ -15,6 +15,7 @@ std::map<std::string, std::function<void()>> features {
{ "key", key_benchmarking },
{ "hash", hash_benchmarking },
{ "blake2", blake2_benchmarking },
{ "bls", bls_benchmarking }
};

// values to control cout format
Expand Down Expand Up @@ -46,10 +47,10 @@ void print_results(std::string name, uint32_t runs, uint64_t total, uint64_t min
std::cout.imbue(std::locale(""));
std::cout
<< std::setw(name_width) << std::left << name
<< std::setw(runs_width) << runs
// std::fixed for not printing 1234 in 1.234e3.
// setprecision(0) for not printing fractions
<< std::right << std::fixed << std::setprecision(0)
<< std::setw(runs_width) << runs
<< std::setw(time_width) << total/runs << std::setw(ns_width) << " ns"
<< std::setw(time_width) << min << std::setw(ns_width) << " ns"
<< std::setw(time_width) << max << std::setw(ns_width) << " ns"
Expand All @@ -62,8 +63,10 @@ bytes to_bytes(const std::string& source) {
return output;
};

void benchmarking(std::string name, const std::function<void()>& func) {
uint64_t total {0}, min {std::numeric_limits<uint64_t>::max()}, max {0};
void benchmarking(const std::string& name, const std::function<void()>& func) {
uint64_t total{0};
uint64_t min{std::numeric_limits<uint64_t>::max()};
uint64_t max{0};

for (auto i = 0U; i < num_runs; ++i) {
auto start_time = std::chrono::high_resolution_clock::now();
Expand Down
6 changes: 4 additions & 2 deletions benchmark/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#include <functional>
#include <map>
#include <vector>
#include <limits>

#include <fc/crypto/hex.hpp>

namespace benchmark {
namespace eosio::benchmark {
using bytes = std::vector<char>;

void set_num_runs(uint32_t runs);
Expand All @@ -19,7 +20,8 @@ void modexp_benchmarking();
void key_benchmarking();
void hash_benchmarking();
void blake2_benchmarking();
void bls_benchmarking();

void benchmarking(std::string name, const std::function<void()>& func);
void benchmarking(const std::string& name, const std::function<void()>& func);

} // benchmark
2 changes: 1 addition & 1 deletion benchmark/blake2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

void blake2_benchmarking() {
uint32_t _rounds = 0x0C;
Expand Down
Loading