Skip to content

Releases

v0.17.0 — batch-dispatch worker protocol

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 31 Oct 22:46

0.17.0 — batch-dispatch worker protocol

The worker bus goes from per-item work-stealing to batch dispatch: the master hands each
worker up to PYTEST_FAST_BATCH (default 32) test indices per frame and refills as the worker
drains, so workers never block between tests. Results still ship per-item the moment each
completes — a worker crash cannot take completed results down with it (the compact runtime's
exact crash evidence is preserved). Each batch frame carries a lookahead hint (the first item
reserved for that worker's next batch), so the batch's last test runs with its TRUE nextitem:
module/session fixture behavior is identical to per-item dispatch.

Numbers (synthetic 100k sub-ms-test corpus, 6P+6E machine)

config wall before wall after bus idle before bus idle after bus/t before bus/t after
fast-1w 27.47s 20.92s 5.65s 0.28s 56µs 3µs
fast-4w 7.64s 5.74s 6.12s 0.48s 61µs 5µs
fast-8w 6.30s 3.92s 15.81s 1.60s 158µs 16µs

Plain pytest on the same corpus: 47.3s → the engine at 8w is 12.1×. Bus round-trips:
100k → ~3.1k. Batch-size sweep at 4w: 1→7.41s, 4→6.10s, 8→5.86s, 32→5.62s, 128→5.59s —
the knee is at the 32 default (PYTEST_FAST_BATCH=1 restores per-item dispatch).

Dogfood suite: bus 252 → 12 round-trips, wall 7.55s → 6.84s. Unit/parity/stress tiers green.

Full methodology and the verification matrix: PR #16.

v0.16.0 — compact mutation runtime: lean results, crash evidence, immutable-source campaigns

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 19 Jul 18:19

Compact mutation runtime

A generic runtime surface for exact mutation executors and other high-frequency wrapper tools: minimal per-request payloads, provable crash attribution, and fail-closed contracts at every edge — while the full pytest protocol keeps running underneath.

request_run_results — the quiet compact client

request_run_results(addr, on_result, nodeids=[...], stop_on_failure=..., fresh_workers=...) delivers validated lean RunResults through a callback. Unlike request_run it never writes to stdout (progress goes to an optional on_progress callback); unlike request_run_streamed it does not ask workers to serialize full pytest reports. Everything crossing the socket is validated — malformed progress frames, missing or malformed results, wrong outcome/duration/phase shapes all reject with rc=2 instead of reaching the executor.

Phase timings in every result

Every RunResult now carries phases — per-phase durations for setup / call / teardown — so timing-aware clients get exact phase attribution without paying for serialized TestReports.

Exact crash evidence — run_meta["process_failures"]

Each worker publishes the index of the item it is about to execute into a per-worker shared-memory slot right before entering the pytest protocol, and overwrites it with a terminal sentinel right after. If a worker process dies (os._exit, hard crash, kill), the parent reads the slot after the run and reports exactly the nodeid that was provably inside the protocol — nothing else. A completed earlier occurrence of the same nodeid cannot mask a later crash of its re-execution. The run stays UNTRUSTED as before; the new field tells you which item took the process down, with zero per-item transport frames on the happy path.

Collection errors fail closed for compact requests

A compact (want_results) request against a daemon whose collection has errors is rejected with rc=2 and a collection_errors count before any test item is dispatched — on both the persistent and fork-per-request paths. Wrapper tools can no longer receive results from a silently shortened suite. The ordinary CLI keeps its native collection output.

pytest_fast_worker_shutdown hook

Fired once per worker after final fixture teardown and before the worker's successful completion frame — the place to durably flush process-local artifacts that os._exit would otherwise discard. Deliberately fail-closed: an exception means no completion frame, and the controller rejects the run as incomplete rather than accepting missing plugin output. Worker identity (--worker-identity) now also applies with a single worker, so one-worker campaigns get the same gw0 lifecycle.

PYTEST_FAST_IMMUTABLE_SOURCES — campaign mode

Opt-in: when an outer campaign fingerprints the complete source/config/runtime set before and after the daemon lifetime, the per-request source-tree mtime scan can be skipped entirely — O(tree) work off the hot path of every request. The env-fingerprint guard stays active, and the flag itself is part of the fingerprint, so toggling it forces a respawn. Intended for fail-closed tooling, not interactive development.

Leaner persistent runs

Persistent workers previously serialized full per-phase reports on every request regardless of who asked. The requested full_report flag now travels to the workers, so lean requests skip pytest_report_to_serializable work entirely; streaming requests keep full reports.

Fixes

  • The pre-warm watcher records its source-mtime baseline before announcing readiness, so an edit landing in that gap is no longer lost at startup.
  • CI preserves the matrix-selected interpreter, so the 3.11–3.14 jobs genuinely test their declared Python version.

Protocol contract

EXACT_MUTATION_PROTOCOL_VERSION = 1 is exported: compact phase results, stop-first/fresh-worker acknowledgements, collection fail-closed behavior, and exact active-item crash evidence.

Verification

Integration tests for crash attribution on both execution paths (including the duplicate-nodeid case), compact stop-first contract, lean-vs-native serialization, collection-error rejection, shutdown-hook lifecycle (1 and 2 workers), and malformed-frame rejection. Gates: make lint-heavy, make test-full (138 passed); CI matrix Python 3.11–3.14 across Linux/macOS plus stress and parity tiers — all green.

v0.15.0 — collection errors fail closed

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 17 Jul 16:10

Collection errors fail closed

A test module that fails to import (ImportError, syntax error, broken module-scope fixture) is silently dropped from pytest's collected items. Before 0.15 the daemon served the shortened suite as if nothing happened: green summary, n quietly smaller, rc=0 — a silently shortened suite looking green is the worst failure mode a test runner can have (observed in the wild: two files with ImportError ran a «green» suite with zero trace).

Now:

  • collect-time failures are captured in the forkserver preload (CollectReport recorder) and shipped to the daemon with the workers' one-time ready frame;
  • the summary grows a loud COLLECT ERRORS (N) block (with per-file tracebacks) right under results :;
  • every run served by that boot forces rc=1 — single-run, persist-pool and bench paths alike;
  • the successfully collected tests still run: you get the full remaining suite AND a red, attributed verdict (semantics of --continue-on-collection-errors, but loud);
  • daemon-plugin run_info gains an additive collect_errors key (list of (nodeid, longrepr)), and the block contract gains conditional collect-errors.

Also: the fuzz-tier noise strategy no longer generates KNOWN outcome strings (hypothesis falsified the categorize-noise property with noise=['failed'] — significance ordering working as designed; the property's domain is genuinely-unknown strings), with the surfaced edge pinned as a deterministic test.

Full matrix green: 3 OS × py3.11–3.14, stress+parity tiers, 125-test dogfood suite.

v0.14.0 — mutation modes: stop-first dispatch, fresh-worker isolation

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 15 Jul 21:09

Mutation runs on warm workers

Two new wrapper-client execution modes over the persistent-worker protocol, built for mutation testing: thousands of short ordered runs against the same suite, where the win is not re-paying the pytest lifecycle and not running past an already-found killer.

stop_on_failure — stop at the first observed failure

request_run(addr, nodeids=[...], stop_on_failure=True) makes a --persist-workers daemon stop dispatching the ordered selection after the first failed/error result. Already-dispatched items finish; the tail is never issued.

  • A trusted short-circuit is reported in run_meta: total (actually dispatched), planned_total (original selection), short_circuited. The scheduler never invents a failure — an early stop is trusted only when backed by a real failed/error result; any other shortfall stays UNTRUSTED.
  • Dispatch switches to eager mode with a per-worker lookahead reservation, so pytest's nextitem fixture semantics survive: module/class fixtures shared by adjacent selected items are set up once, and a short-circuit tears the boundary down to session scope.
  • Requires a --persist-workers daemon; cannot be combined with benchmark mode. request_run_streamed(..., stop_on_failure=True) exposes the same contract for report-consuming tools.

fresh_workers — per-request process isolation

request_run(addr, nodeids=[...], fresh_workers=True) retires the resident pool and runs this request in a newly forked worker — a fresh pytest session per request — while the daemon's completed collection and forkserver controller stay resident. A later ordinary request lazily re-creates the persistent pool. An empty selection works as a cheap barrier that closes session resources (e.g. before resetting an external database). Cannot be combined with stop_on_failure or benchmark mode.

Explicit capability negotiation

Both modes are trailing protocol fields with a mandatory acknowledgement: the daemon confirms the contract in its final frame, and a 0.14+ client rejects an unacknowledged response with rc=2 — an older daemon can never silently run a weaker contract.

Fail-closed selection

A requested nodeid absent from the daemon's collection now rejects the whole request with rc=2 before any selected test runs — on both the persistent and fork-per-request paths. A stale selection can no longer read as an empty green run.

Persistent-session boundary hardening

Between persistent requests only session-scoped fixtures survive: the boundary anchor is now a genuine pytest Item parented directly to the Session, so third-party pytest_runtest_protocol/teardown hooks keep their declared contract, and the previous behavior of the first collected item's module fixtures leaking across requests is gone.

Effect

On a downstream mutation workload over an identical mutant set: roughly 6–11× end-to-end against the original baseline; an isolated parallel mutation lane shows ~2.7× wall-time and ~4.1× on the execution phase with exactly matching outcome statuses. For a stream of N requests, session-scoped setup amortizes from N to one per persistent session.

Verification

Integration tests for stop-first dispatch (single- and multi-worker lookahead), fixture lifecycle across request boundaries, fail-closed unknown nodeids on both paths, capability negotiation against a legacy daemon (both clients), and mode-combination rejections. Gates: make lint-heavy, make test-full (123 passed).

v0.13.0 — block-designed summary: plugins own the whole layout

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 14 Jul 16:35
55d6f80

The summary is yours

The summary box is now rendered as a list of named blocks — top, results, warmup, run, par, [detailed], bus, [failures], [xpass], [durations (full-report) | slowest (lean)], bottom — and daemon plugins (PYTEST_FAST_DAEMON_PLUGINS) get full control over it:

  • pytest_fast_run_completed(run_info) — the additive hook, unchanged: returned lines become a plugin:<mod> block placed right after the stats block.
  • pytest_fast_render_summary(run_info, blocks) — new, full control: receives every named block of the default render (plus earlier plugin:* blocks) and returns the new layout — reorder, drop, rewrite, inject. Returning None keeps the (possibly mutated in place) list. Plugins run in env-list order as a pipeline.

SummaryBlock (TypedDict) is exported for typing. Failure policy extends to the new hook: a raising plugin or a malformed render return degrades to a visible ⚠ line in a plugin-errors block — never a crashed daemon, never a silently-missing gate, and the default layout survives.

Default output is byte-identical when no plugins are configured.

Verification

Layout hook e2e (retitle / reorder / drop blocks), malformed-return degradation, updated seam & degradation tests. Gates: make lint-heavy, make test-full (106 passed), make test-stress (107 passed).

v0.12.1 — plugin sections anchor after the stats block

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 14 Jul 16:25
9ef4b2a

Daemon-plugin summary sections (PYTEST_FAST_DAEMON_PLUGINS) now splice right after the stats block (results/RUN/par/bus) instead of before the closing rule: plugin verdicts are summary-grade signal, detail dumps (FAILURES tracebacks, the SLOWEST table) stay below them. The seam test asserts the position (bus < section < closing rule). No API changes.

v0.12.0 — extension seams for wrappers & plugins

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 14 Jul 15:33
6069b5f

Extension seams — wrappers & plugins are first-class

Building tooling on top of pytest-fast (run-analysis gates, custom reporters, per-test metrics)
previously meant either the heavy full-report streaming client plus private-API imports, or forking
the renderer. 0.12.0 adds three extension seams, one per process role — each using the mechanism
native to where it runs. See the new README section «Extending pytest-fast» for worked examples.

Worker seam — custom per-test measurements on the bus

New hookspec pytest_fast_annotate_result(item, result, extra) — an ordinary pytest hook: conftest
impls already execute inside forked workers (the full pytest protocol runs there), so you measure
with standard hooks/hookwrappers/fixtures and harvest into extra. Whatever you put there rides the
existing worker→master bus as result["extra"], next to duration/cpu. A raising impl degrades to
a stderr note in the daemon log — never a failed test, never an untrusted run.

Per-test CPU time is now a documented stable field: every standard-loop run ships result["cpu"]
(duration − cpu ≈ I/O wait) — the contention-robust signal for timing analysis.

Daemon seam — summary sections inside the box

PYTEST_FAST_DAEMON_PLUGINS=pkg.mod (comma-separated import paths) names plain modules — the
daemon holds every run's aggregated data but, by architecture, no pytest session (collection lives in
the forkserver preload). Each module exposes pytest_fast_run_completed(run_info); returned lines
are spliced INSIDE the summary box, right before the closing rule — how a timing gate or flakiness
tracker "edits" the pretty output without touching pytest-fast. run_info carries results,
worker_stats, bus, total, warmup, run_wall, num_workers, start_method, label.

Failure policy: import error / missing symbol / raising plugin → a visible ⚠ line in the summary —
never a crashed daemon, never a silently-missing gate. The env var participates in the staleness
fingerprint, so changing the plugin list respawns the warm daemon on its own.

Client seam — wrapper clients with full data access

request_run(address, want_results=True) → the final frame also carries results (lean projection:
nodeid/outcome/duration/cpu/extra/longrepr — the heavy per-phase reports are never re-shipped),
worker_stats and run_meta ({total, warmup, run_wall, num_workers, start_method}). ~100 bytes per
test on the wire — full data access without the full-report bus cost.

The flag rides as the 8th positional element of the run-request tuple: compatible in both
directions
(an older daemon ignores trailing elements; an older client is unaffected). Reply frames
are dicts — treat unknown keys as optional; that's the protocol's forward-compat contract.

run_via_daemon is promoted to public API: the ensure/stale-respawn orchestration the CLI and the
--fast plugin use themselves — compose it with request_run(...) / request_run_streamed(...) and
your wrapper gets daemon lifecycle handling for free.

Verification

New e2e suite tests/test_plugin_seams.py: annotate → bus → daemon plugin → box splice (cpu
presence asserted), all three daemon-plugin degradation paths, want_results frame shape against a
resident daemon + plain-frame invariance without the flag. Full gates: make lint-heavy,
make test-full (104 passed), make test-stress (107 passed — the wire changed, so the fuzz/stress
tier was run).

v0.11.0 — opt-in --persist-workers

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 12 Jul 22:56
bbc3a76

opt-in --persist-workers — amortize expensive session-scoped fixtures

By default every run forks fresh workers that exit on completion, so a scope="session" fixture (a DB
engine + schema seed, an app factory, a warmed cache) is set up again on every run — the forkserver
amortizes collect, not fixtures. Many-small-runs clients (a mutation tester issuing one run per
mutant, a fuzz loop, a watch-driven re-runner) re-pay that setup every time, and it dominates wall-clock.

--persist-workers holds a warm worker pool across runs/requests: each worker is forked once and its
pytest session spans every run, so session-scoped fixtures are set up once and reused. Works in both
front-ends — local --runs N and the resident --serve daemon (the many-small-runs path).

Opt-in — it trades away cross-run isolation (arbitrary global state a test mutates persists to the
next run). Isolation within a run is unchanged: function- and module-scoped fixtures still tear down
normally between items.

Correctness: re-running an item requires the run-boundary nextitem to differ from the item being
torn down (else pytest keeps its function-scoped fixtures and the re-run can't re-inject them) — handled
via a session-sharing anchor, regression-tested with --workers 2. Serve-mode verdicts are asserted to
match the default per-run-fork path (every item runs, failures propagate, stable across warm requests).

Full CI matrix green — Linux / macOS / Windows × py3.11–3.14, plus lint, parity, and stress. See #9.

v0.9.3 — performance diagnostics (--detailed + --bench)

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 08 Jun 12:37
a7f1c8e

Two opt-in, CLI-runner-only performance reports (rendered by the warm daemon — no native-pytest controller cost). Everything they report is a deterministic function of measured numbers and a fixed rule, never a heuristic guess. Each worker now also records its CPU time and inter-test bus idle, so the run rectangle decomposes exactly and per-test CPU-vs-I/O is known.

--detailed — why wasn't it faster, and should I add workers?

Extends the par. summary with: parallel efficiency vs the work-conserving ideal; CPU-vs-I/O split with idle core-equivalents (process CPU is low when blocked on a DB → I/O-bound while par. looks full); lost time in absolute worker-seconds (bus vs straggler tail); a balance read (a big test-count spread at near-equal walls is healthy); the duration floor/tail; and a verdict with a deterministic worker-count suggestion — cores / cpu_sat (Little's-law pool sizing), capped by an E-core discount (workers past the perf cores run on slower E-cores and only hide I/O). Always says measure — a shared resource or the E-core tax can cancel the gain.

--bench[=N] — what should I optimize?

Runs the suite N times (default 2; first dropped as warmup), then a targeted cProfile pass over just the top bottleneck tests adds function-level attribution. Ranked by reclaimable worker-seconds:

  • best @ cores — the deterministic ceiling max(Σwork/cores, longest-test).
  • SHARED SETUP clusters — (K−1)·S reclaimable if a fixture is session/module-scopeable (flagged [potential]).
  • per-test hot-spots — slowest calls classified I/O-/CPU-/SETUP-bound; the tip states only what the timings determine.
  • profile rows — top leaves by self time with exact call counts. 667× psycopg2.execute in one test is a measured N+1 / hot-call signal, not a guess. cProfile is stdlib (no dependency); overhead is paid only on the few tests that hold the wall.
  • unstable timing — with ≥2 measured runs, per-test coefficient of variation flags flaky/contended timings.

Also

  • New env vars PYTEST_FAST_WATCH_POLL / PYTEST_FAST_WATCH_DEBOUNCE (watcher reactivity tuning).
  • The project's own test suite went ~18s → ~8s serial / <3s parallel (found with --bench itself).
  • Pure-Python, no new dependency. README documents both reports.

Full changelog: v0.9.0...v0.9.3

v0.9.0 — worker-count guard & fuzz-CI repair

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 08 Jun 09:19
4924c39

Fixes

  • No more silent false-green from workers < 1. --workers 0 / a zero or negative PYTEST_FAST_WORKERS could reach the daemon through the pytest --fast plugin path — 0 workers run nothing, so the session exited green having executed no tests. Worker-count validation is now centralized in _resolve_workers: an explicit < 1 is rejected on every front-end (CLI → parser.error, plugin → pytest.UsageError, Daemon.__init__ → a real ValueError that survives python -O). An unparseable PYTEST_FAST_WORKERS still falls back to auto-detect.
  • Atheris fuzz CI repaired. The job synced the venv on 3.13 and uv pip installed atheris ad-hoc, then ran the harness with a bare uv run, which reconciled the env against .python-version (3.11), rebuilt the venv, and dropped atheris → ModuleNotFoundError before any fuzzing. Now uses uv run --no-sync (CI step + Makefile fuzz target).

New

  • Public worker-count API so external tooling stops importing internals or replicating perf-core detection:
    • pytest_fast.resolve_workers(cli_value=None) and default_workers()
    • pytest-fast --print-inferred-workers — prints the resolved count (honoring --workers / PYTEST_FAST_WORKERS / auto-detect) and exits, e.g. W=$(pytest-fast --print-inferred-workers) in a Makefile.

Tests

8 new cases including a plugin-path regression asserting pytest --fast --fast-workers 0 fails loudly and never reports a pass. Full default suite green across the Linux/macOS × py3.11–3.14 matrix.

Full changelog: v0.8.0...v0.9.0