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

Introduce background stale AppendVec shrink mechanism #9219

Merged
merged 13 commits into from
Apr 6, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,36 @@ use std::sync::{
use std::thread::{self, sleep, Builder, JoinHandle};
use std::time::Duration;

pub struct AccountsCleanupService {
t_cleanup: JoinHandle<()>,
pub struct AccountsBackgroundService {
t_background: JoinHandle<()>,
}

impl AccountsCleanupService {
const INTERVAL_MS: u64 = 100;

impl AccountsBackgroundService {
pub fn new(bank_forks: Arc<RwLock<BankForks>>, exit: &Arc<AtomicBool>) -> Self {
info!("AccountsCleanupService active");
info!("AccountsBackgroundService active");
let exit = exit.clone();
let t_cleanup = Builder::new()
.name("solana-accounts-cleanup".to_string())
let t_background = Builder::new()
.name("solana-accounts-background".to_string())
.spawn(move || loop {
if exit.load(Ordering::Relaxed) {
break;
}
let bank = bank_forks.read().unwrap().working_bank();
bank.clean_dead_slots();
sleep(Duration::from_millis(100));

bank.process_dead_slots();

// Currently, given INTERVAL_MS, we process 1 slot/100 ms
bank.process_stale_slot();

sleep(Duration::from_millis(INTERVAL_MS));
})
.unwrap();
Self { t_cleanup }
Self { t_background }
}

pub fn join(self) -> thread::Result<()> {
self.t_cleanup.join()
self.t_background.join()
}
}
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! command-line tools to spin up validators and a Rust library
//!

pub mod accounts_cleanup_service;
pub mod accounts_background_service;
pub mod accounts_hash_verifier;
pub mod banking_stage;
pub mod broadcast_stage;
Expand Down
6 changes: 3 additions & 3 deletions core/src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! validation pipeline in software.

use crate::{
accounts_cleanup_service::AccountsCleanupService,
accounts_background_service::AccountsBackgroundService,
accounts_hash_verifier::AccountsHashVerifier,
broadcast_stage::RetransmitSlotsSender,
cluster_info::ClusterInfo,
Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct Tvu {
retransmit_stage: RetransmitStage,
replay_stage: ReplayStage,
ledger_cleanup_service: Option<LedgerCleanupService>,
accounts_cleanup_service: AccountsCleanupService,
accounts_cleanup_service: AccountsBackgroundService,
storage_stage: StorageStage,
accounts_hash_verifier: AccountsHashVerifier,
}
Expand Down Expand Up @@ -211,7 +211,7 @@ impl Tvu {
)
});

let accounts_cleanup_service = AccountsCleanupService::new(bank_forks.clone(), &exit);
let accounts_cleanup_service = AccountsBackgroundService::new(bank_forks.clone(), &exit);

let storage_stage = StorageStage::new(
storage_state,
Expand Down
Loading