How Parallel Execution Skews Duration Percentiles in CI

A flat P95 duration line on a test dashboard is easy to read as stability. Under parallel execution it often is not. JUnit XML records each test's elapsed time, but not whether it ran on an idle worker or one contending for CPU, a shared database container or a browser pool. Change the worker count and the percentile shifts even when no test changed, and a genuine slowdown can hide inside the noise.

This matters more in agentic quality engineering. Coding agents add tests quickly and sometimes adjust parallelism or timeouts to get a pipeline green, which changes the topology the numbers depend on. And suites that call a model or drive an agent add a new kind of duration: provider latency and rate limiting, which get worse as more workers hit the same endpoint at once.

This article explains why wall-clock time and test duration diverge under parallelism, how to capture worker-aware timing with pytest-xdist and GitHub Actions, which queries separate real regressions from topology noise, and how to report the duration of model-calling tests without letting them distort everything else.

Build an API Automation Framework in Python

Learn Python, Behave, GitHub Copilot, APIs, and CI/CD by building a real framework you can finish in a weekend.

Learn more

Why Wall-Clock Time and Test Duration Diverge Under Parallelism

JUnit XML records time as the elapsed seconds from test start to test end, measured inside the test process. That number is accurate in isolation. The problem is that "isolated" is a fiction in a parallel run: workers share host CPUs, memory bandwidth, disk I/O, and — critically — any shared fixture setup (database containers, Selenium grids, Playwright browser contexts). A test that takes 400 ms on a quiet worker takes 900 ms on a saturated one. Both numbers land in the same percentile bucket with no label distinguishing them. When you track duration variance as a stability signal, this noise floor makes genuine regressions invisible until they're severe.

Worker count is also a pipeline variable, not a test variable. GitHub Actions matrix jobs, pytest-xdist -n auto, and Buildkite parallel steps all change worker count based on queue depth, runner availability, or explicit config changes. None of those changes appear in the JUnit XML that your Allure or ReportPortal instance ingests. So your test execution dashboard visualization is plotting a dependent variable (test duration) while silently changing an independent variable (parallelism level) — and calling the result a trend.

Capturing Worker-Aware Timing in GitHub Actions and pytest-xdist

The fix starts at instrumentation. You need to record worker ID, worker count, and queue wait time alongside test duration — and that data has to survive into whatever store your dashboard queries. For GitHub Actions test results, the matrix context gives you the worker index for free; the gap is that standard JUnit XML doesn't carry it. An autouse fixture in conftest.py can attach it to every test as a custom property. pytest-xdist sets PYTEST_XDIST_WORKER and PYTEST_XDIST_WORKER_COUNT in each worker process; the matrix values come from the workflow:

# conftest.py — attach worker metadata to each JUnit XML test case
import os
import pytest


@pytest.fixture(autouse=True)
def _worker_metadata(record_property):
    record_property("worker_id", os.environ.get("PYTEST_XDIST_WORKER", "main"))
    record_property("worker_count", os.environ.get("PYTEST_XDIST_WORKER_COUNT", "1"))
    record_property("matrix_index", os.environ.get("MATRIX_INDEX", "0"))
    record_property("matrix_size", os.environ.get("MATRIX_SIZE", "1"))

pytest's JUnit XML output serializes recorded properties as <property> nodes inside each <testcase>. From there, parsing JUnit XML to extract structured signals gives you the worker context you need for normalization. Store it in PostgreSQL or ClickHouse with a worker_count column and you can group by it in every duration query.

The GitHub Actions YAML side is straightforward — pass the matrix index and size as env vars so they are available to the conftest (splitting the suite across matrix jobs is omitted here):

# .github/workflows/test.yml (excerpt)
jobs:
  test:
    strategy:
      matrix:
        index: [0, 1, 2, 3]
    steps:
      - name: Run tests
        env:
          MATRIX_INDEX: ${{ matrix.index }}
          MATRIX_SIZE: 4
        run: pytest -n 4 --junitxml=results-${{ matrix.index }}.xml

Once worker count is a first-class column, your duration queries can normalize against it. The key insight: compare percentiles only within the same worker-count bucket. In PostgreSQL:

-- P95 duration grouped by worker topology, last 30 days
SELECT
    worker_count,
    test_name,
    PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY duration_ms) AS p95_ms,
    COUNT(*) AS sample_count
