Patch validator from loading persisted program costs
This commit is contained in:
@ -104,12 +104,11 @@ impl CostUpdateService {
|
|||||||
|
|
||||||
fn service_loop(
|
fn service_loop(
|
||||||
exit: Arc<AtomicBool>,
|
exit: Arc<AtomicBool>,
|
||||||
blockstore: Arc<Blockstore>,
|
_blockstore: Arc<Blockstore>,
|
||||||
cost_model: Arc<RwLock<CostModel>>,
|
cost_model: Arc<RwLock<CostModel>>,
|
||||||
cost_update_receiver: CostUpdateReceiver,
|
cost_update_receiver: CostUpdateReceiver,
|
||||||
) {
|
) {
|
||||||
let mut cost_update_service_timing = CostUpdateServiceTiming::default();
|
let mut cost_update_service_timing = CostUpdateServiceTiming::default();
|
||||||
let mut dirty: bool;
|
|
||||||
let mut update_count: u64;
|
let mut update_count: u64;
|
||||||
let wait_timer = Duration::from_millis(100);
|
let wait_timer = Duration::from_millis(100);
|
||||||
|
|
||||||
@ -118,7 +117,6 @@ impl CostUpdateService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dirty = false;
|
|
||||||
update_count = 0_u64;
|
update_count = 0_u64;
|
||||||
let mut update_cost_model_time = Measure::start("update_cost_model_time");
|
let mut update_cost_model_time = Measure::start("update_cost_model_time");
|
||||||
for cost_update in cost_update_receiver.try_iter() {
|
for cost_update in cost_update_receiver.try_iter() {
|
||||||
@ -129,24 +127,14 @@ impl CostUpdateService {
|
|||||||
CostUpdate::ExecuteTiming {
|
CostUpdate::ExecuteTiming {
|
||||||
mut execute_timings,
|
mut execute_timings,
|
||||||
} => {
|
} => {
|
||||||
dirty |= Self::update_cost_model(&cost_model, &mut execute_timings);
|
Self::update_cost_model(&cost_model, &mut execute_timings);
|
||||||
update_count += 1;
|
update_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_cost_model_time.stop();
|
update_cost_model_time.stop();
|
||||||
|
|
||||||
let mut persist_cost_table_time = Measure::start("persist_cost_table_time");
|
cost_update_service_timing.update(update_count, update_cost_model_time.as_us(), 0);
|
||||||
if dirty {
|
|
||||||
Self::persist_cost_table(&blockstore, &cost_model);
|
|
||||||
}
|
|
||||||
persist_cost_table_time.stop();
|
|
||||||
|
|
||||||
cost_update_service_timing.update(
|
|
||||||
update_count,
|
|
||||||
update_cost_model_time.as_us(),
|
|
||||||
persist_cost_table_time.as_us(),
|
|
||||||
);
|
|
||||||
|
|
||||||
thread::sleep(wait_timer);
|
thread::sleep(wait_timer);
|
||||||
}
|
}
|
||||||
@ -196,6 +184,7 @@ impl CostUpdateService {
|
|||||||
dirty
|
dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn persist_cost_table(blockstore: &Blockstore, cost_model: &RwLock<CostModel>) {
|
fn persist_cost_table(blockstore: &Blockstore, cost_model: &RwLock<CostModel>) {
|
||||||
let cost_model_read = cost_model.read().unwrap();
|
let cost_model_read = cost_model.read().unwrap();
|
||||||
let cost_table = cost_model_read.get_instruction_cost_table();
|
let cost_table = cost_model_read.get_instruction_cost_table();
|
||||||
|
@ -805,7 +805,8 @@ impl Validator {
|
|||||||
|
|
||||||
let vote_tracker = Arc::<VoteTracker>::default();
|
let vote_tracker = Arc::<VoteTracker>::default();
|
||||||
let mut cost_model = CostModel::default();
|
let mut cost_model = CostModel::default();
|
||||||
cost_model.initialize_cost_table(&blockstore.read_program_costs().unwrap());
|
// initialize cost model with built-in instruction costs only
|
||||||
|
cost_model.initialize_cost_table(&[]);
|
||||||
let cost_model = Arc::new(RwLock::new(cost_model));
|
let cost_model = Arc::new(RwLock::new(cost_model));
|
||||||
|
|
||||||
let (retransmit_slots_sender, retransmit_slots_receiver) = unbounded();
|
let (retransmit_slots_sender, retransmit_slots_receiver) = unbounded();
|
||||||
|
Reference in New Issue
Block a user