Skip to content
20 changes: 19 additions & 1 deletion mesh/crates/mesh-llm-host-runtime/src/mesh/announcements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,28 @@ impl Node {
serving_models.clear();
hosted_models.clear();
}
let advertised_model_throughput = self
let mut advertised_model_throughput = self
.routing_metrics
.advertisable_model_throughput(&hosted_models);
let now_unix_ms = current_time_unix_ms();
// Each hinted model also carries this node's calibrated prefill rate, so
// a router can cost the node cold, not only when it holds a cache hit.
{
let inventory = self
.cache_affinity_inventory
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
for hint in &mut advertised_model_throughput {
hint.prefill = inventory.model_prefill_measurement(&hint.model_name).map(
|(micros_per_token, observed_at)| crate::network::metrics::PrefillMeasurement {
micros_per_token,
observed_at_unix_ms: now_unix_ms.saturating_sub(
u64::try_from(observed_at.elapsed().as_millis()).unwrap_or(u64::MAX),
),
},
);
}
}
let cache_affinity = mesh_llm_membership::local_advertisement(
&self.cache_affinity_inventory,
self.endpoint.id().as_bytes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ pub(crate) fn test_apply_transitive_ann_refreshes_advertised_model_throughput()
avg_tokens_per_second_milli: 35_000,
throughput_samples: 4,
measurement: None,
prefill: None,
}];

apply_transitive_ann(
Expand Down Expand Up @@ -582,6 +583,7 @@ pub(crate) async fn test_add_peer_refreshes_advertised_model_throughput() {
avg_tokens_per_second_milli: 20_000,
throughput_samples: 2,
measurement: None,
prefill: None,
}];

node.add_peer(peer_id, addr.clone(), &ann, None).await;
Expand Down Expand Up @@ -614,6 +616,7 @@ pub(crate) async fn test_peer_throughput_hint_counts_only_while_fresh() {
avg_tokens_per_second_milli: 30_000,
throughput_samples: 5,
measurement,
prefill: None,
};
let measured = |age_ms: u64| {
Some(ThroughputMeasurement {
Expand Down
Loading
Loading