Parallel Execution & Thread Budget¶
Speed up your QA runs by distributing work across multiple CPU cores.
Enable parallel execution¶
Set processes in your flow options:
'flows' => [
'options' => [
'processes' => 4, // total CPU cores budget
],
'qa' => ['jobs' => ['phpcs_src', 'phpstan_src', 'phpmd_src', 'parallel_lint']],
],
Or override from the CLI:
How thread budgeting works¶
The processes value is the total CPU cores available, not the number of parallel jobs. GitHooks distributes threads across jobs that support internal parallelism:
| Tool | Internal parallelism flag |
|---|---|
| phpcs / phpcbf | --parallel |
| parallel-lint | -j |
| psalm | --threads |
| phpstan | Worker count from .neon config (read-only) |
For example, with processes: 4 and two threadable jobs (phpcs and parallel-lint), each gets approximately 2 threads.
Monitor thread usage¶
Use --monitor to see the actual thread usage after execution:
Check your system¶
Shows detected CPU count and current processes configuration. Warns if processes exceeds available CPUs.
Tips¶
- Start with
processesequal to your CPU core count. - PHPStan worker count is configured in the
.neonfile (maximumNumberOfProcesses), not via GitHooks. It is accounted for in the budget but not adjustable at runtime. - Use
--monitorto verify that the budget is being distributed as expected.