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

Evict persistent entries to Hot Archive #4585

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SirTyson
Copy link
Contributor

Description

Resolves #4395

This PR evicts persitent entries to the Hot Archive in p23. Specifically, the background eviction scan will delete expired persistent entries from the live bucketlist and add them to the hot archive. This change also includes eviction meta for these types.

Operations have not yet been modified to work with the evicted entries. This means that InvokeHostFunctionOp does not check the hot archive for the existence of archived entries, and RestoreFootprintOp will not be able to restore evicted entries. These changes will be added in a follow up PR.

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

releaseAssert(mData.filter);
releaseAssert(in.mData.filter);
if (!(*(mData.filter) == *(in.mData.filter)))
if (!mData.filter)
Copy link
Contributor

Choose a reason for hiding this comment

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

This got me scratching my head a bit, could it be simplified to

if (!mData.filter || !in.mData.filter) 
{
  return mData.filter == in.mData.filter;
}
return *mData.filter == *in.mData.filter;

(at least that's how I understand this)

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 checking that each index either:

  1. Doesn't have a filter pointer
  2. Has the same filter as the other index

What you provided won't work, as there are more checks later in the function for other index fields, so we can't return true after checking the filter. I've update this function though and added some comments to hopefully make it more clear.

releaseAssertOrThrow(isPersistentEntry(entry.data));
// Unfortunately, for legacy purposes, evictedTemporaryLedgerKeys is
// misnamed and stores all evicted keys, both temp and persistent.
mLedgerCloseMeta.v1().evictedTemporaryLedgerKeys.emplace_back(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still planning to rename this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I haven't pushed the XDR changes yet.


// Returns a pair of vectors representing entries evicted this ledger, where
// the first vector constains all deleted keys (TTL and temporary), and
// the second vector contains all archived keys (persistent and
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Archived entries.

// the second vector contains all archived keys (persistent and
// ContractCode). Note that when an entry is archived, its TTL key will be
// included in the deleted keys vector.
std::pair<std::vector<LedgerKey>, std::vector<LedgerEntry>>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I may be overly cautious here, but I feel like it would be safer to return a struct with named fields here. Even though the types are different, there is still some risk of confusion. At least it definitely would make the caller code easier to read.

@SirTyson SirTyson requested a review from dmkozh December 19, 2024 21:56
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.

Evict persistent entries to Hot Archive during eviction scans
2 participants