mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#13013: Move constructors out of mempool_eviction hot loop
This commit is contained in:
parent
28a5e599bf
commit
cf59264631
@ -9,7 +9,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
static void AddTx(const CMutableTransaction& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
{
|
||||
int64_t nTime = 0;
|
||||
unsigned int nHeight = 1;
|
||||
@ -17,7 +17,7 @@ static void AddTx(const CMutableTransaction& tx, const CAmount& nFee, CTxMemPool
|
||||
unsigned int sigOpCost = 4;
|
||||
LockPoints lp;
|
||||
pool.addUnchecked(CTxMemPoolEntry(
|
||||
MakeTransactionRef(tx), nFee, nTime, nHeight,
|
||||
tx, nFee, nTime, nHeight,
|
||||
spendsCoinbase, sigOpCost, lp));
|
||||
}
|
||||
|
||||
@ -97,16 +97,25 @@ static void MempoolEviction(benchmark::Bench& bench)
|
||||
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)};
|
||||
|
||||
LOCK2(cs_main, pool.cs);
|
||||
|
||||
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
|
||||
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(::GetSerializeSize(tx1, SER_NETWORK, PROTOCOL_VERSION));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user