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

wip: add uncleaned roots when we shrink away non-zero lamport accounts #2865

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jeffwashington
Copy link

Problem

monitor # zero lamport single ref accounts for better cleaning

Summary of Changes

Fixes #

Copy link

mergify bot commented Sep 6, 2024

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/web3.js (example)

Thank you for keeping the RPC clients in sync with the server API @jeffwashington.

Copy link

mergify bot commented Sep 6, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@jeffwashington
Copy link
Author

I think this shows the metrics from running this on mnb:
image


/// offsets to accounts that are zero lamport single ref stored in this storage.
/// These are still alive. But, shrink will be able to remove them.
zero_lamport_single_ref_offsets: RwLock<IntSet<usize>>,

Choose a reason for hiding this comment

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

Do we need to keep all the offsets here?
Is the count of the number of single-ref zeros in the storage enough?

@@ -4353,6 +4403,37 @@ impl AccountsDb {
);
}

pub(crate) fn zero_lamport_single_ref_found(&self, slot: Slot, offset: usize) {
if let Some(store) = self.storage.get_slot_storage_entry(slot) {
let mut zero_lamport_single_ref_offsets =

Choose a reason for hiding this comment

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

Can we move this logic one level up, i.e. after 'index.scan(...)`?

In index.scan(...), we keep a counter of how many single_ref_zeros.
After the index.scan(), we do the check below.

In this way, we don't need zero_lamport_single_ref_offsets: RwLock<IntSet> on account_storage at all?

Can we just keep the count, zero_lamport_single_ref_counts on account_storage instead, for the later usage in do_shrink_store()?

.adding_dead_slots_to_clean
.fetch_add(1, Ordering::Relaxed);
} else {
if Self::is_shrinking_productive(slot, &store)

Choose a reason for hiding this comment

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

nit: we can check if slot is already in self.shrink_candidate_slot here.
if it is already in, we can skip this if shrinking_productive check () ....

// should we also check for ref counts here?
if let Some((slot_alive, acct_info)) = slot_list.first() {
if acct_info.is_zero_lamport() && !acct_info.is_cached() {
self.zero_lamport_single_ref_found(
Copy link
Author

Choose a reason for hiding this comment

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

this hsould probably ALSO run when we are doing clean and we find a zero lamport account that has a single ref. This is a reason why the hashset may be necessary so we don't double-count it.

Copy link
Author

Choose a reason for hiding this comment

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

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.

2 participants