From a76174b76b80baed21390e39796fb800fed52ae9 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 17 Aug 2017 10:31:47 +0100 Subject: [PATCH 1/3] Benchmark time to call sendtoaddress with many UTXOs --- qa/zcash/create_wallet_200k_utxos.py | 62 +++++++++++++++++++++ qa/zcash/performance-measurements.sh | 82 +++++++++++++++++++++++++--- src/wallet/rpcwallet.cpp | 6 ++ src/zcbenchmarks.cpp | 15 +++++ src/zcbenchmarks.h | 1 + 5 files changed, 157 insertions(+), 9 deletions(-) create mode 100755 qa/zcash/create_wallet_200k_utxos.py diff --git a/qa/zcash/create_wallet_200k_utxos.py b/qa/zcash/create_wallet_200k_utxos.py new file mode 100755 index 000000000..870a4a90b --- /dev/null +++ b/qa/zcash/create_wallet_200k_utxos.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python2 +# Copyright (c) 2017 The Zcash developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# +# Create a large wallet +# +# To use: +# - Copy to qa/rpc-tests/wallet_large.py +# - Add wallet_large.py to RPC tests list +# - ./qa/pull-tester/rpc-tests.sh wallet_large --noshutdown +# - Archive the resulting /tmp/test###### directory +# + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_equal, + connect_nodes_bi, + initialize_chain_clean, + start_nodes, +) + +from decimal import Decimal + + +class LargeWalletTest(BitcoinTestFramework): + + def setup_chain(self): + print("Initializing test directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, 2) + + def setup_network(self): + self.nodes = start_nodes(2, self.options.tmpdir) + connect_nodes_bi(self.nodes, 0, 1) + self.is_network_split = False + self.sync_all() + + def run_test(self): + self.nodes[1].generate(103) + self.sync_all() + + inputs = [] + for i in range(200000): + taddr = self.nodes[0].getnewaddress() + inputs.append(self.nodes[1].sendtoaddress(taddr, Decimal("0.001"))) + if i % 1000 == 0: + self.nodes[1].generate(1) + self.sync_all() + + assert_equal(set(self.nodes[1].getrawmempool()), set(inputs)) + print(self.nodes[1].getmempoolinfo()) + self.nodes[1].generate(1) + print(self.nodes[1].getmempoolinfo()) + self.sync_all() + print('Node 0: %d transactions, %d UTXOs' % + (len(self.nodes[0].listtransactions()), len(self.nodes[0].listunspent()))) + print('Node 1: %d transactions, %d UTXOs' % + (len(self.nodes[1].listtransactions()), len(self.nodes[1].listunspent()))) + +if __name__ == '__main__': + LargeWalletTest().main() diff --git a/qa/zcash/performance-measurements.sh b/qa/zcash/performance-measurements.sh index e1eb242be..d6cc504d1 100755 --- a/qa/zcash/performance-measurements.sh +++ b/qa/zcash/performance-measurements.sh @@ -28,10 +28,52 @@ function zcashd_generate { zcash_rpc generate 101 > /dev/null } +function extract_benchmark_datadir { + if [ -f "$1.tar.xz" ]; then + # Check the hash of the archive: + "$SHA256CMD" $SHA256ARGS -c < Date: Wed, 6 Sep 2017 19:52:35 +0100 Subject: [PATCH 2/3] Fix bug in benchmark data generation script --- qa/zcash/create_wallet_200k_utxos.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qa/zcash/create_wallet_200k_utxos.py b/qa/zcash/create_wallet_200k_utxos.py index 870a4a90b..c4ac3e2e4 100755 --- a/qa/zcash/create_wallet_200k_utxos.py +++ b/qa/zcash/create_wallet_200k_utxos.py @@ -48,15 +48,13 @@ class LargeWalletTest(BitcoinTestFramework): self.nodes[1].generate(1) self.sync_all() - assert_equal(set(self.nodes[1].getrawmempool()), set(inputs)) - print(self.nodes[1].getmempoolinfo()) self.nodes[1].generate(1) - print(self.nodes[1].getmempoolinfo()) self.sync_all() print('Node 0: %d transactions, %d UTXOs' % (len(self.nodes[0].listtransactions()), len(self.nodes[0].listunspent()))) print('Node 1: %d transactions, %d UTXOs' % (len(self.nodes[1].listtransactions()), len(self.nodes[1].listunspent()))) + assert_equal(len(self.nodes[0].listunspent()), len(inputs)) if __name__ == '__main__': LargeWalletTest().main() From e719bf75d4a0858b2e435eae9e6d2ccc7faf7780 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 11 Sep 2017 21:53:35 +0100 Subject: [PATCH 3/3] Adjust instructions for UTXO dataset creation --nocleanup is sufficient to leave the data directories behind. --noshutdown is only useful if you want to inspect the nodes afterwards, and you'd need to manually shut down both nodes before copying the data directories. --- qa/zcash/create_wallet_200k_utxos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/zcash/create_wallet_200k_utxos.py b/qa/zcash/create_wallet_200k_utxos.py index c4ac3e2e4..d4a1d9d48 100755 --- a/qa/zcash/create_wallet_200k_utxos.py +++ b/qa/zcash/create_wallet_200k_utxos.py @@ -9,7 +9,7 @@ # To use: # - Copy to qa/rpc-tests/wallet_large.py # - Add wallet_large.py to RPC tests list -# - ./qa/pull-tester/rpc-tests.sh wallet_large --noshutdown +# - ./qa/pull-tester/rpc-tests.sh wallet_large --nocleanup # - Archive the resulting /tmp/test###### directory #