mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-27 03:18:59 +03:00
Improve metrics UI performance (#22691)
* embed cpu/mem stats into detectors, cameras, and processes so history consumers don't need the full cpu_usages dict * support dot-notation for nested keys to avoid returning large objects when only specific subfields are needed * fix setLastUpdated being called inside useMemo this triggered a setState-during-render warning, so moved to a useEffect * frontend types * frontend hide instead of unmount all graphs - re-rendering is much more expensive and disruptive than the amount of dom memory required keep track of visited tabs to keep them mounted rather than re-mounting or mounting all tabs add isActive prop to all charts to re-trigger animation when switching metrics tabs fix chart data padding bug where the loop used number of series rather than number of data points fix bug where only a shallow copy of the array was used for mutation fix missing key prop causing console logs * add isactive after rebase * formatting * skip None values in filtered output for dot notation
This commit is contained in:
@@ -498,4 +498,30 @@ def stats_snapshot(
|
||||
"pid": pid,
|
||||
}
|
||||
|
||||
# Embed cpu/mem stats into detectors, cameras, and processes
|
||||
# so history consumers don't need the full cpu_usages dict
|
||||
cpu_usages = stats.get("cpu_usages", {})
|
||||
|
||||
for det_stats in stats["detectors"].values():
|
||||
pid_str = str(det_stats.get("pid", ""))
|
||||
usage = cpu_usages.get(pid_str, {})
|
||||
det_stats["cpu"] = usage.get("cpu")
|
||||
det_stats["mem"] = usage.get("mem")
|
||||
|
||||
for cam_stats in stats["cameras"].values():
|
||||
for pid_key, field in [
|
||||
("ffmpeg_pid", "ffmpeg_cpu"),
|
||||
("capture_pid", "capture_cpu"),
|
||||
("pid", "detect_cpu"),
|
||||
]:
|
||||
pid_str = str(cam_stats.get(pid_key, ""))
|
||||
usage = cpu_usages.get(pid_str, {})
|
||||
cam_stats[field] = usage.get("cpu")
|
||||
|
||||
for proc_stats in stats["processes"].values():
|
||||
pid_str = str(proc_stats.get("pid", ""))
|
||||
usage = cpu_usages.get(pid_str, {})
|
||||
proc_stats["cpu"] = usage.get("cpu")
|
||||
proc_stats["mem"] = usage.get("mem")
|
||||
|
||||
return stats
|
||||
|
||||
Reference in New Issue
Block a user