FROM test_runs
WHERE run_date >= NOW() - INTERVAL '30 days'
GROUP BY worker_count, test_name
HAVING COUNT(*) >= 20
ORDER BY p95_ms DESC;

Bucketing like this often shows that a single "stable" P95 is really several distributions, one per worker count, each with its own median. An apparent improvement over a quarter can turn out to be nothing more than a change in how many workers ran the suite. Filtering the dashboard by worker count by default keeps that from being reported as progress.

Where Experienced Teams Still Get Burned by Parallelism Metrics

Averaging across merged XML reports. When GitHub Actions matrix jobs each produce a separate JUnit XML file and your CI step merges them with a tool like junit-merge or Allure's collector, the merge discards the per-file worker context. The merged report looks like a single serial run. Engineers who know to look for this still get caught when a new pipeline stage is added by someone else and the merge step silently absorbs the new topology. Guard against it by validating that worker_count properties are present before merge, or by storing pre-merge artifacts separately in your test results store.

Using suite-level duration as a proxy for test-level health. The wall-clock time of the full CI job — what GitHub Actions reports as job duration — reflects the slowest worker, not the average test. Teams that alert on job duration as a test health signal are actually alerting on load-balancing efficiency. It's a useful ops metric, but it tells you nothing about which specific tests are regressing. Separate your pipeline observability (job duration, queue wait, runner utilization) from your test observability (per-test P95, variance, flake rate) and route them to different dashboards with different alert thresholds.

Duration of model-calling tests is a different measurement

A test that calls an LLM or runs an agent loop spends most of its time waiting on a model endpoint. Its duration depends on the model, the prompt length, the number of tool calls the agent chose to make, and whether the provider throttled the request. Parallelism amplifies the last one: eight workers sending requests at once are more likely to hit rate limits and back off than two. Put those tests in the same percentile as ordinary API tests and the P95 tracks your provider's load, not your code.

Record the extra context as JUnit properties so it can be grouped and filtered like worker count:

import pytest


@pytest.fixture
def model_call_metadata(record_property):
    """Tests that call a model update this dict; it is written as JUnit properties."""
    meta = {"model": "unknown", "tool_calls": 0, "retries": 0}
    yield meta
    for key, value in meta.items():
        record_property(key, value)

Then report these tests on their own panel: duration percentiles per model and per worker count, with tool-call count alongside. A rise in duration that comes with a rise in tool calls usually means the agent's behaviour changed after a prompt or model update, which is worth investigating even if every test still passes. A rise that comes with retries points to throttling, which is a capacity question.

The same discipline applies to changes made by coding agents. When an agent's pull request changes -n, the matrix, or a timeout, the dashboard should show the topology change next to the duration change, so a reviewer can tell a faster suite from a differently measured one.

Myths About Duration Percentiles That Survive in Most Dashboards

"P95 duration is stable, so the suite is healthy." Stability in a percentile that's computed across mixed worker topologies means nothing. You can have a test that regressed by 3× on a 4-worker run, but because most samples in the window came from 8-worker runs (where contention happened to be lower), the P95 barely moves. The regression is real; the metric hides it. The correction is to track P95 within a fixed worker-count cohort and alert on deviation from that cohort's baseline, not from a global rolling average. This is the same structural problem that makes branch filtering skew pass rates in multi-pipeline views — mixing populations that aren't comparable.

"Adding workers always makes the suite faster." Beyond a certain parallelism level, shared-resource contention (Docker-in-Docker, a single Postgres container, a Selenium hub with a fixed pool) causes test durations to increase even as wall-clock job time decreases. Teams that scale workers to cut CI time and then wonder why their P95 per test is climbing are hitting this ceiling. Profile your fixture setup cost separately from test execution cost — OpenTelemetry spans around pytest_sessionstart and fixture teardown give you the breakdown without requiring a full distributed tracing stack.

Duration percentiles are only meaningful when the execution topology is held constant or explicitly modeled as a variable. Start by adding worker_count as a first-class column in your test results store, then rewrite your dashboard queries to group by it before computing any percentile. If you want to go deeper on what duration signals can actually tell you about suite stability, the analysis of duration variance as a leading indicator is the logical next read.

Note: This article is for informational purposes only and is not a substitute for professional advice. If you need guidance on specific situations described in this article, consider consulting a qualified professional.

Understanding how systems actually work is the first step toward navigating them effectively.

Browse all articles