improve packed ancient test by sweeping (#32002)
This commit is contained in:
parent
3f13cd353e
commit
8937fd9bd6
|
@ -2988,11 +2988,26 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// combines ALL possible slots in `sorted_slots`
|
||||||
|
fn combine_ancient_slots_packed_for_tests(db: &AccountsDb, sorted_slots: Vec<Slot>) {
|
||||||
|
// combine normal append vec(s) into packed ancient append vec
|
||||||
|
let tuning = PackedAncientStorageTuning {
|
||||||
|
max_ancient_slots: 0,
|
||||||
|
// re-combine/shrink 55% of the data savings this pass
|
||||||
|
percent_of_alive_shrunk_data: 55,
|
||||||
|
ideal_storage_size: NonZeroU64::new(get_ancient_append_vec_capacity()).unwrap(),
|
||||||
|
can_randomly_shrink: CAN_RANDOMLY_SHRINK_FALSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut stats_sub = ShrinkStatsSub::default();
|
||||||
|
db.combine_ancient_slots_packed_internal(sorted_slots, tuning, &mut stats_sub);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_shrink_packed_ancient() {
|
fn test_shrink_packed_ancient() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
let num_normal_slots = 1;
|
for num_normal_slots in 1..4 {
|
||||||
// build an ancient append vec at slot 'ancient_slot'
|
// build an ancient append vec at slot 'ancient_slot'
|
||||||
let (db, ancient_slot) =
|
let (db, ancient_slot) =
|
||||||
get_one_packed_ancient_append_vec_and_others(true, num_normal_slots);
|
get_one_packed_ancient_append_vec_and_others(true, num_normal_slots);
|
||||||
|
@ -3004,10 +3019,9 @@ pub mod tests {
|
||||||
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// combine normal append vec(s) into existing ancient append vec
|
combine_ancient_slots_packed_for_tests(
|
||||||
db.combine_ancient_slots_packed(
|
&db,
|
||||||
(ancient_slot..=max_slot_inclusive).collect(),
|
(ancient_slot..=max_slot_inclusive).collect(),
|
||||||
CAN_RANDOMLY_SHRINK_FALSE,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
compare_all_accounts(
|
compare_all_accounts(
|
||||||
|
@ -3026,16 +3040,14 @@ pub mod tests {
|
||||||
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
db.combine_ancient_slots_packed(
|
combine_ancient_slots_packed_for_tests(&db, (next_slot..=max_slot_inclusive).collect());
|
||||||
(next_slot..=max_slot_inclusive).collect(),
|
|
||||||
CAN_RANDOMLY_SHRINK_FALSE,
|
|
||||||
);
|
|
||||||
|
|
||||||
compare_all_accounts(
|
compare_all_accounts(
|
||||||
&initial_accounts,
|
&initial_accounts,
|
||||||
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
&get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_addref_accounts_failed_to_shrink_ancient() {
|
fn test_addref_accounts_failed_to_shrink_ancient() {
|
||||||
|
|
Loading…
Reference in New Issue