Skip to content

Commit 05a4921

Browse files
authored
Tracks last cleaned slot in accounts background service (#6396)
1 parent 069872c commit 05a4921

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

runtime/src/accounts_background_service.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use {
3838
};
3939

4040
const INTERVAL_MS: u64 = 100;
41-
const CLEAN_INTERVAL_BLOCKS: u64 = 100;
41+
const CLEAN_INTERVAL_SLOTS: Slot = 100;
4242
const SHRINK_INTERVAL: Duration = Duration::from_secs(1);
4343

4444
pub type SnapshotRequestSender = Sender<SnapshotRequest>;
@@ -148,7 +148,7 @@ impl SnapshotRequestHandler {
148148
test_hash_calculation: bool,
149149
non_snapshot_time_us: u128,
150150
exit: &AtomicBool,
151-
) -> Option<Result<u64, SnapshotError>> {
151+
) -> Option<Result<Slot, SnapshotError>> {
152152
let (snapshot_request, num_outstanding_requests, num_re_enqueued_requests) =
153153
self.get_next_snapshot_request()?;
154154

@@ -273,7 +273,7 @@ impl SnapshotRequestHandler {
273273
snapshot_request: SnapshotRequest,
274274
accounts_package_kind: AccountsPackageKind,
275275
exit: &AtomicBool,
276-
) -> Result<u64, SnapshotError> {
276+
) -> Result<Slot, SnapshotError> {
277277
info!("handling snapshot request: {snapshot_request:?}, {accounts_package_kind:?}");
278278
let mut total_time = Measure::start("snapshot_request_receiver_total_time");
279279
let SnapshotRequest {
@@ -414,7 +414,7 @@ impl SnapshotRequestHandler {
414414
("non_snapshot_time_us", non_snapshot_time_us, i64),
415415
("shrink_ancient_time_us", shrink_ancient_time_us, i64),
416416
);
417-
Ok(snapshot_root_bank.block_height())
417+
Ok(snapshot_root_bank.slot())
418418
}
419419
}
420420

@@ -497,7 +497,7 @@ impl AbsRequestHandlers {
497497
test_hash_calculation: bool,
498498
non_snapshot_time_us: u128,
499499
exit: &AtomicBool,
500-
) -> Option<Result<u64, SnapshotError>> {
500+
) -> Option<Result<Slot, SnapshotError>> {
501501
self.snapshot_request_handler.handle_snapshot_requests(
502502
test_hash_calculation,
503503
non_snapshot_time_us,
@@ -520,7 +520,7 @@ impl AccountsBackgroundService {
520520
) -> Self {
521521
let is_running = Arc::new(AtomicBool::new(true));
522522
let stop = Arc::new(AtomicBool::new(false));
523-
let mut last_cleaned_block_height = 0;
523+
let mut last_cleaned_slot = 0;
524524
let mut removed_slots_count = 0;
525525
let mut total_remove_slots_time = 0;
526526
let t_background = Builder::new()
@@ -599,11 +599,11 @@ impl AccountsBackgroundService {
599599

600600
last_snapshot_end_time = Some(Instant::now());
601601
match snapshot_handle_result {
602-
Ok(snapshot_block_height) => {
602+
Ok(snapshot_slot) => {
603603
assert!(
604-
last_cleaned_block_height <= snapshot_block_height,
605-
"last cleaned block height: {last_cleaned_block_height}, \
606-
snapshot request block height: {snapshot_block_height}, \
604+
last_cleaned_slot <= snapshot_slot,
605+
"last cleaned slot: {last_cleaned_slot}, \
606+
snapshot request slot: {snapshot_slot}, \
607607
is startup verification complete: {}, \
608608
enqueued snapshot requests: {:?}",
609609
bank.is_startup_verification_complete(),
@@ -613,7 +613,7 @@ impl AccountsBackgroundService {
613613
.try_iter()
614614
.collect::<Vec<_>>(),
615615
);
616-
last_cleaned_block_height = snapshot_block_height;
616+
last_cleaned_slot = snapshot_slot;
617617
previous_shrink_time = Instant::now();
618618
}
619619
Err(err) => {
@@ -625,16 +625,16 @@ impl AccountsBackgroundService {
625625
break;
626626
}
627627
}
628-
} else if bank.block_height() - last_cleaned_block_height
629-
> (CLEAN_INTERVAL_BLOCKS + thread_rng().gen_range(0..10))
628+
} else if bank.slot() - last_cleaned_slot
629+
> (CLEAN_INTERVAL_SLOTS + thread_rng().gen_range(0..10))
630630
{
631631
// Note that the flush will do an internal clean of the
632632
// cache up to bank.slot(), so should be safe as long
633633
// as any later snapshots that are taken are of
634634
// slots >= bank.slot()
635635
bank.force_flush_accounts_cache();
636636
bank.clean_accounts();
637-
last_cleaned_block_height = bank.block_height();
637+
last_cleaned_slot = bank.slot();
638638
// Do not 'shrink' until *after* the startup verification is complete.
639639
// This is because startup verification needs to get the snapshot
640640
// storages *as they existed at startup* (to calculate the accounts

0 commit comments

Comments
 (0)