Skip to content

Commit

Permalink
Log cache size and difference after every TaggedCache sweep.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled committed Mar 5, 2024
1 parent 56f72e6 commit 859c676
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ripple/basics/TaggedCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class TaggedCache
clock_type::time_point const now(m_clock.now());
clock_type::time_point when_expire;

std::size_t beforeSize = 0, afterSize = 0;
auto const start = std::chrono::steady_clock::now();
{
std::lock_guard lock(m_mutex);
Expand Down Expand Up @@ -240,8 +241,10 @@ class TaggedCache
workers.reserve(m_cache.partitions());
std::atomic<int> allRemovals = 0;

std::size_t beforeSize = 0;
for (std::size_t p = 0; p < m_cache.partitions(); ++p)
{
beforeSize += m_cache.map()[p].size();
workers.push_back(sweepHelper(
when_expire,
now,
Expand All @@ -252,6 +255,8 @@ class TaggedCache
}
for (std::thread& worker : workers)
worker.join();
for (std::size_t p = 0; p < m_cache.partitions(); ++p)
afterSize += m_cache.map()[p].size();

m_cache_count -= allRemovals;
}
Expand All @@ -262,7 +267,10 @@ class TaggedCache
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start)
.count()
<< "ms";
<< "ms"
<< ". total before - after = deleted: "
<< beforeSize << " - " << afterSize << " = "
<< (beforeSize - afterSize);
}

bool
Expand Down

0 comments on commit 859c676

Please sign in to comment.