feat: update ttft modeling and add cache affinity

This commit is contained in:
2026-04-15 19:08:10 +08:00
parent ff316c6873
commit a3f386c858
15 changed files with 1276 additions and 99 deletions

View File

@@ -1,6 +1,6 @@
use crate::cluster::meta_store::MetaStore;
use crate::instance::Instance;
use crate::router::{local_l0_scores, CandidateInfo, RouteDecision, Router};
use crate::router::{CandidateInfo, RouteDecision, Router};
use crate::trace::RequestRecord;
pub struct TtlAwareRouter {
@@ -22,11 +22,11 @@ impl Router for TtlAwareRouter {
&mut self,
req: &RequestRecord,
instances: &[Instance],
_meta: &MetaStore,
_now: f64,
meta: &MetaStore,
now: f64,
) -> RouteDecision {
let n = instances.len();
let scores = local_l0_scores(req, instances);
let scores = meta.score_prefix(&req.hash_ids, now, n);
let mut best = 0u32;
let mut best_key = (i64::MIN, f64::INFINITY); // maximize prefix, then minimize load
let mut candidates = Vec::with_capacity(n);
@@ -52,7 +52,7 @@ impl Router for TtlAwareRouter {
chosen: best,
probe_overhead_s: 0.0,
candidates,
reason: "max local L0 prefix, tie -> least loaded",
reason: "max meta_store prefix, tie -> least loaded",
}
}
}