- A/B with betterbench ab between two deployments of the same model, with verdict, confidence interval and caveats. - Sweeps vary one or two deployment settings, deploy, benchmark and remove each variant, and compare them in one table. - Every run records CPU, RAM, VRAM, GPU utilization and power. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
3.2 KiB
TypeScript
59 lines
3.2 KiB
TypeScript
import type { ResourceStats } from "@/lib/db/schema";
|
|
import { formatBytes } from "@/lib/format";
|
|
|
|
const cores = (v: number | null) => (v == null ? "—" : v.toFixed(v >= 10 ? 0 : 1));
|
|
|
|
function Cell({ label, value, note }: { label: string; value: string; note?: string }) {
|
|
return (
|
|
<div className="flex flex-col gap-0.5 rounded-lg bg-muted/50 px-3 py-2">
|
|
<span className="text-[11px] tracking-wide text-muted-foreground uppercase">{label}</span>
|
|
<span className="text-lg font-semibold">{value}</span>
|
|
{note && <span className="text-[11px] text-muted-foreground">{note}</span>}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Resource use sampled during a run: per deployment (A/B: both sides) and per GPU. */
|
|
export function BenchmarkResources({ stats, names }: { stats: ResourceStats; names?: { a: string; b?: string } }) {
|
|
if (stats.samples === 0 && stats.gpus.length === 0) return <p className="text-sm text-muted-foreground">No resource samples were recorded.</p>;
|
|
const multi = stats.containers.length > 1;
|
|
return (
|
|
<div className="flex flex-col gap-3">
|
|
{stats.containers.map((c) => (
|
|
<div key={c.side} className="flex flex-col gap-1.5">
|
|
{multi && <span className="text-xs font-medium">{c.side === "a" ? `A · ${names?.a ?? ""}` : `B · ${names?.b ?? ""}`}</span>}
|
|
<div className="grid gap-2 sm:grid-cols-3">
|
|
<Cell label="CPU, average" value={`${cores(c.cpuAvg)} cores`} note={`peak ${cores(c.cpuPeak)} cores`} />
|
|
<Cell
|
|
label="RAM, peak"
|
|
value={c.memPeakBytes != null ? formatBytes(c.memPeakBytes) : "—"}
|
|
note={`average ${c.memAvgBytes != null ? formatBytes(c.memAvgBytes) : "—"}${c.memLimitBytes ? ` · limit ${formatBytes(c.memLimitBytes)}` : ""}`}
|
|
/>
|
|
{c.memPeakBytes != null && c.memLimitBytes ? (
|
|
<Cell label="Of the limit" value={`${Math.round((c.memPeakBytes / c.memLimitBytes) * 100)}%`} note="peak RAM ÷ memory limit" />
|
|
) : (
|
|
<Cell label="Of the limit" value="—" note="no memory limit set" />
|
|
)}
|
|
</div>
|
|
</div>
|
|
))}
|
|
{stats.gpus.map((g) => (
|
|
<div key={g.index} className="flex flex-col gap-1.5">
|
|
<span className="text-xs font-medium">
|
|
GPU {g.index} · {g.name}
|
|
</span>
|
|
<div className="grid gap-2 sm:grid-cols-3">
|
|
<Cell label="VRAM, peak" value={formatBytes(g.vramPeakMb * 2 ** 20)} note={`of ${formatBytes(g.vramTotalMb * 2 ** 20)} · average ${formatBytes(g.vramAvgMb * 2 ** 20)}`} />
|
|
<Cell label="Utilization" value={`${Math.round(g.utilAvg)}%`} note={`average · peak ${Math.round(g.utilPeak)}%`} />
|
|
<Cell label="Power" value={g.powerAvgW != null ? `${Math.round(g.powerAvgW)} W` : "—"} note={g.powerPeakW != null ? `average · peak ${Math.round(g.powerPeakW)} W` : undefined} />
|
|
</div>
|
|
</div>
|
|
))}
|
|
<p className="text-[11px] text-muted-foreground">
|
|
Sampled every ~2 s over {stats.seconds} s ({stats.samples} samples). RAM is the container's usage without page cache, like <code>docker stats</code>; GPU
|
|
figures are for the whole GPU, so other work on it counts too.
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|