SHAMap performance improvements (RIPD-434)

This reworks the way SHAMaps are stored, flushed, backed, and
traversed. Rather than storing the linkages in the SHAMap itself,
that information is now stored in the nodes. This makes
snapshotting much cheaper and also allows traverse work done on
behalf of one SHAMap to be used by other SHAMaps that share inner
nodes with that SHAMap.

When a SHAMap is modified, nodes are modified all the way up to the
root. This means that the modified nodes in a SHAMap can easily be
traversed for flushing. So they don't need to be separately tracked.

Summary
* Remove mTNByID
* Remove mDirtyNodes
* Much faster traverses
* Much Faster snapshots
* New algorithm for flushing
* New vistNodes/visitLeaves
* Avoid I/O if a map is unbacked
This commit is contained in:
David Schwartz
2014-07-31 16:38:58 -07:00
committed by Tom Ritchford
parent d26241de0e
commit fc560179e0
15 changed files with 889 additions and 1064 deletions

View File

@@ -57,14 +57,9 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
WriteLog (lsTRACE, Ledger)
<< "root account: " << startAccount->peekSLE ().getJson (0);
mAccountStateMap->armDirty ();
writeBack (lepCREATE, startAccount->getSLE ());
auto dirtyNodes = mAccountStateMap->disarmDirty();
mAccountStateMap->flushDirty (
*dirtyNodes, 256, hotACCOUNT_NODE, mLedgerSeq);
// TODO(tom): why 256?
mAccountStateMap->flushDirty (hotACCOUNT_NODE, mLedgerSeq);
initializeFees ();
}
@@ -243,16 +238,12 @@ Ledger::~Ledger ()
{
if (mTransactionMap)
{
logTimedDestroy <Ledger> (mTransactionMap,
"mTransactionMap with " +
std::to_string(mTransactionMap->size ()) + " items");
logTimedDestroy <Ledger> (mTransactionMap, "mTransactionMap");
}
if (mAccountStateMap)
{
logTimedDestroy <Ledger> (mAccountStateMap,
"mAccountStateMap with " +
std::to_string (mAccountStateMap->size ()) + " items");
logTimedDestroy <Ledger> (mAccountStateMap, "mAccountStateMap");
}
}