Browse Source
Extend createjoinsplit to benchmark parallel JoinSplits
Closes #1940
v1.0.9-lin
Jack Grigg
8 years ago
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
4 changed files with
34 additions and
4 deletions
-
qa/zcash/performance-measurements.sh
-
src/wallet/rpcwallet.cpp
-
src/zcbenchmarks.cpp
-
src/zcbenchmarks.h
|
|
@ -74,7 +74,7 @@ case "$1" in |
|
|
|
zcash_rpc zcbenchmark parameterloading 10 |
|
|
|
;; |
|
|
|
createjoinsplit) |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 10 |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 10 "${@:3}" |
|
|
|
;; |
|
|
|
verifyjoinsplit) |
|
|
|
zcash_rpc zcbenchmark verifyjoinsplit 1000 "\"$RAWJOINSPLIT\"" |
|
|
@ -111,7 +111,7 @@ case "$1" in |
|
|
|
zcash_rpc zcbenchmark parameterloading 1 |
|
|
|
;; |
|
|
|
createjoinsplit) |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 1 |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 1 "${@:3}" |
|
|
|
;; |
|
|
|
verifyjoinsplit) |
|
|
|
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\"" |
|
|
@ -146,7 +146,7 @@ case "$1" in |
|
|
|
zcash_rpc zcbenchmark parameterloading 1 |
|
|
|
;; |
|
|
|
createjoinsplit) |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 1 |
|
|
|
zcash_rpc zcbenchmark createjoinsplit 1 "${@:3}" |
|
|
|
;; |
|
|
|
verifyjoinsplit) |
|
|
|
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\"" |
|
|
|
|
|
@ -2465,7 +2465,15 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp) |
|
|
|
} else if (benchmarktype == "parameterloading") { |
|
|
|
sample_times.push_back(benchmark_parameter_loading()); |
|
|
|
} else if (benchmarktype == "createjoinsplit") { |
|
|
|
sample_times.push_back(benchmark_create_joinsplit()); |
|
|
|
if (params.size() < 3) { |
|
|
|
sample_times.push_back(benchmark_create_joinsplit()); |
|
|
|
} else { |
|
|
|
int nThreads = params[2].get_int(); |
|
|
|
std::vector<double> vals = benchmark_create_joinsplit_threaded(nThreads); |
|
|
|
// Divide by nThreads^2 to get average seconds per JoinSplit because
|
|
|
|
// we are running one JoinSplit per thread.
|
|
|
|
sample_times.push_back(std::accumulate(vals.begin(), vals.end(), 0.0) / (nThreads*nThreads)); |
|
|
|
} |
|
|
|
} else if (benchmarktype == "verifyjoinsplit") { |
|
|
|
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit)); |
|
|
|
} else if (benchmarktype == "solveequihash") { |
|
|
|
|
|
@ -95,6 +95,27 @@ double benchmark_create_joinsplit() |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
std::vector<double> benchmark_create_joinsplit_threaded(int nThreads) |
|
|
|
{ |
|
|
|
std::vector<double> ret; |
|
|
|
std::vector<std::future<double>> tasks; |
|
|
|
std::vector<std::thread> threads; |
|
|
|
for (int i = 0; i < nThreads; i++) { |
|
|
|
std::packaged_task<double(void)> task(&benchmark_create_joinsplit); |
|
|
|
tasks.emplace_back(task.get_future()); |
|
|
|
threads.emplace_back(std::move(task)); |
|
|
|
} |
|
|
|
std::future_status status; |
|
|
|
for (auto it = tasks.begin(); it != tasks.end(); it++) { |
|
|
|
it->wait(); |
|
|
|
ret.push_back(it->get()); |
|
|
|
} |
|
|
|
for (auto it = threads.begin(); it != threads.end(); it++) { |
|
|
|
it->join(); |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
double benchmark_verify_joinsplit(const JSDescription &joinsplit) |
|
|
|
{ |
|
|
|
struct timeval tv_start; |
|
|
|
|
|
@ -7,6 +7,7 @@ |
|
|
|
extern double benchmark_sleep(); |
|
|
|
extern double benchmark_parameter_loading(); |
|
|
|
extern double benchmark_create_joinsplit(); |
|
|
|
extern std::vector<double> benchmark_create_joinsplit_threaded(int nThreads); |
|
|
|
extern double benchmark_solve_equihash(); |
|
|
|
extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads); |
|
|
|
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit); |
|
|
|