feat: expose measured model loading phases in overview and chat (#1095)

This commit is contained in:
2026-11-17 13:26:49 +01:00
parent c88084d1b5
commit 939cc5f46d
5 changed files with 199 additions and 4 deletions

View File

@ -142,6 +142,7 @@ pub fn routes() -> Router<Arc<AppState>> {
.route("/ui/keys/entfernen", post(verwaltung::key_remove))
.route("/ui/chat", get(chat::page))
.route("/ui/chat/senden", post(chat::send))
.route("/ui/chat/status", get(chat::load_status))
.route("/ui/chat.js", get(chat::script))
.route("/ui/auswertung", get(auswertung::page))
.route("/ui/anfragen", get(requests_page))
@ -824,6 +825,29 @@ async fn overview_html(state: &AppState) -> String {
.map(|e| format!("<span>{}: {}</span> ", esc(&e.name), e.text()))
.collect();
let (hour_errors, hour_failures) = state.runtime.metrics.errors_last_hour();
let phases: String = state
.runtime
.scheduler_view()
.instances
.iter()
.map(|i| {
let phase = state.runtime.model_load_status(&i.model);
let elapsed = phase
.elapsed_ms
.map(|ms| format!(" · {:.1} s", ms as f64 / 1000.0))
.unwrap_or_default();
let last = phase
.last_load_ms
.map(|ms| format!(" · zuletzt gemessene Ladezeit {:.1} s", ms as f64 / 1000.0))
.unwrap_or_default();
let label = if i.state == "unloading" {
"wird entladen"
} else {
phase.phase
};
format!("<p>{}: {}{elapsed}{last}</p>", esc(&i.model), label)
})
.collect();
format!(
"<section class=\"card\" aria-label=\"Überwachung\">{engines}<p>Serverfehler letzte Stunde: {hour_errors} · Fehlstarts letzte Stunde: {hour_failures} · Wartend: {waiting}</p></section>\
<section class=\"kacheln\">\
@ -836,7 +860,7 @@ async fn overview_html(state: &AppState) -> String {
<div><span>Wartend</span><b>{waiting}</b></div>\
<div><span title=\"Unbenutzte Modelle, die für wartende Anfragen entladen wurden.\">Verdrängt</span><b>{evictions}</b></div></section>\
<section class=\"card\"><h2>GPUs</h2>{gpus}</section>\
<section class=\"card\"><h2>Geladene Modelle</h2>{inst}</section>\
<section class=\"card\"><h2>Modelle und Ladephasen</h2>{phases}{inst}</section>\
<p class=\"klein\">Zähler und Stundenfenster seit dem Start des Gateways (maximal letzte Stunde). Stand {now} UTC, wird alle 5 s erneuert.</p>",
uptime = uptime(state.started.elapsed().as_secs()),
req = t.requests,