Refactor squash timing report (#31041)
* typo * refactor squash timing report * address review comments
This commit is contained in:
parent
24a87f33a8
commit
684901879d
|
@ -168,7 +168,7 @@ use {
|
|||
collections::{HashMap, HashSet},
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt, mem,
|
||||
ops::{Deref, RangeInclusive},
|
||||
ops::{AddAssign, Deref, RangeInclusive},
|
||||
path::PathBuf,
|
||||
rc::Rc,
|
||||
sync::{
|
||||
|
@ -301,6 +301,7 @@ type RentCollectionCycleParams = (
|
|||
PartitionsPerCycle,
|
||||
);
|
||||
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct SquashTiming {
|
||||
pub squash_accounts_ms: u64,
|
||||
pub squash_accounts_cache_ms: u64,
|
||||
|
@ -310,6 +311,16 @@ pub struct SquashTiming {
|
|||
pub squash_cache_ms: u64,
|
||||
}
|
||||
|
||||
impl AddAssign for SquashTiming {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.squash_accounts_ms += rhs.squash_accounts_ms;
|
||||
self.squash_accounts_cache_ms += rhs.squash_accounts_cache_ms;
|
||||
self.squash_accounts_index_ms += rhs.squash_accounts_index_ms;
|
||||
self.squash_accounts_store_ms += rhs.squash_accounts_store_ms;
|
||||
self.squash_cache_ms += rhs.squash_cache_ms;
|
||||
}
|
||||
}
|
||||
|
||||
type EpochCount = u64;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -12991,3 +12991,29 @@ fn test_calculate_loaded_accounts_data_size_cost() {
|
|||
Bank::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_squash_timing_add_assign() {
|
||||
let mut t0 = SquashTiming::default();
|
||||
|
||||
let t1 = SquashTiming {
|
||||
squash_accounts_ms: 1,
|
||||
squash_accounts_cache_ms: 2,
|
||||
squash_accounts_index_ms: 3,
|
||||
squash_accounts_store_ms: 4,
|
||||
squash_cache_ms: 5,
|
||||
};
|
||||
|
||||
let expected = SquashTiming {
|
||||
squash_accounts_ms: 2,
|
||||
squash_accounts_cache_ms: 2 * 2,
|
||||
squash_accounts_index_ms: 3 * 2,
|
||||
squash_accounts_store_ms: 4 * 2,
|
||||
squash_cache_ms: 5 * 2,
|
||||
};
|
||||
|
||||
t0 += t1;
|
||||
t0 += t1;
|
||||
|
||||
assert!(t0 == expected);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use {
|
||||
crate::{
|
||||
accounts_background_service::{AbsRequestSender, SnapshotRequest, SnapshotRequestType},
|
||||
bank::Bank,
|
||||
bank::{Bank, SquashTiming},
|
||||
epoch_accounts_hash,
|
||||
snapshot_config::SnapshotConfig,
|
||||
},
|
||||
|
@ -48,11 +48,7 @@ struct SetRootMetrics {
|
|||
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
struct SetRootTimings {
|
||||
total_squash_cache_ms: i64,
|
||||
total_squash_accounts_ms: i64,
|
||||
total_squash_accounts_index_ms: i64,
|
||||
total_squash_accounts_cache_ms: i64,
|
||||
total_squash_accounts_store_ms: i64,
|
||||
total_squash_time: SquashTiming,
|
||||
total_snapshot_ms: i64,
|
||||
prune_non_rooted_ms: i64,
|
||||
drop_parent_banks_ms: i64,
|
||||
|
@ -275,11 +271,7 @@ impl BankForks {
|
|||
let parents = root_bank.parents();
|
||||
banks.extend(parents.iter());
|
||||
let total_parent_banks = banks.len();
|
||||
let mut total_squash_accounts_ms = 0;
|
||||
let mut total_squash_accounts_index_ms = 0;
|
||||
let mut total_squash_accounts_cache_ms = 0;
|
||||
let mut total_squash_accounts_store_ms = 0;
|
||||
let mut total_squash_cache_ms = 0;
|
||||
let mut squash_timing = SquashTiming::default();
|
||||
let mut total_snapshot_ms = 0;
|
||||
|
||||
// handle epoch accounts hash
|
||||
|
@ -305,12 +297,7 @@ impl BankForks {
|
|||
);
|
||||
|
||||
self.last_accounts_hash_slot = eah_bank.slot();
|
||||
let squash_timing = eah_bank.squash();
|
||||
total_squash_accounts_ms += squash_timing.squash_accounts_ms as i64;
|
||||
total_squash_accounts_index_ms += squash_timing.squash_accounts_index_ms as i64;
|
||||
total_squash_accounts_cache_ms += squash_timing.squash_accounts_cache_ms as i64;
|
||||
total_squash_accounts_store_ms += squash_timing.squash_accounts_store_ms as i64;
|
||||
total_squash_cache_ms += squash_timing.squash_cache_ms as i64;
|
||||
squash_timing += eah_bank.squash();
|
||||
is_root_bank_squashed = eah_bank.slot() == root;
|
||||
|
||||
eah_bank
|
||||
|
@ -334,7 +321,7 @@ impl BankForks {
|
|||
//
|
||||
// This is needed when a snapshot request occurs in a slot after an EAH request, and is
|
||||
// part of the same set of `banks` in a single `set_root()` invocation. While (very)
|
||||
// unlikely for a validator with defaut snapshot intervals (and accounts hash verifier
|
||||
// unlikely for a validator with default snapshot intervals (and accounts hash verifier
|
||||
// intervals), it *is* possible, and there are tests to exercise this possibility.
|
||||
if let Some(bank) = banks.iter().find(|bank| {
|
||||
bank.slot() > self.last_accounts_hash_slot
|
||||
|
@ -342,12 +329,8 @@ impl BankForks {
|
|||
}) {
|
||||
let bank_slot = bank.slot();
|
||||
self.last_accounts_hash_slot = bank_slot;
|
||||
let squash_timing = bank.squash();
|
||||
total_squash_accounts_ms += squash_timing.squash_accounts_ms as i64;
|
||||
total_squash_accounts_index_ms += squash_timing.squash_accounts_index_ms as i64;
|
||||
total_squash_accounts_cache_ms += squash_timing.squash_accounts_cache_ms as i64;
|
||||
total_squash_accounts_store_ms += squash_timing.squash_accounts_store_ms as i64;
|
||||
total_squash_cache_ms += squash_timing.squash_cache_ms as i64;
|
||||
squash_timing += bank.squash();
|
||||
|
||||
is_root_bank_squashed = bank_slot == root;
|
||||
|
||||
let mut snapshot_time = Measure::start("squash::snapshot_time");
|
||||
|
@ -381,12 +364,7 @@ impl BankForks {
|
|||
}
|
||||
|
||||
if !is_root_bank_squashed {
|
||||
let squash_timing = root_bank.squash();
|
||||
total_squash_accounts_ms += squash_timing.squash_accounts_ms as i64;
|
||||
total_squash_accounts_index_ms += squash_timing.squash_accounts_index_ms as i64;
|
||||
total_squash_accounts_cache_ms += squash_timing.squash_accounts_cache_ms as i64;
|
||||
total_squash_accounts_store_ms += squash_timing.squash_accounts_store_ms as i64;
|
||||
total_squash_cache_ms += squash_timing.squash_cache_ms as i64;
|
||||
squash_timing += root_bank.squash();
|
||||
}
|
||||
let new_tx_count = root_bank.transaction_count();
|
||||
let accounts_data_len = root_bank.load_accounts_data_size() as i64;
|
||||
|
@ -404,11 +382,7 @@ impl BankForks {
|
|||
removed_banks,
|
||||
SetRootMetrics {
|
||||
timings: SetRootTimings {
|
||||
total_squash_cache_ms,
|
||||
total_squash_accounts_ms,
|
||||
total_squash_accounts_index_ms,
|
||||
total_squash_accounts_cache_ms,
|
||||
total_squash_accounts_store_ms,
|
||||
total_squash_time: squash_timing,
|
||||
total_snapshot_ms,
|
||||
prune_non_rooted_ms: prune_time.as_ms() as i64,
|
||||
drop_parent_banks_ms: drop_parent_banks_time.as_ms() as i64,
|
||||
|
@ -461,27 +435,39 @@ impl BankForks {
|
|||
("total_banks", self.banks.len(), i64),
|
||||
(
|
||||
"total_squash_cache_ms",
|
||||
set_root_metrics.timings.total_squash_cache_ms,
|
||||
set_root_metrics.timings.total_squash_time.squash_cache_ms,
|
||||
i64
|
||||
),
|
||||
(
|
||||
"total_squash_accounts_ms",
|
||||
set_root_metrics.timings.total_squash_accounts_ms,
|
||||
set_root_metrics
|
||||
.timings
|
||||
.total_squash_time
|
||||
.squash_accounts_ms,
|
||||
i64
|
||||
),
|
||||
(
|
||||
"total_squash_accounts_index_ms",
|
||||
set_root_metrics.timings.total_squash_accounts_index_ms,
|
||||
set_root_metrics
|
||||
.timings
|
||||
.total_squash_time
|
||||
.squash_accounts_index_ms,
|
||||
i64
|
||||
),
|
||||
(
|
||||
"total_squash_accounts_cache_ms",
|
||||
set_root_metrics.timings.total_squash_accounts_cache_ms,
|
||||
set_root_metrics
|
||||
.timings
|
||||
.total_squash_time
|
||||
.squash_accounts_cache_ms,
|
||||
i64
|
||||
),
|
||||
(
|
||||
"total_squash_accounts_store_ms",
|
||||
set_root_metrics.timings.total_squash_accounts_store_ms,
|
||||
set_root_metrics
|
||||
.timings
|
||||
.total_squash_time
|
||||
.squash_accounts_store_ms,
|
||||
i64
|
||||
),
|
||||
(
|
||||
|
@ -512,7 +498,7 @@ impl BankForks {
|
|||
),
|
||||
(
|
||||
"program_cache_prune_ms",
|
||||
timing::duration_as_ms(&program_cache_prune_start.elapsed()) as usize,
|
||||
timing::duration_as_ms(&program_cache_prune_start.elapsed()),
|
||||
i64
|
||||
),
|
||||
("dropped_banks_len", set_root_metrics.dropped_banks_len, i64),
|
||||
|
|
Loading…
Reference in New Issue