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

moves where the exit flag is checked #185

Closed
Closed
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
20 changes: 10 additions & 10 deletions runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,13 @@ impl AccountsBackgroundService {
let mut last_snapshot_end_time = None;

loop {
if exit.load(Ordering::Relaxed) {
break;
}
let start_time = Instant::now();

// Grab the current root bank
let bank = bank_forks.read().unwrap().root_bank();

if exit.load(Ordering::Relaxed) {
break;
break; // check the exit flag before any possibly long-running function
}
// Purge accounts of any dead slots
request_handlers
Expand All @@ -624,9 +621,6 @@ impl AccountsBackgroundService {
&mut removed_slots_count,
&mut total_remove_slots_time,
);
if exit.load(Ordering::Relaxed) {
break;
}

let non_snapshot_time = last_snapshot_end_time
.map(|last_snapshot_end_time: Instant| {
Expand Down Expand Up @@ -671,6 +665,9 @@ impl AccountsBackgroundService {
last_snapshot_end_time = Some(Instant::now());
}

if exit.load(Ordering::Relaxed) {
break; // check the exit flag before any possibly long-running function
}
// Note that the flush will do an internal clean of the
// cache up to bank.slot(), so should be safe as long
// as any later snapshots that are taken are of
Expand All @@ -695,20 +692,23 @@ impl AccountsBackgroundService {
if bank.block_height() - last_cleaned_block_height
> (CLEAN_INTERVAL_BLOCKS + thread_rng().gen_range(0..10))
{
if exit.load(Ordering::Relaxed) {
break; // check the exit flag before any possibly long-running function
}
// Note that the flush will do an internal clean of the
// cache up to bank.slot(), so should be safe as long
// as any later snapshots that are taken are of
// slots >= bank.slot()
bank.force_flush_accounts_cache();
if exit.load(Ordering::Relaxed) {
break;
break; // check the exit flag before any possibly long-running function
}
bank.clean_accounts(last_full_snapshot_slot);
last_cleaned_block_height = bank.block_height();
// See justification below for why we skip 'shrink' here.
if bank.is_startup_verification_complete() {
if exit.load(Ordering::Relaxed) {
break;
break; // check the exit flag before any possibly long-running function
}
bank.shrink_ancient_slots();
}
Expand All @@ -722,7 +722,7 @@ impl AccountsBackgroundService {
// was in the snapshot itself.
if bank.is_startup_verification_complete() {
if exit.load(Ordering::Relaxed) {
break;
break; // check the exit flag before any possibly long-running function
}
bank.shrink_candidate_slots();
}
Expand Down