Move static treeNodeCache from SHAMap to the Application

These changes address two JIRA issues:

 - 291 unittest reported leaked objects
 - 292 SHAMap::treeNodeCache should be a dependency injection

The treeNodeCache was a static member of SHAMap.  It's now a
non-static member of the Application accessed through
getTreeNodeCache().  That addressed JIRA 291

The SHAMap constructors were adjusted so the treeNodeCache is
passed in to the constructor.  That addresses JIRA 292,  It required
that any code constructing a SHAMap needed to be edited to pass
the new parameter to the constructed SHAMap.

In the mean time, SHAMap was examined for dead/unused code and
interfaces that could be made private.  Dead and unused interfaces
were removed and methods that could be private were made private.
This commit is contained in:
Scott Schurr
2014-06-19 16:09:24 -07:00
committed by Vinnie Falco
parent 55222dc5d1
commit 837872c3f3
11 changed files with 139 additions and 151 deletions

View File

@@ -270,13 +270,16 @@ public:
{
if (hash.isZero ())
{
Application& app = getApp();
SHAMap::pointer empty = std::make_shared<SHAMap> (
smtTRANSACTION, std::ref (getApp().getFullBelowCache()));
smtTRANSACTION,
app.getFullBelowCache(),
app.getTreeNodeCache());
mapComplete (hash, empty, false);
return empty;
}
acquiring = std::make_shared<TransactionAcquire> (hash, std::ref (m_clock));
acquiring = std::make_shared<TransactionAcquire> (hash, m_clock);
startAcquiring (acquiring);
}
}
@@ -870,7 +873,7 @@ private:
Ledger::pointer newLCL
= std::make_shared<Ledger> (false
, std::ref (*mPreviousLedger));
, *mPreviousLedger);
// Set up to write SHAMap changes to our database,
// perform updates, extract changes
@@ -963,7 +966,7 @@ private:
getApp().getLedgerMaster().consensusBuilt (newLCL);
Ledger::pointer newOL = std::make_shared<Ledger>
(true, std::ref (*newLCL));
(true, *newLCL);
LedgerMaster::ScopedLockType sl
(getApp().getLedgerMaster ().peekMutex ());
@@ -981,8 +984,7 @@ private:
<< " not get in";
SerializerIterator sit (it.second->peekTransaction ());
SerializedTransaction::pointer txn
= std::make_shared<SerializedTransaction>
(std::ref (sit));
= std::make_shared<SerializedTransaction>(sit);
if (applyTransaction (engine, txn, newOL, true, false))
{
@@ -1263,8 +1265,7 @@ private:
#endif
SerializerIterator sit (item->peekSerializer ());
SerializedTransaction::pointer txn
= std::make_shared<SerializedTransaction>
(std::ref (sit));
= std::make_shared<SerializedTransaction>(sit);
if (applyTransaction (engine, txn,
applyLedger, openLgr, true) == resultRetry)

View File

@@ -41,9 +41,11 @@ Ledger::Ledger (const RippleAddress& masterID, std::uint64_t startAmount)
, mAccepted (false)
, mImmutable (false)
, mTransactionMap (std::make_shared <SHAMap> (smtTRANSACTION,
std::ref (getApp().getFullBelowCache())))
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
, mAccountStateMap (std::make_shared <SHAMap> (smtSTATE,
std::ref (getApp().getFullBelowCache())))
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
{
// special case: put coins in root account
auto startAccount = std::make_shared<AccountState> (masterID);
@@ -91,9 +93,12 @@ Ledger::Ledger (uint256 const& parentHash,
, mAccepted (false)
, mImmutable (true)
, mTransactionMap (std::make_shared <SHAMap> (
smtTRANSACTION, transHash, std::ref (getApp().getFullBelowCache())))
smtTRANSACTION, transHash,
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
, mAccountStateMap (std::make_shared <SHAMap> (smtSTATE, accountHash,
std::ref (getApp().getFullBelowCache())))
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
{
updateHash ();
loaded = true;
@@ -154,7 +159,8 @@ Ledger::Ledger (bool /* dummy */,
, mAccepted (false)
, mImmutable (false)
, mTransactionMap (std::make_shared <SHAMap> (smtTRANSACTION,
std::ref (getApp().getFullBelowCache())))
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
, mAccountStateMap (prevLedger.mAccountStateMap->snapShot (true))
{
prevLedger.updateHash ();
@@ -222,9 +228,11 @@ Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
mAccepted (false),
mImmutable (false),
mTransactionMap (std::make_shared <SHAMap> (
smtTRANSACTION, std::ref (getApp().getFullBelowCache()))),
smtTRANSACTION, getApp().getFullBelowCache(),
getApp().getTreeNodeCache())),
mAccountStateMap (std::make_shared <SHAMap> (
smtSTATE, std::ref (getApp().getFullBelowCache())))
smtSTATE, getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
{
initializeFees ();
}
@@ -304,10 +312,13 @@ void Ledger::setRaw (Serializer& s, bool hasPrefix)
if (mValidHash)
{
Application& app = getApp();
mTransactionMap = std::make_shared<SHAMap> (smtTRANSACTION, mTransHash,
std::ref (getApp().getFullBelowCache()));
app.getFullBelowCache(),
app.getTreeNodeCache());
mAccountStateMap = std::make_shared<SHAMap> (smtSTATE, mAccountHash,
std::ref (getApp().getFullBelowCache()));
app.getFullBelowCache(),
app.getTreeNodeCache());
}
}
@@ -476,13 +487,13 @@ SerializedTransaction::pointer Ledger::getSTransaction (
SerializerIterator sit (item->peekSerializer ());
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
return std::make_shared<SerializedTransaction> (std::ref (sit));
return std::make_shared<SerializedTransaction> (sit);
if (type == SHAMapTreeNode::tnTRANSACTION_MD)
{
Serializer sTxn (sit.getVL ());
SerializerIterator tSit (sTxn);
return std::make_shared<SerializedTransaction> (std::ref (tSit));
return std::make_shared<SerializedTransaction> (tSit);
}
return SerializedTransaction::pointer ();
@@ -497,7 +508,7 @@ SerializedTransaction::pointer Ledger::getSMTransaction (
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
{
txMeta.reset ();
return std::make_shared<SerializedTransaction> (std::ref (sit));
return std::make_shared<SerializedTransaction> (sit);
}
else if (type == SHAMapTreeNode::tnTRANSACTION_MD)
{

View File

@@ -30,7 +30,7 @@
#include <ripple/nodestore/Manager.h>
#include <ripple/overlay/make_Overlay.h>
#include <fstream>
namespace ripple {
// VFALCO TODO Clean this global up
@@ -147,6 +147,7 @@ public:
std::unique_ptr <NodeStore::Manager> m_nodeStoreManager;
NodeCache m_tempNodeCache;
TreeNodeCache m_treeNodeCache;
SLECache m_sleCache;
LocalCredentials m_localCredentials;
TransactionMaster m_txMaster;
@@ -230,6 +231,9 @@ public:
, m_tempNodeCache ("NodeCache", 16384, 90, get_seconds_clock (),
m_logs.journal("TaggedCache"))
, m_treeNodeCache ("TreeNodeCache", 65536, 60, get_seconds_clock (),
deprecatedLogs().journal("TaggedCache"))
, m_sleCache ("LedgerEntryCache", 4096, 120, get_seconds_clock (),
m_logs.journal("TaggedCache"))
@@ -421,6 +425,11 @@ public:
return m_tempNodeCache;
}
TreeNodeCache& getTreeNodeCache ()
{
return m_treeNodeCache;
}
NodeStore::Database& getNodeStore ()
{
return *m_nodeStore;
@@ -679,7 +688,8 @@ public:
m_ledgerMaster->tune (getConfig ().getSize (siLedgerSize), getConfig ().getSize (siLedgerAge));
m_sleCache.setTargetSize (getConfig ().getSize (siSLECacheSize));
m_sleCache.setTargetAge (getConfig ().getSize (siSLECacheAge));
SHAMap::setTreeCache (getConfig ().getSize (siTreeCacheSize), getConfig ().getSize (siTreeCacheAge));
m_treeNodeCache.setTargetSize (getConfig ().getSize (siTreeCacheSize));
m_treeNodeCache.setTargetAge (getConfig ().getSize (siTreeCacheAge));
//----------------------------------------------------------------------
@@ -1050,8 +1060,8 @@ public:
logTimedCall (m_journal.warning, "AcceptedLedger::sweep", __FILE__, __LINE__,
&AcceptedLedger::sweep);
logTimedCall (m_journal.warning, "SHAMap::sweep", __FILE__, __LINE__,
&SHAMap::sweep);
logTimedCall (m_journal.warning, "SHAMap::sweep", __FILE__, __LINE__,std::bind (
&TreeNodeCache::sweep, &m_treeNodeCache));
logTimedCall (m_journal.warning, "NetworkOPs::sweepFetchPack", __FILE__, __LINE__, std::bind (
&NetworkOPs::sweepFetchPack, m_networkOPs.get ()));

View File

@@ -53,8 +53,8 @@ class PathRequests;
class DatabaseCon;
typedef TaggedCache <uint256, Blob> NodeCache;
typedef TaggedCache <uint256, SerializedLedgerEntry> SLECache;
using NodeCache = TaggedCache <uint256, Blob>;
using SLECache = TaggedCache <uint256, SerializedLedgerEntry>;
class Application : public beast::PropertyStream::Source
{
@@ -87,6 +87,7 @@ public:
virtual RPC::Manager& getRPCManager () = 0;
virtual SiteFiles::Manager& getSiteFiles () = 0;
virtual NodeCache& getTempNodeCache () = 0;
virtual TreeNodeCache& getTreeNodeCache () = 0;
virtual SLECache& getSLECache () = 0;
virtual Validators::Manager& getValidators () = 0;
virtual AmendmentTable& getAmendmentTable() = 0;

View File

@@ -75,18 +75,21 @@ public:
{
using namespace RadixMap;
FullBelowCache fullBelowCache ("test.full_below",
get_seconds_clock ());
beast::manual_clock <std::chrono::seconds> clock; // manual advance clock
beast::Journal const j; // debug journal
FullBelowCache fullBelowCache ("test.full_below", clock);
TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j);
std::shared_ptr <Table> t1 (std::make_shared <Table> (
smtFREE, fullBelowCache));
smtFREE, fullBelowCache, treeNodeCache));
pass ();
// beast::Random r;
// add_random_items (tableItems, *t1, r);
// std::shared_ptr <Table> t2 (t1->snapShot (true));
//
//
// add_random_items (tableItemsExtra, *t1, r);
// add_random_items (tableItemsExtra, *t2, r);
@@ -102,16 +105,16 @@ public:
// try
// {
// TestFilter filter (map, beast::Journal());
//
//
// t3 = std::make_shared <Table> (smtFREE, t2->getHash (),
// fullBelowCache);
//
//
// expect (t3->fetchRoot (t2->getHash (), &filter), "unable to get root");
//
//
// // everything should be in the pack, no hashes should be needed
// std::vector <uint256> hashes = t3->getNeededHashes(1, &filter);
// expect (hashes.empty(), "missing hashes");
//
//
// expect (t3->getHash () == t2->getHash (), "root hashes do not match");
// expect (t3->deepCompare (*t2), "failed compare");
// }

View File

@@ -19,6 +19,7 @@
#include <ripple/nodestore/Database.h>
#include <beast/unit_test/suite.h>
#include <beast/chrono/manual_clock.h>
namespace ripple {
@@ -29,11 +30,16 @@ void SHAMap::DefaultMissingNodeHandler::operator() (std::uint32_t refNUm)
//------------------------------------------------------------------------------
SHAMap::SHAMap (SHAMapType t, FullBelowCache& fullBelowCache, std::uint32_t seq,
SHAMap::SHAMap (
SHAMapType t,
FullBelowCache& fullBelowCache,
TreeNodeCache& treeNodeCache,
std::uint32_t seq,
MissingNodeHandler missing_node_handler)
: m_fullBelowCache (fullBelowCache)
, mSeq (seq)
, mLedgerSeq (0)
, mTreeNodeCache (treeNodeCache)
, mState (smsModifying)
, mType (t)
, mTXMap (false)
@@ -48,11 +54,16 @@ SHAMap::SHAMap (SHAMapType t, FullBelowCache& fullBelowCache, std::uint32_t seq,
mTNByID.replace(root->getID(), root);
}
SHAMap::SHAMap (SHAMapType t, uint256 const& hash, FullBelowCache& fullBelowCache,
SHAMap::SHAMap (
SHAMapType t,
uint256 const& hash,
FullBelowCache& fullBelowCache,
TreeNodeCache& treeNodeCache,
MissingNodeHandler missing_node_handler)
: m_fullBelowCache (fullBelowCache)
, mSeq (1)
, mLedgerSeq (0)
, mTreeNodeCache (treeNodeCache)
, mState (smsSynching)
, mType (t)
, mTXMap (false)
@@ -66,11 +77,6 @@ SHAMap::SHAMap (SHAMapType t, uint256 const& hash, FullBelowCache& fullBelowCach
mTNByID.replace(root->getID(), root);
}
TaggedCache <uint256, SHAMapTreeNode>
SHAMap::treeNodeCache ("TreeNodeCache", 65536, 60,
get_seconds_clock (),
deprecatedLogs().journal("TaggedCache"));
SHAMap::~SHAMap ()
{
mState = smsInvalid;
@@ -116,7 +122,7 @@ std::size_t hash_value (const SHAMapNodeID& mn)
SHAMap::pointer SHAMap::snapShot (bool isMutable)
{
SHAMap::pointer ret = std::make_shared<SHAMap> (mType,
std::ref (m_fullBelowCache));
m_fullBelowCache, mTreeNodeCache);
SHAMap& newMap = *ret;
// Return a new SHAMap that is a snapshot of this one
@@ -346,7 +352,7 @@ SHAMapTreeNode* SHAMap::getNodePointerNT (const SHAMapNodeID& id, uint256 const&
if (filter->haveNode (id, hash, nodeData))
{
SHAMapTreeNode::pointer node = std::make_shared<SHAMapTreeNode> (
std::cref (id), std::cref (nodeData), 0, snfPREFIX, std::cref (hash), true);
id, nodeData, 0, snfPREFIX, hash, true);
canonicalize (hash, node);
// Canonicalize the node with mTNByID to make sure all threads gets the same node
@@ -944,7 +950,7 @@ SHAMapTreeNode* SHAMap::getNodeAsync (
if (filter->haveNode (id, hash, nodeData))
{
ptr = std::make_shared <SHAMapTreeNode> (
std::cref (id), std::cref (nodeData), 0, snfPREFIX, std::cref (hash), true);
id, nodeData, 0, snfPREFIX, hash, true);
filter->gotNode (true, id, hash, nodeData, ptr->getType ());
}
}
@@ -1083,7 +1089,7 @@ bool SHAMap::fetchRoot (uint256 const& hash, SHAMapSyncFilter* filter)
}
SHAMapTreeNode::pointer newRoot = fetchNodeExternalNT(SHAMapNodeID(), hash);
if (newRoot)
{
root = newRoot;
@@ -1302,7 +1308,7 @@ void SHAMap::dump (bool hash)
SHAMapTreeNode::pointer SHAMap::getCache (uint256 const& hash, SHAMapNodeID const& id)
{
SHAMapTreeNode::pointer ret = treeNodeCache.fetch (hash);
SHAMapTreeNode::pointer ret = mTreeNodeCache.fetch (hash);
assert (!ret || !ret->getSeq());
if (ret && (ret->getID() != id))
@@ -1313,7 +1319,7 @@ SHAMapTreeNode::pointer SHAMap::getCache (uint256 const& hash, SHAMapNodeID cons
ret->setID(id);
// Future fetches are likely to use the "new" ID
treeNodeCache.canonicalize (hash, ret, true);
mTreeNodeCache.canonicalize (hash, ret, true);
assert (ret->getID() == id);
assert (ret->getNodeHash() == hash);
}
@@ -1327,7 +1333,7 @@ void SHAMap::canonicalize (uint256 const& hash, SHAMapTreeNode::pointer& node)
SHAMapNodeID id = node->getID();
treeNodeCache.canonicalize (hash, node);
mTreeNodeCache.canonicalize (hash, node);
if (id != node->getID())
{
@@ -1336,7 +1342,7 @@ void SHAMap::canonicalize (uint256 const& hash, SHAMapTreeNode::pointer& node)
node->setID(id);
// Future fetches are likely to use the newer ID
treeNodeCache.canonicalize (hash, node, true);
mTreeNodeCache.canonicalize (hash, node, true);
assert (id == node->getID());
}
}
@@ -1362,8 +1368,11 @@ public:
{
testcase ("add/traverse");
FullBelowCache fullBelowCache ("test.full_below",
get_seconds_clock ());
beast::manual_clock <std::chrono::seconds> clock; // manual advance clock
beast::Journal const j; // debug journal
FullBelowCache fullBelowCache ("test.full_below", clock);
TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j);
// h3 and h4 differ only in the leaf, same terminal node (level 19)
uint256 h1, h2, h3, h4, h5;
@@ -1373,7 +1382,7 @@ public:
h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
SHAMap sMap (smtFREE, fullBelowCache);
SHAMap sMap (smtFREE, fullBelowCache, treeNodeCache);
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
unexpected (!sMap.addItem (i2, true, false), "no add");

View File

@@ -89,7 +89,6 @@ enum SHAMapState
See https://en.wikipedia.org/wiki/Merkle_tree
*/
class SHAMap
// : public CountedObject <SHAMap>
{
private:
/** Function object which handles missing nodes. */
@@ -124,10 +123,18 @@ public:
public:
// build new map
explicit SHAMap (SHAMapType t, FullBelowCache& fullBelowCache,
std::uint32_t seq = 1, MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler());
SHAMap (
SHAMapType t,
FullBelowCache& fullBelowCache,
TreeNodeCache& treeNodeCache,
std::uint32_t seq = 1,
MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler());
SHAMap (SHAMapType t, uint256 const& hash, FullBelowCache& fullBelowCache,
SHAMap (
SHAMapType t,
uint256 const& hash,
FullBelowCache& fullBelowCache,
TreeNodeCache& treeNodeCache,
MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler());
~SHAMap ();
@@ -148,22 +155,17 @@ public:
mLedgerSeq = lseq;
}
bool hasNode (const SHAMapNodeID & id);
bool fetchRoot (uint256 const & hash, SHAMapSyncFilter * filter);
// normal hash access functions
bool hasItem (uint256 const & id);
bool delItem (uint256 const & id);
bool addItem (const SHAMapItem & i, bool isTransaction, bool hasMeta);
bool updateItem (const SHAMapItem & i, bool isTransaction, bool hasMeta);
uint256 getHash () const
{
return root->getNodeHash ();
}
uint256 getHash ()
{
return root->getNodeHash ();
}
// save a copy if you have a temporary anyway
bool updateGiveItem (SHAMapItem::ref, bool isTransaction, bool hasMeta);
@@ -203,10 +205,6 @@ public:
assert (mState != smsInvalid);
mState = smsImmutable;
}
bool isImmutable ()
{
return mState == smsImmutable;
}
bool isSynching () const
{
return (mState == smsFloating) || (mState == smsSynching);
@@ -215,10 +213,6 @@ public:
{
mState = smsSynching;
}
void setFloating ()
{
mState = smsFloating;
}
void clearSynching ()
{
mState = smsModifying;
@@ -234,78 +228,37 @@ public:
int armDirty ();
int flushDirty (DirtySet & dirtySet, int maxNodes, NodeObjectType t,
std::uint32_t seq);
std::uint32_t seq);
std::shared_ptr<DirtySet> disarmDirty ();
void setSeq (std::uint32_t seq)
{
mSeq = seq;
assert (seq != 0);
}
std::uint32_t getSeq ()
{
return mSeq;
}
// overloads for backed maps
SHAMapTreeNode::pointer fetchNodeExternal (const SHAMapNodeID & id, uint256 const & hash); // throws
SHAMapTreeNode::pointer fetchNodeExternalNT (const SHAMapNodeID & id, uint256 const & hash); // no throw
bool operator== (const SHAMap & s)
{
return getHash () == s.getHash ();
}
// trusted path operations - prove a particular node is in a particular ledger
std::list<Blob > getTrustedPath (uint256 const & index);
static Blob checkTrustedPath (uint256 const & ledgerHash, uint256 const & leafIndex,
const std::list<Blob >& path);
void walkMap (std::vector<SHAMapMissingNode>& missingNodes, int maxMissing);
bool getPath (uint256 const & index, std::vector< Blob >& nodes, SHANodeFormat format);
bool deepCompare (SHAMap & other);
virtual void dump (bool withHashes = false);
typedef std::pair <uint256, Blob> fetchPackEntry_t;
std::list<fetchPackEntry_t> getFetchPack (SHAMap * have, bool includeLeaves, int max);
void getFetchPack (SHAMap * have, bool includeLeaves, int max, std::function<void (const uint256&, const Blob&)>);
// VFALCO NOTE These static members should be moved into a
// new Application singleton class.
//
// tree node cache operations
static SHAMapTreeNode::pointer getCache (uint256 const& hash, SHAMapNodeID const& id);
static void canonicalize (uint256 const& hash, SHAMapTreeNode::pointer&);
static int getTreeNodeSize ()
{
return treeNodeCache.getCacheSize ();
}
static void sweep ()
{
treeNodeCache.sweep ();
}
static void setTreeCache (int size, int age)
{
treeNodeCache.setTargetSize (size);
treeNodeCache.setTargetAge (age);
}
void setTXMap ()
{
mTXMap = true;
}
typedef std::pair<uint256, SHAMapNodeID> TNIndex;
private:
static TaggedCache <uint256, SHAMapTreeNode> treeNodeCache;
// trusted path operations - prove a particular node is in a particular ledger
std::list<Blob > getTrustedPath (uint256 const & index);
SHAMapTreeNode::pointer fetchNodeExternal (const SHAMapNodeID & id,
uint256 const & hash); // throws
SHAMapTreeNode::pointer fetchNodeExternalNT (const SHAMapNodeID & id,
uint256 const & hash); // no throw
bool getPath (uint256 const & index, std::vector< Blob >& nodes, SHANodeFormat format);
void dump (bool withHashes = false);
// tree node cache operations
SHAMapTreeNode::pointer getCache (uint256 const& hash, SHAMapNodeID const& id);
void canonicalize (uint256 const& hash, SHAMapTreeNode::pointer&);
void dirtyUp (std::stack<SHAMapTreeNode::pointer>& stack, uint256 const & target, uint256 prevHash);
std::stack<SHAMapTreeNode::pointer> getStack (uint256 const & id, bool include_nonmatching_leaf);
@@ -352,6 +305,7 @@ private:
std::uint32_t mLedgerSeq; // sequence number of ledger this is part of
SyncUnorderedMapType< SHAMapNodeID, SHAMapTreeNode::pointer, SHAMapNode_hash > mTNByID;
std::shared_ptr<DirtySet> mDirtyNodes;
TreeNodeCache& mTreeNodeCache;
SHAMapTreeNode::pointer root;
SHAMapState mState;
SHAMapType mType;

View File

@@ -634,15 +634,6 @@ static void addFPtoList (std::list<SHAMap::fetchPackEntry_t>& list, const uint25
list.push_back (SHAMap::fetchPackEntry_t (hash, blob));
}
std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max)
{
std::list<fetchPackEntry_t> ret;
getFetchPack (have, includeLeaves, max,
std::bind (addFPtoList, std::ref (ret),
std::placeholders::_1, std::placeholders::_2));
return ret;
}
void SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max,
std::function<void (const uint256&, const Blob&)> func)
{
@@ -811,11 +802,14 @@ public:
RAND_pseudo_bytes (reinterpret_cast<unsigned char*> (&seed), sizeof (seed));
srand (seed);
FullBelowCache fullBelowCache ("test.full_below",
get_seconds_clock ());
beast::manual_clock <std::chrono::seconds> clock; // manual advance clock
beast::Journal const j; // debug journal
SHAMap source (smtFREE, fullBelowCache);
SHAMap destination (smtFREE, fullBelowCache);
FullBelowCache fullBelowCache ("test.full_below", clock);
TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j);
SHAMap source (smtFREE, fullBelowCache, treeNodeCache);
SHAMap destination (smtFREE, fullBelowCache, treeNodeCache);
int items = 10000;
for (int i = 0; i < items; ++i)
@@ -853,6 +847,7 @@ public:
do
{
++clock;
++passes;
hashes.clear ();

View File

@@ -196,6 +196,8 @@ private:
bool updateHash ();
};
using TreeNodeCache = TaggedCache <uint256, SHAMapTreeNode>;
} // ripple
#endif

View File

@@ -33,8 +33,9 @@ TransactionAcquire::TransactionAcquire (uint256 const& hash, clock_type& clock)
deprecatedLogs().journal("TransactionAcquire"))
, mHaveRoot (false)
{
Application& app = getApp();
mMap = std::make_shared<SHAMap> (smtTRANSACTION, hash,
std::ref (getApp().getFullBelowCache ()));
app.getFullBelowCache (), app.getTreeNodeCache());
mMap->setTXMap ();
}

View File

@@ -40,36 +40,37 @@ Json::Value doGetCounts (RPC::Context& context)
ret [it.first] = it.second;
}
int dbKB = getApp().getLedgerDB ()->getDB ()->getKBUsedAll ();
Application& app = getApp();
int dbKB = app.getLedgerDB ()->getDB ()->getKBUsedAll ();
if (dbKB > 0)
ret["dbKBTotal"] = dbKB;
dbKB = getApp().getLedgerDB ()->getDB ()->getKBUsedDB ();
dbKB = app.getLedgerDB ()->getDB ()->getKBUsedDB ();
if (dbKB > 0)
ret["dbKBLedger"] = dbKB;
dbKB = getApp().getTxnDB ()->getDB ()->getKBUsedDB ();
dbKB = app.getTxnDB ()->getDB ()->getKBUsedDB ();
if (dbKB > 0)
ret["dbKBTransaction"] = dbKB;
{
std::size_t c = getApp().getOPs().getLocalTxCount ();
std::size_t c = app.getOPs().getLocalTxCount ();
if (c > 0)
ret["local_txs"] = static_cast<Json::UInt> (c);
}
ret["write_load"] = getApp().getNodeStore ().getWriteLoad ();
ret["write_load"] = app.getNodeStore ().getWriteLoad ();
ret["SLE_hit_rate"] = getApp().getSLECache ().getHitRate ();
ret["node_hit_rate"] = getApp().getNodeStore ().getCacheHitRate ();
ret["ledger_hit_rate"] = getApp().getLedgerMaster ().getCacheHitRate ();
ret["SLE_hit_rate"] = app.getSLECache ().getHitRate ();
ret["node_hit_rate"] = app.getNodeStore ().getCacheHitRate ();
ret["ledger_hit_rate"] = app.getLedgerMaster ().getCacheHitRate ();
ret["AL_hit_rate"] = AcceptedLedger::getCacheHitRate ();
ret["fullbelow_size"] = int(getApp().getFullBelowCache().size());
ret["treenode_size"] = SHAMap::getTreeNodeSize ();
ret["fullbelow_size"] = static_cast<int>(app.getFullBelowCache().size());
ret["treenode_size"] = app.getTreeNodeCache().getCacheSize();
std::string uptime;
int s = UptimeTimer::getInstance ().getElapsedSeconds ();