Overview: world speed (ticks per second) from the server's own timing report

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-09-30 22:53:16 +05:00
1 parent b03bc6de28
commit b4b1260099
10 files changed
+173 -2

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ export {};
if(cmd==="preview_preset"){const a=args;const sc=a.scope==="server"?serverSchema:botsSchema;const pr=(a.scope==="server"?serverPresets:botsPresets).presets as any[];const p=pr.find(x=>x.id===a.preset)??{id:a.preset??"defaults",title:"Recommended defaults",description:"Every setting returns to its default value."};const st=(sc.settings as any[]).filter(x=>x.type==="int"||x.type==="float"||x.type==="enum").slice(0,3);return {id:p.id,title:p.title,description:p.description,changes:st.map(x=>({key:x.key,title:x.title,from:x.default,to:x.type==="enum"?(x.options?.[1]?.value??x.default):(Number(x.default)||1)*2,dangerous:false}))};}
if(cmd==="companion_sizes") return {hardware:{cores:16,ram_gb:31,free_ram_gb:12},sizes:[{id:"small",title:"Small",bots:50,warning:null},{id:"medium",title:"Medium",bots:250,warning:null},{id:"large",title:"Large",bots:500,warning:"500 companions may need more CPU and memory than this computer has (8 cores, 16 GB)."}]};
if(cmd==="get_population") return null;
if(cmd==="get_performance") return running?{mean_ms:14,median_ms:15,p95_ms:24,p99_ms:30,max_ms:61,ticks_per_sec:71.4}:null;
if(cmd==="run_diagnostics") return {problems:2,checks:[{id:"files",title:"Server files",level:"ok",detail:"All expected server parts were found."},{id:"world",title:"World server",level:"warn",detail:"Not running."},{id:"disk",title:"Free disk space",level:"warn",detail:"Only 3 GB free; backups and updates need room."},{id:"exposure",title:"Private services",level:"ok",detail:"Database and server console are not reachable from the network."}]};
if(cmd==="plugin:event|listen") return 1;
if(cmd==="plugin:event|unlisten") return null;
+9
View File
@@ -497,6 +497,15 @@ const de: Partial<Record<keyof typeof en, string>> = {
"scan.label.companions": "CoA-Begleiter (Bots)",
"scan.label.client": "Spielclient",
"placeholder.soon": "Dieser Bereich entsteht in einer späteren Version.",
// Tick rate
"overview.tick": "Weltgeschwindigkeit",
"overview.tickUnit": "Ticks/s",
"overview.tickGood": "Flüssig",
"overview.tickBusy": "Ausgelastet",
"overview.tickLag": "Ruckelt",
"overview.tickDetail": "durchschnittlich {mean} ms pro Tick · 95 % unter {p95} ms · Spitze {max} ms",
"overview.tickHint": "Wie schnell der Weltserver läuft. Über 20 Ticks pro Sekunde fühlt sich das Spiel flüssig an, unter 10 ruckelt es.",
};
export default de;
+9
View File
@@ -497,6 +497,15 @@ const en = {
"scan.label.companions": "CoA Companions (bots)",
"scan.label.client": "Game client",
"placeholder.soon": "This section is being built in a later release.",
// Tick rate
"overview.tick": "World speed",
"overview.tickUnit": "ticks/s",
"overview.tickGood": "Smooth",
"overview.tickBusy": "Busy",
"overview.tickLag": "Lagging",
"overview.tickDetail": "average {mean} ms per tick · 95% under {p95} ms · peak {max} ms",
"overview.tickHint": "How fast the world server runs. Above 20 ticks per second the game feels smooth; below 10 it lags.",
} as const;
export default en;
+9
View File
@@ -497,6 +497,15 @@ const es: Partial<Record<keyof typeof en, string>> = {
"scan.label.companions": "Compañeros de CoA (bots)",
"scan.label.client": "Cliente del juego",
"placeholder.soon": "Esta sección se está desarrollando para una versión posterior.",
// Tick rate
"overview.tick": "Velocidad del mundo",
"overview.tickUnit": "ticks/s",
"overview.tickGood": "Fluido",
"overview.tickBusy": "Cargado",
"overview.tickLag": "Con retrasos",
"overview.tickDetail": "media de {mean} ms por tick · 95 % por debajo de {p95} ms · pico de {max} ms",
"overview.tickHint": "Qué tan rápido funciona el servidor del mundo. Por encima de 20 ticks por segundo el juego va fluido; por debajo de 10 se retrasa.",
};
export default es;
+9
View File
@@ -497,6 +497,15 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"scan.label.companions": "Compagnons CoA (bots)",
"scan.label.client": "Client du jeu",
"placeholder.soon": "Cette section sera développée dans une prochaine version.",
// Tick rate
"overview.tick": "Vitesse du monde",
"overview.tickUnit": "ticks/s",
"overview.tickGood": "Fluide",
"overview.tickBusy": "Chargé",
"overview.tickLag": "Saccadé",
"overview.tickDetail": "en moyenne {mean} ms par tick · 95 % sous {p95} ms · pic {max} ms",
"overview.tickHint": "La vitesse du serveur de monde. Au-dessus de 20 ticks par seconde le jeu est fluide, sous 10 il saccade.",
};
export default fr;
+9
View File
@@ -497,6 +497,15 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"scan.label.companions": "Компаньоны CoA (боты)",
"scan.label.client": "Клиент игры",
"placeholder.soon": "Этот раздел появится в одном из следующих выпусков.",
// Tick rate
"overview.tick": "Скорость мира",
"overview.tickUnit": "тиков/с",
"overview.tickGood": "Плавно",
"overview.tickBusy": "Нагружен",
"overview.tickLag": "Лагает",
"overview.tickDetail": "в среднем {mean} мс на тик · 95% быстрее {p95} мс · пик {max} мс",
"overview.tickHint": "Как быстро работает игровой сервер. Выше 20 тиков в секунду игра идёт плавно, ниже 10 — лагает.",
};
export default ru;
+10
View File
@@ -204,6 +204,15 @@ export interface Population {
bots_total: number;
}
export interface Performance {
mean_ms: number;
median_ms: number;
p95_ms: number;
p99_ms: number;
max_ms: number;
ticks_per_sec: number;
}
export interface CompanionSizes {
hardware: { cores: number; ram_gb: number; free_ram_gb: number };
sizes: { id: string; title: string; bots: number; warning: string | null }[];
@@ -278,6 +287,7 @@ export const api = {
invoke<{ txn: UpdateTxn }>("apply_update", { id, source: source ?? null, resolutions }),
rollbackUpdate: (id: string, txn: string) => invoke<UpdateTxn>("rollback_update", { id, txn }),
population: (id: string) => invoke<Population | null>("get_population", { id }),
performance: (id: string) => invoke<Performance | null>("get_performance", { id }),
companionSizes: () => invoke<CompanionSizes>("companion_sizes"),
addCompanions: (id: string, count: number) => invoke<{ spawned: string | null }>("add_companions", { id, count }),
clientInfo: (id: string) => invoke<ClientInfo | null>("client_info", { id }),
+45 -1
View File
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { Loader2 } from "lucide-react";
import { api, asUiError, type ClientInfo, type Human, type Population, type ServerSummary, type ServiceStatus, type StatusView } from "@/lib/api";
import { api, asUiError, type ClientInfo, type Human, type Performance, type Population, type ServerSummary, type ServiceStatus, type StatusView } from "@/lib/api";
import { cn, formatUptime } from "@/lib/utils";
import { useHuman, useT } from "@/i18n";
import { Button } from "@/components/ui/button";
@@ -9,6 +9,31 @@ import { Card } from "@/components/ui/card";
type Action = "starting" | "stopping" | "restarting" | null;
type Failure = { human: Human; technical: string };
/** World loop speed from the server's own timing report, with a simple smooth / busy / lagging verdict. */
function TickRate({ perf }: { perf: Performance }) {
const t = useT();
const level = perf.mean_ms <= 50 ? "good" : perf.mean_ms <= 100 ? "busy" : "lag";
const tone = { good: "text-ok bg-ok/15", busy: "text-warn bg-warn/15", lag: "text-bad bg-bad/15" }[level];
const bar = { good: "bg-ok", busy: "bg-warn", lag: "bg-bad" }[level];
const fill = Math.max(4, Math.min(100, Math.round(100 - perf.mean_ms)));
return (
<div className="mt-4 rounded-md border border-line bg-black/20 p-3" title={t("overview.tickHint")}>
<div className="flex items-center justify-between text-sm">
<span className="text-muted">{t("overview.tick")}</span>
<span className={`rounded px-2 py-0.5 text-xs font-medium ${tone}`}>{t(level === "good" ? "overview.tickGood" : level === "busy" ? "overview.tickBusy" : "overview.tickLag")}</span>
</div>
<div className="mt-1 flex items-baseline gap-2">
<span className="text-3xl font-semibold tabular-nums">{Math.round(perf.ticks_per_sec)}</span>
<span className="text-sm text-muted">{t("overview.tickUnit")}</span>
</div>
<div className="mt-2 h-1.5 overflow-hidden rounded-full bg-white/10" role="meter" aria-valuemin={0} aria-valuemax={100} aria-valuenow={fill} aria-label={t("overview.tick")}>
<div className={`h-full rounded-full transition-[width] duration-500 ${bar}`} style={{ width: `${fill}%` }} />
</div>
<p className="mt-2 text-xs text-muted">{t("overview.tickDetail", { mean: perf.mean_ms, p95: perf.p95_ms, max: perf.max_ms })}</p>
</div>
);
}
function Row({ label, s }: { label: string; s: ServiceStatus }) {
const t = useT();
const running = s.state === "running";
@@ -43,6 +68,7 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
const [pop, setPop] = useState<Population | null>(null);
const [client, setClient] = useState<ClientInfo | null>(null);
const [playing, setPlaying] = useState(false);
const [perf, setPerf] = useState<Performance | null>(null);
const alive = useRef(true);
const poll = useCallback(async () => {
@@ -58,6 +84,23 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
}
}, [server.id]);
// The tick rate comes from the server console (one short connection per reading), so it is read less often.
const worldUp = status?.observed.world.state === "running";
useEffect(() => {
if (!worldUp) {
setPerf(null);
return;
}
let live = true;
const read = () => void api.performance(server.id).then((p) => live && setPerf(p)).catch(() => {});
read();
const iv = setInterval(read, 10000);
return () => {
live = false;
clearInterval(iv);
};
}, [worldUp, server.id]);
useEffect(() => {
alive.current = true;
void api.clientInfo(server.id).then(setClient).catch(() => setClient(null));
@@ -170,6 +213,7 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
<dd className="mt-0.5 text-lg">{pop ? `${pop.players_online}` : "—"}{pop && pop.bots_online > 0 ? <span className="ml-2 text-sm text-muted">{t("overview.companions", { n: pop.bots_online })}</span> : null}</dd>
</div>
</dl>
{perf && <TickRate perf={perf} />}
<div className="mt-7 flex items-center gap-4">
{running ? (