From f1097539b07ca07811dc322957a8e3efafb5b2ad Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 7 Oct 2024 18:44:46 -0600 Subject: [PATCH] Add encoder and decoder info for Nvidia GPUs --- web/src/types/stats.ts | 3 + web/src/views/system/GeneralMetrics.tsx | 131 ++++++++++++++++++++++-- 2 files changed, 128 insertions(+), 6 deletions(-) diff --git a/web/src/types/stats.ts b/web/src/types/stats.ts index a4f5605e1..2affdc1e8 100644 --- a/web/src/types/stats.ts +++ b/web/src/types/stats.ts @@ -41,6 +41,9 @@ export type ExtraProcessStats = { export type GpuStats = { gpu: string; mem: string; + enc?: string; + dec?: string; + pstate?: string; }; export type ServiceStats = { diff --git a/web/src/views/system/GeneralMetrics.tsx b/web/src/views/system/GeneralMetrics.tsx index 112c85684..2d63d9a83 100644 --- a/web/src/views/system/GeneralMetrics.tsx +++ b/web/src/views/system/GeneralMetrics.tsx @@ -14,6 +14,7 @@ import { Button } from "@/components/ui/button"; import VainfoDialog from "@/components/overlay/VainfoDialog"; import { Skeleton } from "@/components/ui/skeleton"; import { ThresholdBarGraph } from "@/components/graph/SystemGraph"; +import { cn } from "@/lib/utils"; type GeneralMetricsProps = { lastUpdated: number; @@ -108,7 +109,7 @@ export default function GeneralMetrics({ const detTempSeries = useMemo(() => { if (!statsHistory) { - return []; + return undefined; } if ( @@ -291,6 +292,74 @@ export default function GeneralMetrics({ return Object.values(series); }, [statsHistory]); + const gpuEncSeries = useMemo(() => { + if (!statsHistory) { + return []; + } + + const series: { + [key: string]: { name: string; data: { x: number; y: string }[] }; + } = {}; + let hasValidGpu = false; + + statsHistory.forEach((stats, statsIdx) => { + if (!stats) { + return; + } + + Object.entries(stats.gpu_usages || []).forEach(([key, stats]) => { + if (!(key in series)) { + series[key] = { name: key, data: [] }; + } + + if (stats.enc) { + hasValidGpu = true; + series[key].data.push({ x: statsIdx + 1, y: stats.enc.slice(0, -1) }); + } + }); + }); + + if (!hasValidGpu) { + return []; + } + + return Object.keys(series).length > 0 ? Object.values(series) : undefined; + }, [statsHistory]); + + const gpuDecSeries = useMemo(() => { + if (!statsHistory) { + return []; + } + + const series: { + [key: string]: { name: string; data: { x: number; y: string }[] }; + } = {}; + let hasValidGpu = false; + + statsHistory.forEach((stats, statsIdx) => { + if (!stats) { + return; + } + + Object.entries(stats.gpu_usages || []).forEach(([key, stats]) => { + if (!(key in series)) { + series[key] = { name: key, data: [] }; + } + + if (stats.dec) { + hasValidGpu = true; + series[key].data.push({ x: statsIdx + 1, y: stats.dec.slice(0, -1) }); + } + }); + }); + + if (!hasValidGpu) { + return []; + } + + return Object.keys(series).length > 0 ? Object.values(series) : undefined; + }, [statsHistory]); + // other processes stats const otherProcessCpuSeries = useMemo(() => { @@ -370,7 +439,10 @@ export default function GeneralMetrics({ Detectors
{statsHistory.length != 0 ? (
@@ -390,7 +462,7 @@ export default function GeneralMetrics({ ) : ( )} - {statsHistory.length != 0 ? ( + {statsHistory.length != 0 && ( <> {detTempSeries && (
@@ -409,8 +481,6 @@ export default function GeneralMetrics({
)} - ) : ( - )} {statsHistory.length != 0 ? (
@@ -466,7 +536,12 @@ export default function GeneralMetrics({ )}
-
+
{statsHistory.length != 0 ? (
GPU Usage
@@ -507,6 +582,50 @@ export default function GeneralMetrics({ ) : ( )} + {statsHistory.length != 0 ? ( + <> + {gpuEncSeries && ( +
+
GPU Encoder
+ {gpuEncSeries.map((series) => ( + + ))} +
+ )} + + ) : ( + + )} + {statsHistory.length != 0 ? ( + <> + {gpuDecSeries && ( +
+
GPU Decoder
+ {gpuDecSeries.map((series) => ( + + ))} +
+ )} + + ) : ( + + )}
)}