-
Notifications
You must be signed in to change notification settings - Fork 1
Close completed test harness Bead #3941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4d10b76
2a3f4ec
43b8464
bc5f4ee
8c6f13d
5be8cfa
60d19aa
9c2e215
2dc7bf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -875,6 +875,29 @@ def cleanup_managed_pytest_basetemp(*, root: Path, run_id: str, env: dict[str, s | |
| return None | ||
|
|
||
|
|
||
| def _pytest_event_worker_ids(events_dir: Path | None) -> dict[int, str]: | ||
| """Recover xdist worker identities emitted after process exec. | ||
|
|
||
| ``PYTEST_XDIST_WORKER`` is not guaranteed to appear in ``/proc``'s | ||
| exec-time environment. The progress plugin emits a session-start event | ||
| from inside each worker, which is the authoritative identity for the | ||
| supervisor sampler. | ||
| """ | ||
| if events_dir is None or not events_dir.is_dir(): | ||
| return {} | ||
| identities: dict[int, str] = {} | ||
| for path in events_dir.glob("*.jsonl"): | ||
| with contextlib.suppress(OSError, UnicodeDecodeError): | ||
| for line in path.read_text(encoding="utf-8").splitlines(): | ||
| with contextlib.suppress(json.JSONDecodeError): | ||
| payload = json.loads(line) | ||
|
Comment on lines
+889
to
+893
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
During full or seed xdist runs, these JSONL files grow by several records per test, but every resource sample (every 2 seconds by default) rereads and JSON-decodes every line accumulated so far. A ~20k-test run therefore performs a quadratic amount of ledger parsing and adds substantial CPU/I/O pressure precisely while the sampler is trying to diagnose an I/O stall; recover identities once from the session-start records or cache incrementally rather than scanning the complete event history on every sample. Useful? React with 👍 / 👎. |
||
| pid = payload.get("pid") | ||
| worker_id = payload.get("worker_id") | ||
| if isinstance(pid, int) and isinstance(worker_id, str) and worker_id != "controller": | ||
| identities[pid] = worker_id | ||
| return identities | ||
|
|
||
|
|
||
| class ResourceSampler: | ||
| """Samples host and process-tree resources for one subprocess tree.""" | ||
|
|
||
|
|
@@ -884,6 +907,7 @@ def __init__(self, *, root_pid: int, run_id: str, root: Path, env: dict[str, str | |
| self.root = root | ||
| self.env = env | ||
| self.output_path = output_path | ||
| self.events_dir = Path(env["POLYLOGUE_PYTEST_EVENTS_DIR"]) if env.get("POLYLOGUE_PYTEST_EVENTS_DIR") else None | ||
| self.sample_count = 0 | ||
| self.peak_rss_kb = 0 | ||
| self.peak_pss_kb: int | None = None | ||
|
|
@@ -930,6 +954,7 @@ def sample(self, *, event: str) -> dict[str, Any]: | |
| total_cpu = 0.0 | ||
| xdist_worker_count = 0 | ||
| xdist_uninterruptible_count = 0 | ||
| event_worker_ids = _pytest_event_worker_ids(self.events_dir) | ||
| for pid in pids: | ||
| status = _status_values(pid) | ||
| rss = int(status.get("rss_kb") or 0) | ||
|
|
@@ -940,7 +965,7 @@ def sample(self, *, event: str) -> dict[str, Any]: | |
| swap_pss = smaps.get("SwapPss") | ||
| cpu = _cpu_seconds(pid) | ||
| process_identity = _process_identity(pid) | ||
| worker_id = _process_environ_value(pid, "PYTEST_XDIST_WORKER") | ||
| worker_id = _process_environ_value(pid, "PYTEST_XDIST_WORKER") or event_worker_ids.get(pid) | ||
| if worker_id is not None: | ||
| xdist_worker_count += 1 | ||
|
Comment on lines
+968
to
970
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When only a subset of xdist workers has emitted readable event receipts—during staggered startup or because Useful? React with 👍 / 👎. |
||
| if str(status.get("state") or "").startswith("D"): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When basetemp admission fails during an ordinary affected run,
--all, or a full seed, this hardcodes the step's scope tonarrow-terminal, even though that scope represents an explicitly narrowed skip-slow terminal run. The top-level history derivesaffectedorrelease-baselinefrom the CLI arguments, so the resulting machine receipts contradict each other about what was attempted; propagate the requested scope or use a distinct refusal scope instead.Useful? React with 👍 / 👎.