perf(tests): replace behave-parallel subprocess model with in-process parallelism #490

Closed
brent.edwards wants to merge 1 commits from perf/in-process-parallel-behave into perf/optimize-medium-features

1 Commits

Author SHA1 Message Date
brent.edwards 6223313677 perf(tests): replace behave-parallel subprocess model with in-process parallelism
Replace the subprocess-per-feature execution model with direct use of
behave's Runner API.  The new CLI supports two modes:

* Sequential (--processes 1 or BEHAVE_PARALLEL_COVERAGE=1): all
  features run in a single Runner.run() call.  Step definitions and
  environment hooks load once.

* Parallel (--processes N, N>1): features split into N chunks and
  dispatched to a multiprocessing.Pool using the fork start method.
  Heavy modules (cleveragents, SQLAlchemy, behave) are imported in the
  parent and shared copy-on-write with forked workers.  Each worker
  creates its own Runner, but every import is a cache hit.

The coverage_report session now wraps the entire behave-parallel
process with a single slipcover invocation instead of wrapping each
subprocess individually.  This eliminates per-worker UUID files and
the post-run merge step.

Key metrics:
  unit_tests:      24m 21s -> 2m 05s (91% reduction)
  coverage_report: 75m 20s -> 3m 00s (96% reduction)
  Coverage:        98% (above 97% threshold)
  All 342 features pass (335 pass in parallel, 331 in sequential,
  4-5 pre-existing failures, 7 skipped)

Part of #478. Closes #481.
2026-03-01 08:37:08 +00:00