mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge #8681: Performance Regression Fix: Pre-Allocate txChanged vector
ec81881
Performance Regression Fix: Pre-Allocate txChanged vector (Jeremy Rubin)
This commit is contained in:
commit
6898213409
11
src/main.cpp
11
src/main.cpp
@ -2787,7 +2787,7 @@ static int64_t nTimePostConnect = 0;
|
|||||||
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
|
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
|
||||||
* corresponding to pindexNew, to bypass loading it again from disk.
|
* corresponding to pindexNew, to bypass loading it again from disk.
|
||||||
*/
|
*/
|
||||||
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock, std::list<CTransaction> &txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int> > &txChanged)
|
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock, std::list<CTransaction> &txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>> &txChanged)
|
||||||
{
|
{
|
||||||
assert(pindexNew->pprev == chainActive.Tip());
|
assert(pindexNew->pprev == chainActive.Tip());
|
||||||
// Read block from disk.
|
// Read block from disk.
|
||||||
@ -2829,7 +2829,7 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
|||||||
UpdateTip(pindexNew, chainparams);
|
UpdateTip(pindexNew, chainparams);
|
||||||
|
|
||||||
for(unsigned int i=0; i < pblock->vtx.size(); i++)
|
for(unsigned int i=0; i < pblock->vtx.size(); i++)
|
||||||
txChanged.push_back(std::make_tuple(pblock->vtx[i], pindexNew, i));
|
txChanged.emplace_back(pblock->vtx[i], pindexNew, i);
|
||||||
|
|
||||||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
||||||
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
||||||
@ -2911,7 +2911,7 @@ static void PruneBlockIndexCandidates() {
|
|||||||
* Try to make some progress towards making pindexMostWork the active block.
|
* Try to make some progress towards making pindexMostWork the active block.
|
||||||
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
||||||
*/
|
*/
|
||||||
static bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const CBlock* pblock, bool& fInvalidFound, std::list<CTransaction>& txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int> >& txChanged)
|
static bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const CBlock* pblock, bool& fInvalidFound, std::list<CTransaction>& txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>>& txChanged)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||||
@ -3013,14 +3013,17 @@ static void NotifyHeaderTip() {
|
|||||||
bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, const CBlock *pblock, CConnman* connman) {
|
bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, const CBlock *pblock, CConnman* connman) {
|
||||||
CBlockIndex *pindexMostWork = NULL;
|
CBlockIndex *pindexMostWork = NULL;
|
||||||
CBlockIndex *pindexNewTip = NULL;
|
CBlockIndex *pindexNewTip = NULL;
|
||||||
|
std::vector<std::tuple<CTransaction,CBlockIndex*,int>> txChanged;
|
||||||
|
if (pblock)
|
||||||
|
txChanged.reserve(pblock->vtx.size());
|
||||||
do {
|
do {
|
||||||
|
txChanged.clear();
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
if (ShutdownRequested())
|
if (ShutdownRequested())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const CBlockIndex *pindexFork;
|
const CBlockIndex *pindexFork;
|
||||||
std::list<CTransaction> txConflicted;
|
std::list<CTransaction> txConflicted;
|
||||||
std::vector<std::tuple<CTransaction,CBlockIndex*,int> > txChanged;
|
|
||||||
bool fInitialDownload;
|
bool fInitialDownload;
|
||||||
int nNewHeight;
|
int nNewHeight;
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user