From 94d6a7dd115a750951dcf0f1b76f0842a004e6ad Mon Sep 17 00:00:00 2001 From: Marius Ciepluch <11855163+norandom@users.noreply.github.com> Date: Mon, 5 Oct 2026 20:44:02 +0200 Subject: [PATCH] search executor: NPROC bound counts threads, as the kernel does [skip ci] Co-Authored-By: Claude Fable 5.1 --- src/openultrasast/search/executor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openultrasast/search/executor.py b/src/openultrasast/search/executor.py index 6817756..42cf849 100644 --- a/src/openultrasast/search/executor.py +++ b/src/openultrasast/search/executor.py @@ -285,9 +285,12 @@ class InProcessExecutor: status = (entry / "status").read_text() except FileNotFoundError: continue - real_uid = int(next(line for line in status.splitlines() if line.startswith("Uid:")).split()[1]) - current += real_uid == uid - process_limit = current + 128 + fields = dict(line.split(":", 1) for line in status.splitlines() if ":" in line) + # The kernel's NPROC counter counts threads, not processes: a single IDE or agent + # process with 60 threads uses 60 of the allowance. + if int(fields["Uid"].split()[0]) == uid: + current += int(fields.get("Threads", "1").strip() or 1) + process_limit = current + 256 except (OSError, ValueError, IndexError, StopIteration): pass