Skip to content

fix(linux): bound the foreground process-tree scan - #3674

Draft
caner-akca wants to merge 1 commit into
herdrdev:masterfrom
caner-akca:issue/3621-bound-foreground-proc-walk
Draft

fix(linux): bound the foreground process-tree scan#3674
caner-akca wants to merge 1 commit into
herdrdev:masterfrom
caner-akca:issue/3621-bound-foreground-proc-walk

Conversation

@caner-akca

Copy link
Copy Markdown
Contributor

Summary

  • Fix the headless server's read-syscall rate (and CPU) growing without bound over uptime on Linux at a constant pane count: foreground-job detection walked each pane shell's entire descendant process tree and read /proc/<pid>/stat per node, so accumulated child/zombie processes made every probe read more over time.
  • Bound the primary foreground process-tree traversal (process_tree_pids in src/platform/linux.rs) with a 512-node scan limit, truncating the walk while retaining the enqueued shell/foreground-group roots, so the detected agent and normal foreground groups are unchanged and only pathologically large trees are capped. Mirrors the existing CHILD_GROUPS_SCAN_LIMIT on the fallback path.

Validation

  • live: stock 0.8.2 at /home/exedev/herdr-fix-3621/stock/target/release/herdr (sha256:b52c743d51046f9173761213b4f05063d7f5c1334753c7e89dfd6e8a71e7452e) showed the server's /proc/<pid>/io read rate scale with foreground-tree size (18,975/s at 700 descendants → 54,124/s at 2,100, ×2.85); frozen driver sha256:7439146b9ba31d48b921a1e4c6bfdb84c5b7cdab548d69680553f3ef88f85c59 with HERDR_BIN=/home/exedev/herdr-fix-3621/patched/target/release/herdr (sha256:6f498481b8578918b30346fca1dfc9079aefa082b9b37152f0f4504558a57613) did not (14,519/s → 13,925/s, ×0.95, bounded)
  • regression coverage: foreground_tree_traversal_is_bounded_by_the_scan_limit failed without the fix and passes at the committed HEAD
  • focused: cargo nextest run -E 'test(foreground_tree_traversal_is_bounded_by_the_scan_limit)' passed at the committed HEAD
  • just check passed at the committed HEAD

Notes

Reproduced and validated on a Linux x86_64 host (kernel 6.12, 2 cores). The 100%-/proc/<pid>/stat read attribution and tree-size scaling were confirmed with strace; the accelerated driver grows two pane shells' descendant trees (both above the 512-node bound) and compares the server read rate, standing in for the reporter's real agents accumulating descendants over ~20h.

refs #3621

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c8bffb29-52a5-4f04-9287-1402339de6fe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant