summaryrefslogtreecommitdiffstats
path: root/desktop/modules/perf/test_vram.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-28 09:18:17 +0100
committerDanilo M. <danix@danix.xyz>2026-10-28 09:18:17 +0100
commit11c4c745c7ed5477c74abe7de3458924a0567a3a (patch)
tree1d5d5a522f4bd05fc60f37c87618c9c438bd4299 /desktop/modules/perf/test_vram.sh
parentad0989dda8dc6420d16aaaa6aa40c47917145342 (diff)
downloadquickshell-11c4c745c7ed5477c74abe7de3458924a0567a3a.tar.gz
quickshell-11c4c745c7ed5477c74abe7de3458924a0567a3a.zip
perf: sum VRAM in a shell script instead of in QML
A process holding thousands of DRM fds makes the fdinfo scan a few hundred KB. Parsing that in QML every 2s drove Qt's unmanaged-heap counter to underflow, after which the V4 engine ran a GC on every allocation and the shell sat at 100% CPU. vram.sh does the scan and the per-client-id sum in awk and prints one number, or nothing when no xe client is found, which the panel draws as a dash. Perf.js loses vram() and its test; test_vram.sh carries the same cases against the script, which takes a file argument instead of scanning so the test can feed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/perf/test_vram.sh')
-rwxr-xr-xdesktop/modules/perf/test_vram.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/desktop/modules/perf/test_vram.sh b/desktop/modules/perf/test_vram.sh
new file mode 100755
index 0000000..7ef4ade
--- /dev/null
+++ b/desktop/modules/perf/test_vram.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# vram.sh: summed once per xe client id, units honoured, other drivers
+# ignored; nothing at all when no xe client is found.
+set -e
+dir=$(dirname "$0")
+tmp=$(mktemp)
+trap 'rm -f "$tmp"' EXIT
+
+printf '%s\n' \
+ "/proc/1/fdinfo/7:drm-driver: xe" \
+ "/proc/1/fdinfo/7:drm-client-id: 38" \
+ "/proc/1/fdinfo/7:drm-resident-vram0: 1024 KiB" \
+ "/proc/1/fdinfo/10:drm-driver: xe" \
+ "/proc/1/fdinfo/10:drm-client-id: 38" \
+ "/proc/1/fdinfo/10:drm-resident-vram0: 1024 KiB" \
+ "/proc/2/fdinfo/5:drm-driver: xe" \
+ "/proc/2/fdinfo/5:drm-client-id: 40" \
+ "/proc/2/fdinfo/5:drm-resident-vram0: 2 MiB" \
+ "/proc/3/fdinfo/4:drm-driver: amdgpu" \
+ "/proc/3/fdinfo/4:drm-client-id: 1" \
+ "/proc/3/fdinfo/4:drm-resident-vram0: 9 GiB" > "$tmp"
+got=$(sh "$dir/vram.sh" "$tmp")
+[ "$got" = $((1024 * 1024 + 2 * 1024 * 1024)) ] || { echo "vram: got '$got'"; exit 1; }
+
+: > "$tmp"
+got=$(sh "$dir/vram.sh" "$tmp")
+[ -z "$got" ] || { echo "empty: got '$got'"; exit 1; }
+echo ok