Skip to content

Commit

Permalink
[LOGGING] More logging for Application.cpp sweep.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottschurr committed Nov 3, 2023
1 parent bc322be commit 2b9c2de
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/ripple/app/ledger/InboundLedgers.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class InboundLedgers

virtual void
stop() = 0;

virtual std::size_t
cacheSize() = 0;
};

std::unique_ptr<InboundLedgers>
Expand Down
21 changes: 21 additions & 0 deletions src/ripple/app/ledger/LedgerReplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ class LedgerReplayer final
void
stop();

std::size_t
tasksSize() const
{
std::lock_guard<std::mutex> lock(mtx_);
return tasks_.size();
}

std::size_t
deltasSize() const
{
std::lock_guard<std::mutex> lock(mtx_);
return deltas_.size();
}

std::size_t
skipListsSize() const
{
std::lock_guard<std::mutex> lock(mtx_);
return skipLists_.size();
}

private:
mutable std::mutex mtx_;
std::vector<std::shared_ptr<LedgerReplayTask>> tasks_;
Expand Down
7 changes: 7 additions & 0 deletions src/ripple/app/ledger/impl/InboundLedgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
58 changes: 55 additions & 3 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
28 changes: 28 additions & 0 deletions src/ripple/consensus/Validations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/test/app/LedgerReplay_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ class MagicInboundLedgers : public InboundLedgers
{
}

virtual size_t
cacheSize() override
{
return 0;
}

LedgerMaster& ledgerSource;
LedgerMaster& ledgerSink;
InboundLedgersBehavior bhvr;
Expand Down

0 comments on commit 2b9c2de

Please sign in to comment.