Parallelism vs Matrix Jobs for Large Test Suite Distribution
0 reputation · 31 Aug 2023, 21:19 UTC
0 reputation · 31 Aug 2023, 21:19 UTC
When optimizing build throughput for a large test suite in CircleCI, there are two primary mechanisms for distributing workloads across multiple containers: the parallelism key and matrix jobs.
Parallelism allows a single job definition to be split across N containers, which requires utilizing the circleci tests split CLI tool and maintaining a timing file to ensure an even distribution of tests. In contrast, matrix jobs execute predefined permutations of environment variables, creating distinct jobs that do not require external data-splitting logic.
The choice between these two depends on whether the goal is to reduce wall-clock time for a monolithic suite or to validate compatibility across different environments. However, it remains unclear how the scheduler manages resource allocation priority when a project simultaneously triggers high-concurrency matrix permutations and high-parallelism jobs.
1. Does the scheduler prioritize a single parallelized job over multiple matrix permutations?
No. The scheduler treats every job instance the same; a parallel job with N containers consumes N concurrency units, and each matrix permutation consumes one unit unless a custom resource class is used. Allocation is based on availability and the order jobs appear in the workflow, not on job type.
2. What is the impact on queue latency when both strategies compete for the same organization‑level concurrency quota?
When the total units requested exceed the quota, the first job that can be satisfied starts immediately. Subsequent jobs wait, and their queue times grow roughly with the number of pending units. The effect is proportional to how many parallel containers and matrix permutations are queued.
A parallelism: N job is seen by the scheduler as N independent job instances. A matrix job creates one instance per permutation. Both consume one concurrency unit per instance (or per resource class). The scheduler’s allocation algorithm is FIFO within a workflow, so the first job that fits the available units starts; others wait until units free up.
requires / hold to enforce ordering.Could you share your current organization‑level concurrency quota? That number will determine whether queue latency is driven more by job ordering or by the quota itself.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.