Repository navigation
fix: budget pytest tmpfs from measured cgroup overhead - #3948
Conversation
📝 WalkthroughWalkthroughPytest verification now parses all supported xdist worker forms, applies measured resource budgets, selects basetemp storage from demand, manages nested benchmark runs, and reads progress artifacts from repository-anchored configurable paths. ChangesPytest resource policy
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant PytestCommand
participant Verify
participant RuntimePolicy
participant CgroupMetrics
participant BasetempPlacement
PytestCommand->>Verify: provide worker options and suite scope
Verify->>RuntimePolicy: pass policy overrides
RuntimePolicy->>CgroupMetrics: read cgroup memory headroom
CgroupMetrics-->>RuntimePolicy: available memory
RuntimePolicy-->>Verify: worker count and predicted demand
Verify->>BasetempPlacement: evaluate configured and predicted demand
BasetempPlacement-->>Verify: select tmpfs or scratch
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90af040608
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17703e74be
ℹ️ 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".
Problem: the ce4dd62 full suite had 15,190 MiB available but the 10 percent tmpfs heuristic imposed a 1,519 MiB cap and terminated the run at 1,521.6 MiB. What changed: reserve host and command-worker headroom before deriving the bounded tmpfs cap, and pass the parsed pytest concurrency into that admission decision. The monitor remains active and low-headroom commands fail before launch.
Problem: xdist option parsing under-reserved several production command forms, and a 768 MiB per-worker estimate admitted a four-worker run on a 4 GiB host despite the measured process, tmpfs, and cgroup envelope. What changed: parse all supported xdist spellings, reserve logical CPU concurrency for auto, and derive admission from the measured four-worker envelope. The cgroup measurement already includes tmpfs charging, so admission uses it as a composite bound while separately constraining a proposed tmpfs cap.
Problem: the four-worker resource measurements were divided into worker-only costs, so default selection, low-worker admission, and basetemp placement could disagree at launch. What changed: retain fixed controller and cgroup components, scale only the marginal worker cost, reserve the full-run basetemp as aggregate demand, and compare inherited tmpfs caps before selecting the basetemp root. The default selector now uses the same envelope as launch admission, including the conservative ceiling of the observed 1,521.6 MiB basetemp peak.
17703e7 to
fb74235
Compare
|
@codex review |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devtools/verify_runs.py`:
- Around line 677-680: Remove the unconditional PytestResourceError for a
missing or unreadable /dev/shm in the resource-admission flow, while preserving
worker-memory checks and disabling tmpfs usage. Ensure
apply_managed_pytest_runtime_policy continues to resolve placement through
resolve_pytest_basetemp_root so scratch is selected when capacity permits, and
add coverage for this unavailable-tmpfs path.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4ef9c4b0-a766-4938-bde5-07df2b93d056
📒 Files selected for processing (4)
devtools/verify.pydevtools/verify_runs.pytests/unit/devtools/test_run_tests.pytests/unit/devtools/test_verify.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb74235e0f
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efe9b8f282
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e7b431a3b
ℹ️ 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".
Clamp inherited tmpfs limits to the measured host-safe policy, account serial pytest runs without inventing an xdist worker, and route unsupervised bare pytest basetemps to NVMe scratch.\n\nAdd production-route regression coverage for each admission boundary.\n\nCo-Authored-By: OpenAI Codex <[email protected]>
Cap pytest admission by the smallest remaining ancestor cgroup allowance, keep worker-memory checks active for explicit basetemp roots, and reserve the measured full-suite basetemp only for broad runs.\n\nExercise the hierarchy reader, explicit-root refusal, focused placement, and runner scope propagation through production policy paths.\n\nCo-Authored-By: OpenAI Codex <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8647d622e7
ℹ️ 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".
Reserve the measured full-suite basetemp only for seed, full, load-sensitive, and broad-testmon steps. Ordinary affected testmon runs retain the focused disk requirement.\n\nCover every managed pytest label class through the production runner.\n\nCo-Authored-By: OpenAI Codex <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c74810e0dd
ℹ️ 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".
Use the focused controller and proportional cgroup envelope for non-broad runs, preserve measured full-suite disk demand on explicit scratch roots, and normalize leaked cloud basetemp configuration before bare pytest selects storage. Cover low-memory focused admission, explicit-root disk refusal, and workstation cloud-default normalization. Co-Authored-By: OpenAI Codex <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devtools/run_tests.py`:
- Line 50: Update _subprocess_env in devtools/run_tests.py to construct pytest
artifact paths from ROOT instead of Path.cwd(), matching the checkout-root
behavior already used by _managed_env and ensuring paths remain correct when
devtools test runs from a subdirectory.
In `@devtools/verify.py`:
- Around line 1727-1730: In the concurrency argument, remove the unreachable
None fallback and use the already-assigned pytest_concurrency value directly,
while preserving the minimum concurrency of 1 via max. Do not call
_pytest_command_concurrency again or read the policy-mutated env.
In `@tests/conftest.py`:
- Around line 105-114: Update devtools/verify_slos.py so _run_benchmarks()
launches pytest with the managed pytest environment, preserving
POLYLOGUE_VERIFY_RUN_ID, POLYLOGUE_PYTEST_BASETEMP_ROOT, and
POLYLOGUE_PYTEST_TMPFS from the parent managed step. Ensure the nested pytest
receives the configured tmpfs budget instead of triggering the bare-pytest
fallback in tests/conftest.py.
In `@tests/unit/devtools/test_verify.py`:
- Around line 1917-1930: Patch verify_runs.read_cgroup_memory_headroom_bytes in
test_managed_policy_uses_scratch_when_tmpfs_is_unavailable to return an
effectively unlimited memory headroom value, matching the other tests in this
file. Keep the existing _meminfo, _pressure, os.cpu_count, and _fs_usage patches
unchanged so the policy assertions are independent of the host cgroup
configuration.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1c5dd074-09db-4006-a3e6-054e865b1224
📒 Files selected for processing (9)
devtools/run_tests.pydevtools/verify.pydevtools/verify_runs.pypolylogue/core/metrics.pytests/conftest.pytests/unit/core/test_metrics_cgroup_memory_limits.pytests/unit/devtools/test_run_tests.pytests/unit/devtools/test_verify.pytests/unit/test_pytest_temp_policy.py
💤 Files with no reviewable changes (1)
- tests/unit/devtools/test_run_tests.py
Problem: focused and nested benchmark pytest launches could lose checkout-scoped artifacts or managed tmpfs context when invoked from a subdirectory.\n\nWhat changed: anchor inherited artifact paths to the checkout, pass managed policy and run markers through the SLO parent and child, and make the supervisor read the event ledger supplied to pytest. The concurrency receipt now uses its already-parsed value, and the scratch fallback test isolates cgroup state.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16d1cb7e3c
ℹ️ 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".
Give the output-stall and progress-stall supervisor tests independent VerifyRun artifact directories. This prevents one invocation's event stream from changing another invocation's termination classification while preserving the real process-control route.\n\nCo-Authored-By: OpenAI Codex <[email protected]>
|
@codex review Please review exact head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f671d8ad2
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f8c57d9a8
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72dfe5e3b7
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CLAUDE.md`:
- Around line 516-517: Update the documentation sentence describing
POLYLOGUE_PYTEST_TMPFS=1 to state that it requests bounded tmpfs, but is honored
only when the effective budget satisfies the declared basetemp requirement;
retain the existing POLYLOGUE_PYTEST_BASETEMP_MIN_FREE_MB override description.
In `@devtools/verify.py`:
- Around line 1817-1819: Update _subprocess_env in devtools/verify.py to export
POLYLOGUE_PYTEST_EVENTS_DIR rooted at ROOT / PYTEST_EVENTS_DIR, alongside the
existing rooted pytest paths. In tests/unit/devtools/test_run_tests.py lines
58-65, extend the environment assertions to verify this variable resolves under
the checkout root.
In `@tests/conftest.py`:
- Around line 192-212: Update _remove_stale_basetemp in tests/conftest.py to
return immediately when the top-level entry is a symbolic link, before os.walk
or any permission changes. In tests/unit/test_pytest_temp_policy.py lines
289-303, add coverage for a stale top-level symbolic link and verify the linked
target tree’s permissions remain unchanged.
In `@tests/unit/test_pytest_temp_policy.py`:
- Around line 273-303: Update both stale-cleanup tests, especially
test_sweep_stale_polylogue_basetemps_reclaims_reused_pid_identity and
test_sweep_stale_polylogue_basetemps_reclaims_read_only_fixture_tree, to accept
the frozen_clock fixture and derive each entry’s mtime relative to its frozen
timestamp instead of using the hard-coded old = 1.0 value. Keep the existing
stale-reclamation assertions unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 478f1985-4e38-4a74-8095-e9b94f7a901e
📒 Files selected for processing (11)
CLAUDE.mdTESTING.mddevtools/verify.pydevtools/verify_runs.pydevtools/verify_slos.pytests/conftest.pytests/unit/devtools/test_run_tests.pytests/unit/devtools/test_slo_catalog.pytests/unit/devtools/test_verify.pytests/unit/operations/test_mutation_actuators.pytests/unit/test_pytest_temp_policy.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e3c097539
ℹ️ 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".
|
@codex review Please review exact head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d479aa057
ℹ️ 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".
|
@codex review Please review exact head |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Make the managed pytest harness select, supervise, and reclaim test storage from measured process, cgroup-overhead, basetemp, host-headroom, and filesystem envelopes.
Problem
The previous policy could admit a tmpfs cap from predicted demand while ignoring the larger allowed cap, and it could double-count or omit the cgroup charge around tmpfs pages. Broad suites then either filled shared memory or refused under misleading arithmetic. Real xdist progress was also written to per-worker event files that the live stall supervisor did not read, while nested benchmark pytest could consume tmpfs without that supervisor enforcing the cap. Explicit basetemp roots below
/dev/shmbypassed the common budget, and legacy read-only fixture trees could survive the stale-directory sweep indefinitely.Solution
Use the observed 6,278,623,232-byte cgroup peak, separate fixed process/cgroup overhead from adjustable tmpfs demand, and cap host capacity by the smallest remaining ancestor cgroup allowance. Worker-memory admission remains active for explicit scratch roots. Focused tests retain bounded tmpfs by default. Full-suite and seed-testmon runs default to NVMe scratch because the fixture tree can exceed the supervised 2 GiB tmpfs ceiling; an explicit tmpfs broad run remains bounded.
The live supervisor reads both per-worker event files and the merged event artifact, so flowing controller output cannot mask wedged workers. Nested benchmark pytest preserves managed admission and run identity while using scratch because its parent is not a pytest supervisor. Explicit
/dev/shmroots now use the same cap and cleanup path. Stale basetemp ownership binds PID plus process-start identity, and stale read-only fixture publications are made owner-writable only after liveness adjudication so cleanup can finish.The full-suite diagnostic also exposed a test fixture that created current durable tier files without fresh-bootstrap authority. The mutation-actuator fixture now initializes the active archive through the production bootstrap route.
Verification
direnv exec . devtools test tests/unit/devtools/test_verify.py tests/unit/test_pytest_temp_policy.py tests/unit/operations/test_mutation_actuators.py: 216 passed in 28.12sdirenv exec . devtools test -k managed_pytest_policy_bounds_explicit_tmpfs_root: 1 passed, 21,312 deselecteddirenv exec . devtools test tests/unit/devtools/test_run_tests.py tests/unit/test_pytest_temp_policy.py: 33 passed in 1.91sdirenv exec . devtools verify --quick: all 25 steps passed in 108.08s ata0da69269458fdd7c90b717109434f05df8ac603gw0.jsonlwhile continuously emitting output; it is terminated by the progress timeout rather than the output-silence timeout.a0da69269458fdd7c90b717109434f05df8ac603.