Skip to content

perf(witan): run the witan test suite in parallel - #517

Merged
feoh merged 2 commits into
mainfrom
perf/witan-test-speed
Oct 19, 2026
Merged

feoh merged 2 commits into
mainfrom
perf/witan-test-speed

Conversation

@feoh

@feoh feoh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

N/A

Description (What does it do?)

The witan tests take ~10 minutes per PR. This cuts that time without removing any test coverage, by running the suite in parallel with pytest-xdist.

  • witan-tests.yml, publish-witan.yml and just test-witan-council run pytest -n auto --dist worksteal. Pass -n 0 to the recipe to run serially (needed for --pdb).
  • Adds pytest-xdist to witan's test dependency group.
  • Fixes one test that read the shared system temp dir and could flake once tests run in parallel.
Implementation details

The Run tests step took 5.2–7.9 minutes over the last 20 successful runs, nearly all of it spent waiting on omnigraph subprocesses. Each test already builds its own store under tmp_path, and testsupport/hermetic.py gives each process its own fake home directory, so the tests spread across workers as they are. worksteal because single tests range from milliseconds to ~15s.

Checked under xdist:

  • The hermetic leak check still fails the run. The main pytest process records the real home before any worker starts, and checks it after they all finish. A probe test that wrote to the real ~/.config/witan exited 1 with AGENT_KIT_STRICT_HERMETICITY=1.
  • Workers still find the omnigraph binary with ~/.local/bin removed from PATH, and no requires_omnigraph test skips.
  • test_mark_run_atomic_roundtrip set TMPDIR without resetting tempfile's cached temp dir, so it searched the shared /tmp for *.tmp files. Other workers' atomic writes in witan/context.py create those briefly. It now uses the tmp_state_dir fixture.

uv.lock was regenerated with uv 0.12, which keeps lockfile revision 3 and changes nothing beyond the two new packages.

How can this be tested?

  • This PR's witan (memory + CLI) job: compare its time and its final passed/skipped line with a recent main run.
  • Locally: just test-witan-council. With 4 workers I got 1630 passed, 1 skipped in ~67s, against ~7 minutes serially on the same machine, and the result held over repeated runs and with 32 workers.
  • Three omnigraph-server tests fail on any machine with an outdated omnigraph-server binary, serially as well. CI doesn't install that binary and skips them.

feoh added 2 commits October 19, 2026 14:52
The `witan (memory + CLI)` job ran 1630 tests serially and took 5-8 minutes,
almost all of it waiting on `omnigraph` subprocesses against a per-test store.
The tests are already independent: each one inits its own store under
tmp_path, and testsupport/hermetic.py gives every process its own fake HOME.
So they spread across cores cleanly.

Run them with `-n auto --dist worksteal` in witan-tests.yml, publish-witan.yml
and `just test-witan-council`. No tests are removed or skipped. Locally, -n 4
(the ubuntu-latest core count) gives 1630 passed in ~67s, against ~7 minutes
serially on the same machine, and it stayed stable across repeated and
oversubscribed (-n 32) runs.

Checked under xdist:
- The hermetic leak guard still fails the run. The controller snapshots the
  real home before the workers start. A probe test that wrote to the real
  ~/.config/witan exited 1 with AGENT_KIT_STRICT_HERMETICITY=1.
- Workers still find the omnigraph binary with ~/.local/bin stripped from
  PATH, with no requires_omnigraph skips. They inherit the PATH entry the
  controller re-added.
…mp dir

It set TMPDIR without resetting tempfile's cached gettempdir(), so it wrote
its stamp to the shared system temp dir and globbed it for *.tmp. Under
pytest-xdist another worker's atomic write from witan/context.py can leave a
*.tmp there for an instant and fail the assertion. Use the tmp_state_dir
fixture, which resets the cache, so the test checks only its own tmp_path.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The dependency, execution, and test-isolation changes are consistent, with no unresolved blocking issues.

No open issues 🎉

What changed in this PR

Speeds up Witan’s test suite by enabling parallel execution locally and in CI without removing coverage.

Changes:

  • Adds pytest-xdist and enables automatic workers with work stealing.
  • Documents -n 0 for serial local runs.
  • Isolates a maintenance test’s temporary files to avoid parallel-run interference.
File Description
uv.lock Locks pytest-xdist and execnet dependencies.
mcp/​servers/​witan/​tests/​test_maintenance.py Uses the isolated temporary-state fixture.
mcp/​servers/​witan/​pyproject.toml Adds pytest-xdist to test dependencies.
justfile Enables parallel Witan tests locally.
.github/​workflows/​witan-tests.yml Enables parallel tests in CI.
.github/​workflows/​publish-witan.yml Enables parallel tests before publishing.

Review effort: Balanced

@feoh
feoh merged commit db8edb4 into main Oct 19, 2026
25 checks passed
@feoh
feoh deleted the perf/witan-test-speed branch October 19, 2026 19:04
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.

3 participants