Cost model uses compute_unit to replace microsecond as cost unit (#18934)
* wip - cost_update_services to log both us and cu for each instruction to determine possible ratio * replace microsecond with compute_unit as cost unit
This commit is contained in:
@@ -137,9 +137,12 @@ impl CostUpdateService {
|
||||
let mut dirty = false;
|
||||
{
|
||||
let mut cost_model_mutable = cost_model.write().unwrap();
|
||||
for (program_id, tining) in &execute_timings.details.per_program_timings {
|
||||
let cost = tining.accumulated_us / tining.count as u64;
|
||||
match cost_model_mutable.upsert_instruction_cost(program_id, cost) {
|
||||
for (program_id, timing) in &execute_timings.details.per_program_timings {
|
||||
if timing.count < 1 {
|
||||
continue;
|
||||
}
|
||||
let units = timing.accumulated_units / timing.count as u64;
|
||||
match cost_model_mutable.upsert_instruction_cost(program_id, units) {
|
||||
Ok(c) => {
|
||||
debug!(
|
||||
"after replayed into bank, instruction {:?} has averaged cost {}",
|
||||
@@ -220,7 +223,7 @@ mod tests {
|
||||
let accumulated_us: u64 = 1000;
|
||||
let accumulated_units: u64 = 100;
|
||||
let count: u32 = 10;
|
||||
expected_cost = accumulated_us / count as u64;
|
||||
expected_cost = accumulated_units / count as u64;
|
||||
|
||||
execute_timings.details.per_program_timings.insert(
|
||||
program_key_1,
|
||||
@@ -255,7 +258,7 @@ mod tests {
|
||||
let accumulated_units: u64 = 200;
|
||||
let count: u32 = 10;
|
||||
// to expect new cost is Average(new_value, existing_value)
|
||||
expected_cost = ((accumulated_us / count as u64) + expected_cost) / 2;
|
||||
expected_cost = ((accumulated_units / count as u64) + expected_cost) / 2;
|
||||
|
||||
execute_timings.details.per_program_timings.insert(
|
||||
program_key_1,
|
||||
|
||||
Reference in New Issue
Block a user