Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions core/src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ use solana_rpc::{
};
use solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SendDroppedBankCallback,
SnapshotRequestHandler,
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
},
bank_forks::{BankForks, SnapshotConfig},
commitment::BlockCommitmentCache,
Expand Down Expand Up @@ -235,10 +234,18 @@ impl Tvu {
let (pruned_banks_sender, pruned_banks_receiver) = unbounded();

// Before replay starts, set the callbacks in each of the banks in BankForks
// Note after this callback is created, only the AccountsBackgroundService should be calling
// AccountsDb::purge_slot() to clean up dropped banks.
let callback = bank_forks
.read()
.unwrap()
.root_bank()
.rc
.accounts
.accounts_db
.create_drop_bank_callback(pruned_banks_sender);
for bank in bank_forks.read().unwrap().banks().values() {
bank.set_callback(Some(Box::new(SendDroppedBankCallback::new(
pruned_banks_sender.clone(),
))));
bank.set_callback(Some(Box::new(callback.clone())));
}

let accounts_background_request_sender = AbsRequestSender::new(snapshot_request_sender);
Expand Down
5 changes: 3 additions & 2 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,9 @@ impl Accounts {

/// Purge a slot if it is not a root
/// Root slots cannot be purged
pub fn purge_slot(&self, slot: Slot) {
self.accounts_db.purge_slot(slot);
/// `is_from_abs` is true if the caller is the AccountsBackgroundService
pub fn purge_slot(&self, slot: Slot, is_from_abs: bool) {
self.accounts_db.purge_slot(slot, is_from_abs);
}

/// Add a slot to root. Root slots cannot be purged
Expand Down
7 changes: 4 additions & 3 deletions runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,12 @@ impl AbsRequestHandler {
})
}

pub fn handle_pruned_banks(&self, bank: &Bank) -> usize {
/// `is_from_abs` is true if the caller is the AccountsBackgroundService
pub fn handle_pruned_banks(&self, bank: &Bank, is_from_abs: bool) -> usize {
let mut count = 0;
for pruned_slot in self.pruned_banks_receiver.try_iter() {
count += 1;
bank.rc.accounts.purge_slot(pruned_slot);
bank.rc.accounts.purge_slot(pruned_slot, is_from_abs);
}

count
Expand Down Expand Up @@ -393,7 +394,7 @@ impl AccountsBackgroundService {
total_remove_slots_time: &mut u64,
) {
let mut remove_slots_time = Measure::start("remove_slots_time");
*removed_slots_count += request_handler.handle_pruned_banks(&bank);
*removed_slots_count += request_handler.handle_pruned_banks(&bank, true);
remove_slots_time.stop();
*total_remove_slots_time += remove_slots_time.as_us();

Expand Down
Loading