Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eviction cycle metrics #4144

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Conversation

SirTyson
Copy link
Contributor

Description

Resolves #4137

Adds additional metrics for eviction scans. Specifically, records the period of eviction scans in ledgers and the average amount of time it takes for an entry to get evicted after expiring.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

mBytesScannedForEviction,
mIncompleteBucketScans);
mBucketList->scanForEviction(
mApp, ltx, ledgerSeq, mEntriesEvicted, mBytesScannedForEviction,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make these metrics live in Bucketlist instead of passing them here? They don't seem to be used outside of Bucketlist anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the standard interface we use for all BucketList related metrics. The BucketList itself is a very light weight class (the only member is std::vector<BucketLevel> mLevels;). We could do this, but we would also have to change the BucketList constructor from BucketList() to BucketList(Application), which would be annoying for tests and a bit of a refactor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I flagged this because this function signature is getting a bit out of hand. Could we use a struct here?

if (metrics.has_value())
{
++metrics->numEntriesEvicted;
metrics->evictedEntriesAgeSum +=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to sum it up like this? we could use a histrogram (that would live inside Bucket), and update it every time we evict a single entry instead of manually aggregating evictions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually don't want a histogram and specifically want the per-cycle aggregation. A histogram for this metric is misleading. Given the nature of the eviction scan, entries evicted in level 8 will almost certainly be "older" than entries evicted in level 6. Within a given cycle, the number of evicted entries is very noisy from level to level. We want to abstract away that noise. We only care if the average age increases cycle-to-cycle. This would be pretty involved to graph in Grafana if we use a histogram, as the cycle length itself is variable. This seemed significantly easier, as it logs the only metric we actually care about (average cycle-to-cycle) in a way that is easy to analyze in Grafana.

{
// Evicted entry "age" is the delta between its liveUntilLedger and the
// ledger when the entry is actually evicted
uint64_t evictedEntriesAgeSum;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uninitialized variables

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also see my other comment regarding average age, I think you can remove this struct completely, and only keep evictionCycleStartLedger)

src/bucket/BucketList.cpp Show resolved Hide resolved
@marta-lokhova
Copy link
Contributor

r+ 407d836

@latobarita latobarita merged commit b12f66a into stellar:master Jan 22, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add metric for evicted entry liveUntilLedger
3 participants