Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replay stage feed back program cost #17731

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a weight to occurrence count to be at same scale as age in micros
  • Loading branch information
tao-stones committed Jun 9, 2021
commit 526b1da2ed060f0ddcb76630fb78281919f45ed0
7 changes: 5 additions & 2 deletions core/src/execute_cost_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::{collections::HashMap, time::SystemTime};
// would be more efficient. PRUNE_RATIO defines the after prune table
// size will be original_size * PRUNE_RATIO.
const PRUNE_RATIO: f64 = 0.75;
// with 50_000 TPS as norm, weights occurrences '100' per microsec
const OCCURRENCES_WEIGHT: i64 = 100;

const DEFAULT_CAPACITY: usize = 1024;

#[derive(Debug)]
Expand Down Expand Up @@ -120,8 +123,8 @@ impl ExecuteCostTable {
.occurrences
.iter()
.map(|(key, (count, timestamp))| {
let weighted_age: f64 =
*count as f64 / (now.duration_since(*timestamp).unwrap().as_micros()) as f64;
let age = now.duration_since(*timestamp).unwrap().as_micros();
let weighted_age = *count as i64 * OCCURRENCES_WEIGHT + age as i64 * -1;
(weighted_age, *key)
})
.collect();
Expand Down