Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Optimize stale slot shrinking for previously cleaned roots (#10099)
Browse files Browse the repository at this point in the history
* Prioritize shrinking of previously cleaned roots

* measure time of stale slot shrinking

* Disable shrink for test

* shrink: budgeting, store count, force for snapshot

* Polish implementation and fix tests

* Fix ci..

* Clean up a bit

* Further polish implementation and fix/add tests

* Rebase fixes

* Remove unneeded Default for AccountStorageEntry

* Address review comments

* More cleanup

* More cleanup
  • Loading branch information
ryoqun authored Jun 12, 2020
1 parent 4f76139 commit dfe72d5
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 51 deletions.
8 changes: 6 additions & 2 deletions core/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ pub struct AccountsBackgroundService {
}

const INTERVAL_MS: u64 = 100;
const SHRUNKEN_ACCOUNT_PER_SEC: usize = 250;
const SHRUNKEN_ACCOUNT_PER_INTERVAL: usize =
SHRUNKEN_ACCOUNT_PER_SEC / (1000 / INTERVAL_MS as usize);

impl AccountsBackgroundService {
pub fn new(bank_forks: Arc<RwLock<BankForks>>, exit: &Arc<AtomicBool>) -> Self {
info!("AccountsBackgroundService active");
let exit = exit.clone();
let mut consumed_budget = 0;
let t_background = Builder::new()
.name("solana-accounts-background".to_string())
.spawn(move || loop {
Expand All @@ -30,8 +34,8 @@ impl AccountsBackgroundService {

bank.process_dead_slots();

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

sleep(Duration::from_millis(INTERVAL_MS));
})
Expand Down
Loading

0 comments on commit dfe72d5

Please sign in to comment.