diff --git a/src/ripple/app/ledger/InboundLedgers.h b/src/ripple/app/ledger/InboundLedgers.h index dca4a80c54b..b12760153e2 100644 --- a/src/ripple/app/ledger/InboundLedgers.h +++ b/src/ripple/app/ledger/InboundLedgers.h @@ -83,6 +83,9 @@ class InboundLedgers virtual void stop() = 0; + + virtual std::size_t + cacheSize() = 0; }; std::unique_ptr diff --git a/src/ripple/app/ledger/LedgerReplayer.h b/src/ripple/app/ledger/LedgerReplayer.h index 6866250485d..b06dd2cc858 100644 --- a/src/ripple/app/ledger/LedgerReplayer.h +++ b/src/ripple/app/ledger/LedgerReplayer.h @@ -125,6 +125,27 @@ class LedgerReplayer final void stop(); + std::size_t + tasksSize() const + { + std::lock_guard lock(mtx_); + return tasks_.size(); + } + + std::size_t + deltasSize() const + { + std::lock_guard lock(mtx_); + return deltas_.size(); + } + + std::size_t + skipListsSize() const + { + std::lock_guard lock(mtx_); + return skipLists_.size(); + } + private: mutable std::mutex mtx_; std::vector> tasks_; diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 7ee49b4547a..0bff434edbc 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -411,6 +411,13 @@ class InboundLedgersImp : public InboundLedgers mRecentFailures.clear(); } + std::size_t + cacheSize() override + { + ScopedLockType lock(mLock); + return mLedgers.size(); + } + private: clock_type& m_clock; diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 8086ba4abd2..10ed603d135 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -1148,16 +1148,68 @@ class ApplicationImp : public Application, public BasicApp << "; size after: " << getTempNodeCache().size(); } { - // Validations do not expose the size of their containers. + 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(); } { - // Inbound ledgers does not expose the size of their containers. + std::size_t const oldInboundLedgersSize = + getInboundLedgers().cacheSize(); + getInboundLedgers().sweep(); + + JLOG(m_journal.debug()) + << "InboundLedgers sweep. Size before: " + << oldInboundLedgersSize + << "; size after: " << getInboundLedgers().cacheSize(); } { - // LedgerReplayer does not expose the size of their containers. + 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 = diff --git a/src/ripple/consensus/Validations.h b/src/ripple/consensus/Validations.h index a9dbd5585e2..1bef76d961c 100644 --- a/src/ripple/consensus/Validations.h +++ b/src/ripple/consensus/Validations.h @@ -1142,6 +1142,34 @@ class Validations return laggards; } + + std::size_t + sizeOfCurrentCache() const + { + std::lock_guard lock{mutex_}; + return current_.size(); + } + + std::size_t + sizeOfSeqEnforcersCache() const + { + std::lock_guard lock{mutex_}; + return seqEnforcers_.size(); + } + + std::size_t + sizeOfByLedgerCache() const + { + std::lock_guard lock{mutex_}; + return byLedger_.size(); + } + + std::size_t + sizeOfBySequenceCache() const + { + std::lock_guard lock{mutex_}; + return bySequence_.size(); + } }; } // namespace ripple diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index b535739353b..41c9a71e9f6 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -173,6 +173,12 @@ class MagicInboundLedgers : public InboundLedgers { } + virtual size_t + cacheSize() override + { + return 0; + } + LedgerMaster& ledgerSource; LedgerMaster& ledgerSink; InboundLedgersBehavior bhvr;