diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-04-24 13:25:39 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-04-24 13:25:45 -0400 |
commit | a0079d4b6dc67be3889af9a16eda89b3c4b33bc5 (patch) | |
tree | ef5fa315e39953d70ad00d404f5d210863606df5 /src | |
parent | 476cb35551f559573c81a3927856b3f76aecd6e9 (diff) | |
parent | fa3bb183adaf086a70fbbe2bb1981f471a3281ce (diff) |
Merge #13013: bench: Amend mempool_eviction test for witness txs
fa3bb183ad bench: Amend mempool_eviction test for witness txs (MarcoFalke)
962d223e5c bench: Move constructors out of mempool_eviction hot loop (MarcoFalke)
Pull request description:
Tree-SHA512: 997a07e067623bc2c0904a21bd490d164045cf51393af260fc79882ed010636dce82c9ebe35aae8fa5db5e73c9f3ecb6232353a0939c295034f9be574f1fcff2
Diffstat (limited to 'src')
-rw-r--r-- | src/bench/mempool_eviction.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp index e05a5e3d1e..4c947a519f 100644 --- a/src/bench/mempool_eviction.cpp +++ b/src/bench/mempool_eviction.cpp @@ -9,16 +9,16 @@ #include <list> #include <vector> -static void AddTx(const CMutableTransaction& tx, const CAmount& nFee, CTxMemPool& pool) +static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) { int64_t nTime = 0; unsigned int nHeight = 1; bool spendsCoinbase = false; unsigned int sigOpCost = 4; LockPoints lp; - pool.addUnchecked(tx.GetHash(), CTxMemPoolEntry( - MakeTransactionRef(tx), nFee, nTime, nHeight, - spendsCoinbase, sigOpCost, lp)); + pool.addUnchecked(tx->GetHash(), CTxMemPoolEntry( + tx, nFee, nTime, nHeight, + spendsCoinbase, sigOpCost, lp)); } // Right now this is only testing eviction performance in an extremely small @@ -29,6 +29,7 @@ static void MempoolEviction(benchmark::State& state) CMutableTransaction tx1 = CMutableTransaction(); tx1.vin.resize(1); tx1.vin[0].scriptSig = CScript() << OP_1; + tx1.vin[0].scriptWitness.stack.push_back({1}); tx1.vout.resize(1); tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; tx1.vout[0].nValue = 10 * COIN; @@ -36,6 +37,7 @@ static void MempoolEviction(benchmark::State& state) CMutableTransaction tx2 = CMutableTransaction(); tx2.vin.resize(1); tx2.vin[0].scriptSig = CScript() << OP_2; + tx2.vin[0].scriptWitness.stack.push_back({2}); tx2.vout.resize(1); tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL; tx2.vout[0].nValue = 10 * COIN; @@ -44,6 +46,7 @@ static void MempoolEviction(benchmark::State& state) tx3.vin.resize(1); tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0); tx3.vin[0].scriptSig = CScript() << OP_2; + tx3.vin[0].scriptWitness.stack.push_back({3}); tx3.vout.resize(1); tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL; tx3.vout[0].nValue = 10 * COIN; @@ -52,8 +55,10 @@ static void MempoolEviction(benchmark::State& state) tx4.vin.resize(2); tx4.vin[0].prevout.SetNull(); tx4.vin[0].scriptSig = CScript() << OP_4; + tx4.vin[0].scriptWitness.stack.push_back({4}); tx4.vin[1].prevout.SetNull(); tx4.vin[1].scriptSig = CScript() << OP_4; + tx4.vin[1].scriptWitness.stack.push_back({4}); tx4.vout.resize(2); tx4.vout[0].scriptPubKey = CScript() << OP_4 << OP_EQUAL; tx4.vout[0].nValue = 10 * COIN; @@ -64,8 +69,10 @@ static void MempoolEviction(benchmark::State& state) tx5.vin.resize(2); tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0); tx5.vin[0].scriptSig = CScript() << OP_4; + tx5.vin[0].scriptWitness.stack.push_back({4}); tx5.vin[1].prevout.SetNull(); tx5.vin[1].scriptSig = CScript() << OP_5; + tx5.vin[1].scriptWitness.stack.push_back({5}); tx5.vout.resize(2); tx5.vout[0].scriptPubKey = CScript() << OP_5 << OP_EQUAL; tx5.vout[0].nValue = 10 * COIN; @@ -76,8 +83,10 @@ static void MempoolEviction(benchmark::State& state) tx6.vin.resize(2); tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1); tx6.vin[0].scriptSig = CScript() << OP_4; + tx6.vin[0].scriptWitness.stack.push_back({4}); tx6.vin[1].prevout.SetNull(); tx6.vin[1].scriptSig = CScript() << OP_6; + tx6.vin[1].scriptWitness.stack.push_back({6}); tx6.vout.resize(2); tx6.vout[0].scriptPubKey = CScript() << OP_6 << OP_EQUAL; tx6.vout[0].nValue = 10 * COIN; @@ -88,8 +97,10 @@ static void MempoolEviction(benchmark::State& state) tx7.vin.resize(2); tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0); tx7.vin[0].scriptSig = CScript() << OP_5; + tx7.vin[0].scriptWitness.stack.push_back({5}); tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0); tx7.vin[1].scriptSig = CScript() << OP_6; + tx7.vin[1].scriptWitness.stack.push_back({6}); tx7.vout.resize(2); tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL; tx7.vout[0].nValue = 10 * COIN; @@ -97,15 +108,23 @@ static void MempoolEviction(benchmark::State& state) tx7.vout[1].nValue = 10 * COIN; CTxMemPool pool; + // Create transaction references outside the "hot loop" + const CTransactionRef tx1_r{MakeTransactionRef(tx1)}; + const CTransactionRef tx2_r{MakeTransactionRef(tx2)}; + const CTransactionRef tx3_r{MakeTransactionRef(tx3)}; + const CTransactionRef tx4_r{MakeTransactionRef(tx4)}; + const CTransactionRef tx5_r{MakeTransactionRef(tx5)}; + const CTransactionRef tx6_r{MakeTransactionRef(tx6)}; + const CTransactionRef tx7_r{MakeTransactionRef(tx7)}; while (state.KeepRunning()) { - AddTx(tx1, 10000LL, pool); - AddTx(tx2, 5000LL, pool); - AddTx(tx3, 20000LL, pool); - AddTx(tx4, 7000LL, pool); - AddTx(tx5, 1000LL, pool); - AddTx(tx6, 1100LL, pool); - AddTx(tx7, 9000LL, pool); + AddTx(tx1_r, 10000LL, pool); + AddTx(tx2_r, 5000LL, pool); + AddTx(tx3_r, 20000LL, pool); + AddTx(tx4_r, 7000LL, pool); + AddTx(tx5_r, 1000LL, pool); + AddTx(tx6_r, 1100LL, pool); + AddTx(tx7_r, 9000LL, pool); pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); pool.TrimToSize(GetVirtualTransactionSize(tx1)); } |