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

Adds CLI tool to print BucketList archival stats #4154

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

SirTyson
Copy link
Contributor

Description

Resolves #4138

Adds a CLI tool that logs some state archival related metrics from the BucketList. Specifically, the tool logs the amount of bytes currently consumed by temporary entries. It divides the temporary entries into three categories: live, expired but no evicted, and evicted.

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

Copy link
Contributor

@marta-lokhova marta-lokhova left a comment

Choose a reason for hiding this comment

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

Thanks, this looks like a really helpful command! Left a few questions

std::map<LedgerKey, LedgerEntry>
BucketManagerImpl::loadCompleteLedgerState(HistoryArchiveState const& has)
static std::vector<std::pair<Hash, std::string>>
getBucketHashes(HistoryArchiveState const& has)
Copy link
Contributor

Choose a reason for hiding this comment

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

this functionality seems redudant: can we re-purpose HistoryArchiveState::allBuckets to avoid duplication?

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 can't use that here, since HistoryArchiveState::allBuckets includes future bucket hashes and returns the bucket hashes sorted lexicographically by hash instead of in BucketList order. This was helpful though, I realized we were iterating through the BucketList in reverse order instead of in order. I've removed the getBucketHashes function since loadCompleteLedgerState and dumpStateArchivalStatistics iterate the BubkcetList in different directions.

@@ -84,6 +84,7 @@ Command options can only by placed after command.
See more examples in [ledger_query_examples.md](ledger_query_examples.md).

* **dump-xdr <FILE-NAME>**: Dumps the given XDR file and then exits.
* **dump-archival-stats**: Logs state archival statistics about the BucketList and then exits.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the exit comment a bit redundant since it's the default behavior for offline commands

// Logs state archival statistics, such as the number of expired entries
// currently in the BucketList, number of bytes of evicted entries, etc.
virtual void
dumpStateArchivalStatistics(HistoryArchiveState const& has) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't seem like this function belongs to the BucketManager interface as it shouldn't rely on state (so probably should be a free util function instead)

Copy link
Contributor

Choose a reason for hiding this comment

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

(i think StateArchivalMetric should be moved elsewhere too)

@@ -535,14 +535,6 @@ mergeBucketList(Config cfg, std::string const& outputDir)
Application::pointer app = Application::create(clock, cfg, false);
app->getLedgerManager().loadLastKnownLedger(nullptr);
auto& lm = app->getLedgerManager();
{
Copy link
Contributor

Choose a reason for hiding this comment

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

just checking, did this get removed because it doesn't work correctly with BucketListDB? (which would be fixed in #4166)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've reverted this after rebasing.


CLOG_INFO(Bucket, "BucketList total bytes: {}", blSize);
CLOG_INFO(Bucket,
"Live Temporary Entries: Non-shadows {} bytes ({}%), Shadowed {} "
Copy link
Contributor

Choose a reason for hiding this comment

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

regarding terminology, do you think we could move away from shadows and maybe call these entries newest vs non-newest (or something like that)? older protocols use the term shadows to refer to something else, and while current protocol doesn't have shadows anymore, we still need to support replay of older buckets in the codebase, so it would be nice to avoid any confusion here.

// *BytesNoShadow == bytes consumed only by newest version of BucketEntry
// *BytesShadows == bytes consumed only by shadows, does not count newest
// version of BucketEntry
// live -> liveUntilLedger > ledgerSeq
Copy link
Contributor

Choose a reason for hiding this comment

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

>=?

if (iter == map.end())
{
StateArchivalMetric metric;
metric.le =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can get pretty expensive memory-wise if we're dealing with a production bucketlist with a large number of temp entries (in order of GBs). Perhaps we should only store the size and expiration ledger of LEs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should also keep track of whether the newest version of a key is DEADENTRY or LIVEENTRY, but you're right, storing the whole LedgerEntry is unnecessary,

@SirTyson SirTyson force-pushed the archival-stats branch 3 times, most recently from 5e90e09 to 02c2edc Compare February 14, 2024 03:42
@marta-lokhova
Copy link
Contributor

LGTM, but looks like commit signing is broken in this PR

@SirTyson
Copy link
Contributor Author

LGTM, but looks like commit signing is broken in this PR

Fixed

@marta-lokhova
Copy link
Contributor

r+ 70d0f7c

@latobarita latobarita merged commit 18c3e80 into stellar:master Feb 16, 2024
14 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 command-line function to report eviction related metrics
3 participants