mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve lifetime management of ledger objects (SLEs) to prevent runaway memory usage: (#4822)
* Add logging for Application.cpp sweep() * Improve lifetime management of ledger objects (`SLE`s) * Only store SLE digest in CachedView; get SLEs from CachedSLEs * Also force release of last ledger used for path finding if there are no path finding requests to process * Count more ST objects (derive from `CountedObject`) * Track CachedView stats in CountedObjects * Rename the CachedView counters * Fix the scope of the digest lookup lock Before this patch, if you asked "is it caching?" It was always caching.
This commit is contained in:
@@ -1065,20 +1065,172 @@ public:
|
||||
// VFALCO TODO fix the dependency inversion using an observer,
|
||||
// have listeners register for "onSweep ()" notification.
|
||||
|
||||
nodeFamily_.sweep();
|
||||
{
|
||||
std::shared_ptr<FullBelowCache const> const fullBelowCache =
|
||||
nodeFamily_.getFullBelowCache(0);
|
||||
|
||||
std::shared_ptr<TreeNodeCache const> const treeNodeCache =
|
||||
nodeFamily_.getTreeNodeCache(0);
|
||||
|
||||
std::size_t const oldFullBelowSize = fullBelowCache->size();
|
||||
std::size_t const oldTreeNodeSize = treeNodeCache->size();
|
||||
|
||||
nodeFamily_.sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "NodeFamily::FullBelowCache sweep. Size before: "
|
||||
<< oldFullBelowSize
|
||||
<< "; size after: " << fullBelowCache->size();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "NodeFamily::TreeNodeCache sweep. Size before: "
|
||||
<< oldTreeNodeSize << "; size after: " << treeNodeCache->size();
|
||||
}
|
||||
if (shardFamily_)
|
||||
{
|
||||
std::size_t const oldFullBelowSize =
|
||||
shardFamily_->getFullBelowCacheSize();
|
||||
std::size_t const oldTreeNodeSize =
|
||||
shardFamily_->getTreeNodeCacheSize().second;
|
||||
|
||||
shardFamily_->sweep();
|
||||
getMasterTransaction().sweep();
|
||||
getNodeStore().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "ShardFamily::FullBelowCache sweep. Size before: "
|
||||
<< oldFullBelowSize
|
||||
<< "; size after: " << shardFamily_->getFullBelowCacheSize();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "ShardFamily::TreeNodeCache sweep. Size before: "
|
||||
<< oldTreeNodeSize << "; size after: "
|
||||
<< shardFamily_->getTreeNodeCacheSize().second;
|
||||
}
|
||||
{
|
||||
TaggedCache<uint256, Transaction> const& masterTxCache =
|
||||
getMasterTransaction().getCache();
|
||||
|
||||
std::size_t const oldMasterTxSize = masterTxCache.size();
|
||||
|
||||
getMasterTransaction().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "MasterTransaction sweep. Size before: " << oldMasterTxSize
|
||||
<< "; size after: " << masterTxCache.size();
|
||||
}
|
||||
{
|
||||
// Does not appear to have an associated cache.
|
||||
getNodeStore().sweep();
|
||||
}
|
||||
if (shardStore_)
|
||||
{
|
||||
// Does not appear to have an associated cache.
|
||||
shardStore_->sweep();
|
||||
getLedgerMaster().sweep();
|
||||
getTempNodeCache().sweep();
|
||||
getValidations().expire(m_journal);
|
||||
getInboundLedgers().sweep();
|
||||
getLedgerReplayer().sweep();
|
||||
m_acceptedLedgerCache.sweep();
|
||||
cachedSLEs_.sweep();
|
||||
}
|
||||
{
|
||||
std::size_t const oldLedgerMasterCacheSize =
|
||||
getLedgerMaster().getFetchPackCacheSize();
|
||||
|
||||
getLedgerMaster().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "LedgerMaster sweep. Size before: "
|
||||
<< oldLedgerMasterCacheSize << "; size after: "
|
||||
<< getLedgerMaster().getFetchPackCacheSize();
|
||||
}
|
||||
{
|
||||
// NodeCache == TaggedCache<SHAMapHash, Blob>
|
||||
std::size_t const oldTempNodeCacheSize = getTempNodeCache().size();
|
||||
|
||||
getTempNodeCache().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "TempNodeCache sweep. Size before: " << oldTempNodeCacheSize
|
||||
<< "; size after: " << getTempNodeCache().size();
|
||||
}
|
||||
{
|
||||
std::size_t const oldCurrentCacheSize =
|
||||
getValidations().sizeOfCurrentCache();
|
||||
std::size_t const oldSizeSeqEnforcesSize =
|
||||
getValidations().sizeOfSeqEnforcersCache();
|
||||
std::size_t const oldByLedgerSize =
|
||||
getValidations().sizeOfByLedgerCache();
|
||||
std::size_t const oldBySequenceSize =
|
||||
getValidations().sizeOfBySequenceCache();
|
||||
|
||||
getValidations().expire(m_journal);
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "Validations Current expire. Size before: "
|
||||
<< oldCurrentCacheSize
|
||||
<< "; size after: " << getValidations().sizeOfCurrentCache();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "Validations SeqEnforcer expire. Size before: "
|
||||
<< oldSizeSeqEnforcesSize << "; size after: "
|
||||
<< getValidations().sizeOfSeqEnforcersCache();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "Validations ByLedger expire. Size before: "
|
||||
<< oldByLedgerSize
|
||||
<< "; size after: " << getValidations().sizeOfByLedgerCache();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "Validations BySequence expire. Size before: "
|
||||
<< oldBySequenceSize
|
||||
<< "; size after: " << getValidations().sizeOfBySequenceCache();
|
||||
}
|
||||
{
|
||||
std::size_t const oldInboundLedgersSize =
|
||||
getInboundLedgers().cacheSize();
|
||||
|
||||
getInboundLedgers().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "InboundLedgers sweep. Size before: "
|
||||
<< oldInboundLedgersSize
|
||||
<< "; size after: " << getInboundLedgers().cacheSize();
|
||||
}
|
||||
{
|
||||
size_t const oldTasksSize = getLedgerReplayer().tasksSize();
|
||||
size_t const oldDeltasSize = getLedgerReplayer().deltasSize();
|
||||
size_t const oldSkipListsSize = getLedgerReplayer().skipListsSize();
|
||||
|
||||
getLedgerReplayer().sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "LedgerReplayer tasks sweep. Size before: " << oldTasksSize
|
||||
<< "; size after: " << getLedgerReplayer().tasksSize();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "LedgerReplayer deltas sweep. Size before: "
|
||||
<< oldDeltasSize
|
||||
<< "; size after: " << getLedgerReplayer().deltasSize();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "LedgerReplayer skipLists sweep. Size before: "
|
||||
<< oldSkipListsSize
|
||||
<< "; size after: " << getLedgerReplayer().skipListsSize();
|
||||
}
|
||||
{
|
||||
std::size_t const oldAcceptedLedgerSize =
|
||||
m_acceptedLedgerCache.size();
|
||||
|
||||
m_acceptedLedgerCache.sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "AcceptedLedgerCache sweep. Size before: "
|
||||
<< oldAcceptedLedgerSize
|
||||
<< "; size after: " << m_acceptedLedgerCache.size();
|
||||
}
|
||||
{
|
||||
std::size_t const oldCachedSLEsSize = cachedSLEs_.size();
|
||||
|
||||
cachedSLEs_.sweep();
|
||||
|
||||
JLOG(m_journal.debug())
|
||||
<< "CachedSLEs sweep. Size before: " << oldCachedSLEsSize
|
||||
<< "; size after: " << cachedSLEs_.size();
|
||||
}
|
||||
|
||||
#ifdef RIPPLED_REPORTING
|
||||
if (auto pg = dynamic_cast<PostgresDatabase*>(&*mRelationalDatabase))
|
||||
|
||||
Reference in New Issue
Block a user