Skip to content

fix(agentctl): Size the pytest-quick slice for its actual parallelism - #65

Closed
Sinity wants to merge 2 commits into
masterfrom
fix/pytest-quick-slice-sizing
Closed

Sinity wants to merge 2 commits into
masterfrom
fix/pytest-quick-slice-sizing

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

agentctl-pytest-quick.slice was declared at MemoryHigh = 5G, but a slice ceiling is shared by every job in the slice and pytest-quick.parallel = 2. Two concurrent focused runs got ~2.5G each.

Problem

The sizing note in this file reasoned "two slots at 6G cost what three at 4G did" — reading the ceiling as per-slot. It is not per-slot, and that arithmetic is what put the pool under sustained reclaim.

The deeper fault is that MemoryHigh and ManagedOOMMemoryPressure are antagonistic on one cgroup. memory.high throttles by deliberately inducing reclaim; oomd kills for sustained reclaim. Undersize the high and the two mechanisms fight, with oomd winning.

Measured on the live host, 2026-09-22:

journalctl -u systemd-oomd | grep -c "Marked.*agentctl-pytest"   ->   29

All 29 between 08:22 and 08:44 — roughly one every 45 seconds — at slice pressure 62–71% against the 50% limit, for >30s with reclaim activity. One killed job's pytest process held ~307 MiB and was 5% through its selection. These were not runaways; the pool was simply smaller than two legitimate runs.

These kills have been read as test flakes, as collection-time failures, and as fixture-memory problems by several agents independently. They are the single largest throughput loss on the current campaign.

Solution

9G high / 10G max — two slots at 4.5G, with the hard bound one step above the throttle line so a genuine runaway is still cgroup-OOM-killed deterministically rather than by PSI. It stays under the 12G parent, so a concurrent heavy run is arbitrated by the parent instead of by killing a healthy child.

The comment is rewritten to state the per-slice rule explicitly, so the next person sizing this does not repeat the per-slot reading.

Verification

  • nix eval of slices.user.agentctl-pytest-quick → high = "9G", max = "10G".
  • Activated via the devshell switch wrapper; nix develop --command switch exited 0, "No version or size changes", configuration activated.
  • Read back from the running systemd, not from source:
systemctl --user show agentctl-pytest-quick.slice -p MemoryHigh -p MemoryMax
MemoryHigh=9663676416      # 9 GiB
MemoryMax=10737418240      # 10 GiB

Residual

ManagedOOMMemoryPressure=kill at 50%/30s is left in place on both leaf pools. With the high correctly sized the pool should no longer generate sustained PSI under normal load, so the policy is not itself wrong — but if kills recur at 9G, the policy and the throttle line are still the pair to reconcile, not the workload.

devtools/worker_memory.py in the polylogue repo models this pool as PYTEST_SLICE_MEMORY_HIGH_MIB = 12 * 1024, mirroring the parent slice. That mismatch is tracked separately on the polylogue side; this change does not touch it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

A slice ceiling is shared by every job in the slice, and
`pytest-quick.parallel = 2`, so the declared 5G gave two concurrent focused
runs ~2.5G each. The sizing note in this file read the ceiling as per-slot
("two slots at 6G cost what three at 4G did"); it is not per-slot, and that
arithmetic is what put the pool under sustained reclaim.

MemoryHigh and ManagedOOMMemoryPressure are antagonistic on one cgroup:
memory.high throttles by deliberately inducing reclaim, and oomd kills for
sustained reclaim. Undersize the high and the two fight, with oomd winning.

Measured on the live host, 2026-09-22:

  journalctl -u systemd-oomd | grep -c "Marked.*agentctl-pytest"  ->  29

all between 08:22 and 08:44, roughly one every 45 s, at slice pressure
62-71% > 50% for > 30s with reclaim activity. One killed job's pytest
process held ~307 MiB and was 5% through its selection. These were not
runaways; the pool was smaller than two legitimate runs. The kills have been
read as test flakes and as collection-time failures by several agents, and
they are the single largest throughput loss on the current campaign.

9G high / 10G max is two slots at 4.5G with the hard bound one step above the
throttle line, so a genuine runaway is still cgroup-OOM-killed
deterministically rather than by PSI. It stays under the 12G parent, so a
concurrent heavy run is arbitrated by the parent instead of by killing a
healthy child.

Verified: `nix eval` of slices.user.agentctl-pytest-quick -> high "9G",
max "10G".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 3c8d5282-7752-4ef7-adc4-52df83db6f27


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T07:53:42.200961Z 13698d6 PR opened
🔒 Security Review ✅ Completed 2026-09-22T07:57:07.236389Z 13698d6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13698d6451

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +466 to +467
MemoryHigh = "9G";
MemoryMax = "10G";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep concurrent pytest leaves below their parent maximum

When pytest-heavy runs concurrently with the nonexclusive pytest-quick pool (modules/services/agentctl.nix:77-83), the measured heavy working set (~10.05 GiB) plus the quick working set that already exceeded 5 GiB surpasses agentctl-pytest.slice's 14 GiB MemoryMax. Unlike MemoryHigh, that parent limit does not arbitrate or throttle: it invokes the cgroup OOM killer, which can kill the long-running corpus or a focused run. Make these pools mutually exclusive or size the parent hard limit for their supported concurrent working sets.

AGENTS.md reference: AGENTS.md:L95-L104

Useful? React with 👍 / 👎.

With the slice ceiling corrected to 9G, the binding constraint moved from
oomd kills to queueing: four concurrent review lanes sat three-deep behind a
two-slot pool.

Width is bounded by the slice ceiling, not by cores. Measured on the live
host with the corrected slice, two concurrent focused jobs held 3,680 MiB of
9,216 MiB (40%), the worse of the two peaking at 2,867 MiB. Three slots at
that peak is 8,601 MiB, still under the high. Four would be 11,468 MiB and
would put the pool back into the sustained reclaim oomd kills for, so this
stops at three.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity

Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Follow-up commit on this branch: pytest-quick.parallel 2 → 3.

With the ceiling corrected, the binding constraint moved from oomd kills to queueing — four concurrent review lanes sat three-deep behind a two-slot pool. Width is bounded by the slice ceiling, not by cores, so I measured the headroom rather than guessing:

two concurrent jobs 3,680 MiB of 9,216 (40%)
worse job's peak 2,867 MiB
three slots at that peak 8,601 MiB — under the high
four slots 11,468 MiB — back into sustained reclaim

So this stops at three, with the arithmetic recorded in the comment.

Verified live after activation. A queued job was admitted 8 seconds after the switch, and the slice now shows three jobs running at 4,453 MiB of 9,216 (48%) with zero oomd kills since.

Cumulative effect of this PR on the campaign: 29 kills in 22 minutes → 0 in ~100 minutes, and pool throughput up 50%.

@Sinity

Sinity commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

The 9G/10G quick slice and three-slot pytest pool are integrated on master in #72. This branch is superseded; its remaining diff is older comments and pool settings.

@Sinity Sinity closed this Sep 25, 2026
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