remove persist_cost_table code

This commit is contained in:
Tao Zhu 2022-03-09 16:59:21 -06:00 committed by Trent Nelson
parent 86a97563b5
commit 607a98e9d0

View File

@ -22,19 +22,12 @@ pub struct CostUpdateServiceTiming {
last_print: u64, last_print: u64,
update_cost_model_count: u64, update_cost_model_count: u64,
update_cost_model_elapsed: u64, update_cost_model_elapsed: u64,
persist_cost_table_elapsed: u64,
} }
impl CostUpdateServiceTiming { impl CostUpdateServiceTiming {
fn update( fn update(&mut self, update_cost_model_count: u64, update_cost_model_elapsed: u64) {
&mut self,
update_cost_model_count: u64,
update_cost_model_elapsed: u64,
persist_cost_table_elapsed: u64,
) {
self.update_cost_model_count += update_cost_model_count; self.update_cost_model_count += update_cost_model_count;
self.update_cost_model_elapsed += update_cost_model_elapsed; self.update_cost_model_elapsed += update_cost_model_elapsed;
self.persist_cost_table_elapsed += persist_cost_table_elapsed;
let now = timestamp(); let now = timestamp();
let elapsed_ms = now - self.last_print; let elapsed_ms = now - self.last_print;
@ -52,11 +45,6 @@ impl CostUpdateServiceTiming {
self.update_cost_model_elapsed as i64, self.update_cost_model_elapsed as i64,
i64 i64
), ),
(
"persist_cost_table_elapsed",
self.persist_cost_table_elapsed as i64,
i64
),
); );
*self = CostUpdateServiceTiming::default(); *self = CostUpdateServiceTiming::default();
@ -134,7 +122,7 @@ impl CostUpdateService {
} }
update_cost_model_time.stop(); update_cost_model_time.stop();
cost_update_service_timing.update(update_count, update_cost_model_time.as_us(), 0); cost_update_service_timing.update(update_count, update_cost_model_time.as_us());
thread::sleep(wait_timer); thread::sleep(wait_timer);
} }
@ -183,28 +171,6 @@ impl CostUpdateService {
); );
dirty dirty
} }
#[allow(dead_code)]
fn persist_cost_table(blockstore: &Blockstore, cost_model: &RwLock<CostModel>) {
let cost_model_read = cost_model.read().unwrap();
let cost_table = cost_model_read.get_instruction_cost_table();
let db_records = blockstore.read_program_costs().expect("read programs");
// delete records from blockstore if they are no longer in cost_table
db_records.iter().for_each(|(pubkey, _)| {
if cost_table.get(pubkey).is_none() {
blockstore
.delete_program_cost(pubkey)
.expect("delete old program");
}
});
for (key, cost) in cost_table.iter() {
blockstore
.write_program_cost(key, cost)
.expect("persist program costs to blockstore");
}
}
} }
#[cfg(test)] #[cfg(test)]