- cost_tracker is data member of a bank, it can report metrics when bank is frozen (#20802)

- removed cost_tracker_stats and histogram
- move stats reporting outside of bank freeze
This commit is contained in:
Tao Zhu
2021-10-24 22:19:23 -05:00
committed by GitHub
parent aa13c90dd7
commit c2bfce90b3
13 changed files with 111 additions and 277 deletions

View File

@ -31,7 +31,6 @@ use solana_runtime::{
bank_forks::BankForks,
cost_model::CostModel,
cost_tracker::CostTracker,
cost_tracker_stats::CostTrackerStats,
hardened_unpack::{open_genesis_config, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE},
snapshot_archive_info::SnapshotArchiveInfoGetter,
snapshot_config::SnapshotConfig,
@ -773,7 +772,6 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
let mut cost_model = CostModel::default();
cost_model.initialize_cost_table(&blockstore.read_program_costs().unwrap());
let mut cost_tracker = CostTracker::default();
let mut cost_tracker_stats = CostTrackerStats::default();
for entry in entries {
num_transactions += entry.transactions.len();
@ -796,15 +794,11 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
&transaction,
true, // demote_program_write_locks
);
if cost_tracker
.try_add(&transaction, &tx_cost, &mut cost_tracker_stats)
.is_err()
{
let result = cost_tracker.try_add(&transaction, &tx_cost);
if result.is_err() {
println!(
"Slot: {}, CostModel rejected transaction {:?}, stats {:?}!",
slot,
transaction,
cost_tracker.get_stats()
"Slot: {}, CostModel rejected transaction {:?}, reason {:?}",
slot, transaction, result,
);
}
for (program_id, _instruction) in transaction.message().program_instructions_iter()
@ -815,12 +809,8 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
}
println!(
"Slot: {}, Entries: {}, Transactions: {}, Programs {}, {:?}",
slot,
num_entries,
num_transactions,
num_programs,
cost_tracker.get_stats()
"Slot: {}, Entries: {}, Transactions: {}, Programs {}",
slot, num_entries, num_transactions, num_programs,
);
println!(" Programs: {:?}", program_ids);