mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-21 08:57:48 +02:00
fix(agent): carry Intel GPU averages forward between samples (#2256)
Intel GPUs (intel_gpu_top) never report temperature or memory, so the "suspended card" heuristic in calculateGPUAverage (temp == 0 && memoryUsed == 0) fired on every collection that landed between samples. intel_gpu_top samples every 3.3s (intelGpuStatsInterval) while the hub's realtime worker collects every 1s, so most realtime collections had no new sample (delta count 0) and returned an empty GPUData with power omitted (json "p"/"pp" are omitempty). The frontend derives the GPU Power Draw series and legend from the latest sample, so the chart and legend blanked on roughly two of every three or four one-second cycles. NVIDIA/AMD were unaffected because they report temperature even when idle, so the heuristic never fired and the last average was already carried forward. Gate the zero-return on non-engine (discrete) GPUs so Intel GPUs carry the last average forward during between-sample gaps, matching the existing NVIDIA/AMD behavior. Add a regression test.
This commit is contained in:
12
agent/gpu.go
12
agent/gpu.go
@@ -361,12 +361,16 @@ func (gm *GPUManager) calculateGPUAverage(id string, gpu *system.GPUData, cacheK
|
||||
|
||||
// If no new data arrived
|
||||
if deltaCount == 0 {
|
||||
// If GPU appears suspended (instantaneous values are 0), return zero values
|
||||
// Otherwise return last known average for temporary collection gaps
|
||||
if gpu.Temperature == 0 && gpu.MemoryUsed == 0 {
|
||||
// Only discrete GPUs report temp/memory, so treat all-zero as suspended (return zeros).
|
||||
// Engine-based (Intel) GPUs don't, so carry the last average forward across sample gaps.
|
||||
if gpu.Engines == nil && gpu.Temperature == 0 && gpu.MemoryUsed == 0 {
|
||||
return system.GPUData{Name: gpu.Name}
|
||||
}
|
||||
return gm.lastAvgData[id] // zero value if not found
|
||||
lastAvg := gm.lastAvgData[id] // zero value if not found
|
||||
if lastAvg.Name == "" {
|
||||
lastAvg.Name = gpu.Name
|
||||
}
|
||||
return lastAvg
|
||||
}
|
||||
|
||||
// Calculate new average
|
||||
|
||||
Reference in New Issue
Block a user