perf(session): read process command lines in one call in the zRAM watcher (#3302)

Read process command lines in one call in the zRAM watcher

The watcher read every /proc/<pid>/cmdline one byte per system call, costing about 390 ms of CPU per scan every 5 s (every second under memory pressure). mapfile reads in blocks and yields the same argument list, cutting a scan to about 17 ms.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-26 18:04:24 -05:00
1 parent 3dbcefc14c
commit aff81a13e3
1 file changed
+1 -1
@@ -778,7 +778,7 @@ case $mode in
for _d in /proc/[0-9]*; do
[ "${_d##*/}" != "$BASHPID" ] || continue
_args=()
while IFS= read -r -d '' _c; do _args+=("$_c"); done 2>/dev/null < "$_d/cmdline" || true
mapfile -d '' -t _args 2>/dev/null < "$_d/cmdline" || true
[ "${#_args[@]}" -gt 0 ] || continue
_name=${_args[0]} _fex=0
if [ "${#_args[@]}" -gt 1 ]; then