Repository navigation
The unit job runs the suite on every core with pytest-xdist - #287
Merged
Merged
Conversation
The single-process run took 44 of its 45 minutes. Three tests that raced a slow process start under load now wait on the event they check, and one parametrize id no longer comes from uuid4(), which every xdist worker must collect identically. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…on advice Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… and the grandchild's cleanup Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…er's sequence in the CI log Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…t link to, the pid wait reads once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
9 tasks done
…nute run Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…production keeps randomly's per-test seeds, one pid reader Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… pre-push timing is CI's measured one, a shorter _within docstring Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ved its parent Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
...
Why
pytest unit + coverageran 27,510 tests in one process: the pytest step took 44 minutes of the job's 45-minute timeout onmain. The runner's second core sat idle. pytest-xdist runs one worker per core; pytest-randomly passes the same seed to every worker, so the order is still random and the seed is still printed, and pytest-cov combines the workers' data into the samecoverage.jsonthe floors gate reads.Running in parallel exposed four tests that depended on a quiet machine or on collection being random, and a wall-clock bound in the extraction tests (below). Each is fixed at its source:
test_request_ids.py::test_a_short_token_is_used_as_sentuuid4()at collection, and xdist refuses workers whose collections differtest_cli_child_stop.py::test_a_cancelled_wait_stops_the_child_and_its_childrenwait_or_stopnever ran and nothing reaped the childawait asyncio.sleep(0)aftercreate_task, so the wait is running before it is cancelledtest_shutdown_deadline.py::test_the_process_exits_without_waiting_on_a_stuck_heartbeattime.monotonic()just beforeretire_process, and the parent measures from that moment to the exit (CLOCK_MONOTONICis one clock for every process on the host); the 5 s bound is unchangedtest_workers_child.py::test_the_child_dies_with_its_parentdie_with_parent(), and the parent is killed only after that--durations=30lists the slowest tests at the end of the job. One-vrun, which names each result's worker, took 41:27 against 29:39 and 32:05 for-q; with one sample the cause is not settled (the same run was slow on a CPU-bound test too), and the job keeps-q;tests/README.mdsays how to find a neighbour without the worker's sequence.Scope and risk
CI configuration, the
make test-unitandmake test-unit-covtargets, the pytest-xdist dev dependency (pyproject.toml,uv.lock), five test files (the four races, and the extraction tests' bounds now on CPU time, whichtest_document_extraction_tables.pyalso gets through its import of_within), and the testing docs, the tests rule, two skills andCONTRIBUTING.md. No server code changes. A test that shares a file, port or directory with another test can now fail when the two run at once. The full suite passed under-n 16and-n 8, with a different seed for each run, apart from the case below, and the testing docs now state the rule.test_document_extraction_tables.py::test_the_delimiter_is_sniffed_in_bounded_timefails on the development host with or without xdist:csv.Snifferspends 7 to 16 s of CPU there (an aarch64 host, without coverage) on its 64 KiB sample, over the test's 5 s bound, so the time is CPU work, not load from other tests. It passes on CI's x86-64 runners with coverage on; why the sniffer is that much slower on aarch64 is outside this PR. Its bound now counts CPU time through_withinand is otherwise unchanged.test_document_extraction.py::test_one_line_sql_with_a_comment_after_every_semicolon_splits_in_bounded_timetook 11.7 s against its 10 s bound in the-vrun (1.6 s on the development host without coverage). With a second worker on the runner's other core, wall time counts that worker's load against every such bound, so_within, the timer of the extraction tests' bounded-time checks (12 calls in two files), and the timer oftest_the_wide_integer_check_is_linear_in_a_deep_table_of_long_keysnow measure the process's CPU time (time.process_time()). The bounds are unchanged, and a loop that turned quadratic still spends its minutes of CPU.Compatibility, rollout and rollback
Tests
Measured on this PR's CI runs at 54fed4c and 0880052 (the later commits change test timers, docs and comments, not the job's command): the pytest step took 29:39 (27,510 passed, 20 skipped, 1 xfailed, the counts on
main), down from 44:04, and the job 30:45 at 54fed4c and 32:05 at 0880052. The repository's runners have two cores, so-n autostarts two workers. Splitting the suite across runners is the next step, in its own PR.Coverage is unchanged.
main's CIcoverage.xmlhad lines 178,318 / 192,923 and branches 46,727 / 54,912. This branch under-n 8has lines 178,323 / 192,923 and branches 46,732 / 54,912. The 5-line difference is environment-dependent skips on the development host.python -m tests.inventory.coverage_floors coverage.jsonpasses.Test count is unchanged: CI's run reports 27,510 passed, 20 skipped and 1 xfailed, the same 27,531 as
main's run. This PR adds no test and removes none.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The author checked the coverage totals, the floors and each race's cause.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass, apart from the delimiter-sniff test named above, which fails on the development host's CPU and passes on CI's runners; the integration suite passes if server behaviour changed.main; no merged migration is edited.frontend/changed.docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code