Repository navigation
perf(devtools): bound pytest harness memory pressure (#2170) - #2171
Conversation
Problem: broad pytest-testmon runs could select nearly the whole suite, retain and write unbounded selection node lists, and then spend the full timeout in one multi-GiB Python process. Basetemp cleanup also had no metadata trail, making stale temp-tree pressure harder to diagnose. What changed: bound pytest selection node-id artifacts while preserving exact counts, run the default affected-test lane with a bounded xdist pool, stream resource-summary parsing instead of loading the full resource log, record managed basetemp cleanup in verify metadata, and update the status route catalog drift found by the broad run. Verification: devtools test tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade tests/unit/devtools/test_pytest_progress_plugin.py tests/unit/devtools/test_verify.py tests/unit/devtools/test_run_tests.py; devtools verify --quick. Full devtools verify selected 11544 tests with -n 4 and proved the harness path, but failed before the catalog drift fix; targeted rerun covers that failure. Ref #2170
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 798bb9e0e8
ℹ️ 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".
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughBounded nodeid sampling is added to ChangesDevtools verify harness improvements
Status route catalog additions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 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 |
## Summary Bound daemon-side SQLite cache pressure by separating long-running daemon/ops writes from the batch-ingest write profile, and by moving recurring daemon read probes onto the read-only profile. ## Problem The live memory snapshot after #2171 showed a different pressure shape from the pytest harness issue: `polylogued.service` was near 950 MiB current cgroup memory with a 2.9 GiB peak, but the daemon process itself was only about 235 MiB PSS. `memory.stat` attributed most current usage to file cache rather than anonymous heap. Several daemon loops still opened the full write profile for small ops/maintenance work, and heartbeat counts opened a write-profile connection for read-only counts. ## Solution Added an explicit daemon write profile in `polylogue/storage/sqlite/connection_profile.py` with a 16 MiB SQLite cache and 64 MiB mmap allowance, leaving the existing 128 MiB / 1 GiB batch-ingest write profile untouched. Moved small daemon/ops writes (`daemon_events`, cursor-lag samples, embedding catch-up rows, OTLP telemetry, daily optimize) to `open_daemon_connection`, and moved heartbeat plus two ops health probes to `open_readonly_connection`. The existing status/metrics memory reporting already distinguishes RSS, cgroup current/peak, cgroup file, and inactive file, so this change relies on that live observability rather than adding another reporting layer. ## Verification - `devtools test tests/unit/storage/test_wal_journal_size_limit.py::test_daemon_write_profile_uses_bounded_cache_and_mmap tests/unit/storage/test_wal_journal_size_limit.py::test_open_daemon_connection_applies_bounded_cache_and_mmap tests/unit/daemon/test_daemon_cli.py::test_daemon_cli_heartbeat_counts_uses_read_only_probe tests/unit/daemon/test_daemon_cli.py::test_daemon_cli_heartbeat_counts_archive tests/unit/daemon/test_cursor_lag_baseline.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_otlp_receiver.py tests/unit/daemon/test_metrics_endpoint.py::TestFormatMetricsReadsArchiveState::test_fts_freshness_and_memory_state` — 46 passed. - `devtools verify --quick` — exit 0. - `devtools verify` — run `20260619T163716Z-testmon-1662720-33dfc22a`; 505 passed in 256.73s, selected_count=1247, peak_tree_pss=2813.7 MiB, diagnosis=`pytest_passed`. Closes #2172
|
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
Bounds the verification harness paths that were still capable of turning broad pytest-testmon selections into multi-GiB, single-process runs. Selection artifacts now preserve exact selected/deselected counts while sampling node IDs, default affected-test verification runs through a bounded xdist pool, run metadata records managed basetemp cleanup, and resource summary parsing streams the resource log instead of loading it wholesale.
Problem
Local verify evidence showed two distinct failure shapes:
devtools verify --seed-testmon --skip-slowselected about 11.5k tests with-n 4, peaked around 3.1 GiB PSS, and wrote about 3.0 GiB of pytest basetemp data.devtools verifyselected about 11.3k tests with-n 0, kept one Python process around 2.8 GiB PSS, and hit the 45-minute supervisor timeout.Focused
devtools test ...runs stayed around 100-140 MiB RSS, so the implicated surface was broad/default harness behavior, not the ordinary inner loop. A freshpssample of the installedpolyloguedduring this work was about 216 MiB RSS after 6h25m, so this PR does not claim a daemon retention fix.Solution
devtools.pytest_progress_pluginnow samples selected/deselected node IDs (POLYLOGUE_PYTEST_SELECTION_NODEID_LIMIT, default 500) while retaining exact counts and omitted-count metadata.devtools verifynow defaults the affected pytest-testmon lane to-n 4, matching seed/full broad lanes, while focuseddevtools testremains single-process by default.basetemp_cleanup, making post-run temp-tree reclamation visible in verify history.resources.jsonlrather than materializing all samples in memory.polylogue ops statusfacade-route catalog was updated forneighbor_candidate_payloadsandsession_correlation_payload; the broad verify run found this real drift after feat(daemon): stabilize evidence read API routes (#1847) #2169.AGENTS.mddescribe the new worker and selection-artifact behavior.Verification
devtools test tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot tests/unit/devtools/test_pytest_progress_plugin.py tests/unit/devtools/test_verify.py tests/unit/devtools/test_run_tests.py-> 74 passed.devtools verify --quick-> exit 0, run20260619T162135Z-quick-1620666-9bbe9eae.devtools verifyselected 11,544 tests with-n 4, completed in 36:03 instead of timing out, recordedbasetemp_cleanup, and peaked at 4.38 GiB PSS; it failed one status route-catalog test, which this PR fixes.devtools verifyafter the catalog/snapshot fix -> exit 0, run20260619T162202Z-testmon-1622183-8c640aa0; pytest step selected 10, ran 1 affected test, passed, and recordedbasetemp_cleanupplus peak PSS 553.1 MiB.Closes #2170
Summary by CodeRabbit
New Features
POLYLOGUE_PYTEST_WORKERS).POLYLOGUE_PYTEST_SELECTION_NODEID_LIMIT(default 500).neighbor_candidate_payloadsandsession_correlation_payload.Documentation