Skip to content

Adaptive parallelism: adjust the parallel test limit from machine load and throughput #7871

Done

Description

@thomhurst

Summary

The number of tests that run at once is a fixed number: 2 x the processor count, or whatever --maximum-parallel-tests sets. That is too low for suites of asynchronous I/O-bound tests, which leave the machine mostly idle, and too high for suites whose tests use a lot of memory or CPU. Users have to find a good number by trial and error for each suite and each machine.

Proposal

Add an opt-in adaptive mode that changes the limit while the run is in progress:

  • Raise the limit step by step while tests are waiting for a slot, the machine has CPU and memory headroom, and the previous raise increased the rate at which tests complete.
  • Stop raising once a raise brings no more throughput. This covers suites limited by something outside the process, such as a database connection pool, where idle CPU does not mean more tests would help.
  • Lower the limit when memory is under pressure, or when the CPUs are saturated and work is queuing for a thread.
  • Treat an explicit --maximum-parallel-tests (or its environment variable and settings equivalents) as a hard upper bound.
  • Log each change of the limit so a run can be understood afterwards.

Enable it with a command-line flag, an environment variable or TUnitSettings. The fixed limit stays the default until benchmarks across CPU-bound, asynchronous I/O, blocking I/O and memory-heavy suites show the adaptive mode is at least as fast everywhere.

Background

An earlier adaptive controller (#2792) was removed in #2825 two days after it was added. This proposal differs in using throughput feedback as the signal for raising the limit, with machine metrics only as guards.

Activity

  1. added
    enhancement
    on Nov 28, 2026
  2. added
    performance
    P3
    on Nov 28, 2026
  3. added a commit that references this issue on Nov 29, 2026
    3c70937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3enhancementperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions