Browse Source

add load-wallet benchmark

pull/4/head
Ariel Gabizon 7 years ago
parent
commit
2e8aefdce1
  1. 7
      qa/zcash/performance-measurements.sh
  2. 5
      src/wallet/rpcwallet.cpp
  3. 45
      src/zcbenchmarks.cpp
  4. 1
      src/zcbenchmarks.h

7
qa/zcash/performance-measurements.sh

@ -56,7 +56,7 @@ function use_200k_benchmark {
function zcashd_start {
case "$1" in
sendtoaddress)
sendtoaddress|loadwallet)
case "$2" in
200k-recv)
use_200k_benchmark 0
@ -86,7 +86,7 @@ function zcashd_stop {
function zcashd_massif_start {
case "$1" in
sendtoaddress)
sendtoaddress|loadwallet)
case "$2" in
200k-recv)
use_200k_benchmark 0
@ -203,6 +203,9 @@ case "$1" in
sendtoaddress)
zcash_rpc zcbenchmark sendtoaddress 10 "${@:4}"
;;
loadwallet)
zcash_rpc zcbenchmark loadwallet 10
;;
*)
zcashd_stop
echo "Bad arguments."

5
src/wallet/rpcwallet.cpp

@ -2602,6 +2602,11 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp)
}
auto amount = AmountFromValue(params[2]);
sample_times.push_back(benchmark_sendtoaddress(amount));
} else if (benchmarktype == "loadwallet") {
if (Params().NetworkIDString() != "regtest") {
throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
}
sample_times.push_back(benchmark_loadwallet());
} else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");
}

45
src/zcbenchmarks.cpp

@ -31,6 +31,39 @@
#include "zcash/IncrementalMerkleTree.hpp"
using namespace libzcash;
// This method is based on Shutdown from init.cpp
void pre_wallet_load()
{
LogPrintf("%s: In progress...\n", __func__);
if (ShutdownRequested())
throw new std::runtime_error("The node is shutting down");
if (pwalletMain)
pwalletMain->Flush(false);
#ifdef ENABLE_MINING
GenerateBitcoins(false, NULL, 0);
#endif
UnregisterNodeSignals(GetNodeSignals());
if (pwalletMain)
pwalletMain->Flush(true);
UnregisterValidationInterface(pwalletMain);
delete pwalletMain;
pwalletMain = NULL;
bitdb.Reset();
RegisterNodeSignals(GetNodeSignals());
LogPrintf("%s: done\n", __func__);
}
void post_wallet_load(){
RegisterValidationInterface(pwalletMain);
#ifdef ENABLE_MINING
// Generate coins in the background
if (pwalletMain || !GetArg("-mineraddress", "").empty())
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
#endif
}
void timer_start(timeval &tv_start)
{
@ -420,3 +453,15 @@ double benchmark_sendtoaddress(CAmount amount)
return timer_stop(tv_start);
}
double benchmark_loadwallet()
{
pre_wallet_load();
struct timeval tv_start;
bool fFirstRunRet=true;
timer_start(tv_start);
pwalletMain = new CWallet("wallet.dat");
DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRunRet);
auto res = timer_stop(tv_start);
post_wallet_load();
return res;
}

1
src/zcbenchmarks.h

@ -17,5 +17,6 @@ extern double benchmark_try_decrypt_notes(size_t nAddrs);
extern double benchmark_increment_note_witnesses(size_t nTxs);
extern double benchmark_connectblock_slow();
extern double benchmark_sendtoaddress(CAmount amount);
extern double benchmark_loadwallet();
#endif

Loading…
Cancel
Save