Make account shrink configurable #17544 (backport #17778) (#18013)

* Make account shrink configurable #17544 (#17778)

1. Added both options for measuring space usage using total accounts usage and for individual store shrink ratio using an enum. Validator CLI options: --accounts-shrink-optimize-total-space and --accounts-shrink-ratio
2. Added code for selecting candidates based on total usage in a separate function select_candidates_by_total_usage
3. Added unit tests for the new functions added
4. The default implementations is kept at 0.8 shrink ratio with --accounts-shrink-optimize-total-space set to true

Fixes #17544

(cherry picked from commit 269d995832)

# Conflicts:
#	core/tests/snapshots.rs
#	ledger/src/bank_forks_utils.rs
#	runtime/src/accounts_db.rs
#	runtime/src/snapshot_utils.rs

* fix some merge errors

Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com>
Co-authored-by: Jeff Washington (jwash) <wash678@gmail.com>
This commit is contained in:
mergify[bot]
2021-06-17 17:32:03 +00:00
committed by GitHub
parent b472dac6b3
commit e9c234d89f
15 changed files with 404 additions and 17 deletions

View File

@@ -142,6 +142,7 @@ fn load_from_snapshot(
process_options.account_indexes.clone(),
process_options.accounts_db_caching_enabled,
process_options.limit_load_slot_count_from_snapshot,
process_options.shrink_ratio,
process_options.accounts_db_test_hash_calculation,
)
.expect("Load from snapshot failed");

View File

@@ -16,6 +16,7 @@ use solana_measure::measure::Measure;
use solana_metrics::{datapoint_error, inc_new_counter_debug};
use solana_rayon_threadlimit::get_thread_count;
use solana_runtime::{
accounts_db::AccountShrinkThreshold,
accounts_index::AccountSecondaryIndexes,
bank::{
Bank, ExecuteTimings, InnerInstructionsList, RentDebits, TransactionBalancesSet,
@@ -374,6 +375,7 @@ pub struct ProcessOptions {
pub limit_load_slot_count_from_snapshot: Option<usize>,
pub allow_dead_slots: bool,
pub accounts_db_test_hash_calculation: bool,
pub shrink_ratio: AccountShrinkThreshold,
}
pub fn process_blockstore(
@@ -401,6 +403,7 @@ pub fn process_blockstore(
Some(&crate::builtins::get(opts.bpf_jit)),
opts.account_indexes.clone(),
opts.accounts_db_caching_enabled,
opts.shrink_ratio,
false,
);
let bank0 = Arc::new(bank0);
@@ -3097,6 +3100,7 @@ pub mod tests {
None,
AccountSecondaryIndexes::default(),
false,
AccountShrinkThreshold::default(),
false,
);
*bank.epoch_schedule()