Skip to content

Commit b2d447a

Browse files
authored
Merge branch refs/heads/2.1.x into 2.2.x
2 parents 4b00cbf + 89f1382 commit b2d447a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

conf/config.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ parameters:
9292
parallel:
9393
jobSize: 20
9494
processTimeout: 600.0
95-
maximumNumberOfProcesses: 32
95+
maximumNumberOfProcesses: 8
9696
minimumNumberOfJobsPerProcess: 2
9797
buffer: 134217728 # 128 MB
98+
loadLimit: 1.0
9899
phpVersion: null
99100
polluteScopeWithLoopInitialAssignments: true
100101
polluteScopeWithAlwaysIterableForeach: true

conf/parametersSchema.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ parametersSchema:
9999
processTimeout: float(),
100100
maximumNumberOfProcesses: int(),
101101
minimumNumberOfJobsPerProcess: int(),
102-
buffer: int()
102+
buffer: int(),
103+
loadLimit: schema(float(), nullable())
103104
])
104105
phpVersion: schema(anyOf(
105106
schema(int(), min(70100), max(80599)),

src/Process/CpuCoreCounter.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Fidry\CpuCoreCounter\CpuCoreCounter as FidryCpuCoreCounter;
66
use Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
7+
use PHPStan\DependencyInjection\AutowiredParameter;
78
use PHPStan\DependencyInjection\AutowiredService;
89

910
#[AutowiredService]
@@ -12,14 +13,21 @@ final class CpuCoreCounter
1213

1314
private ?int $count = null;
1415

16+
public function __construct(
17+
#[AutowiredParameter(ref: '%parallel.loadLimit%')]
18+
private ?float $loadLimit,
19+
)
20+
{
21+
}
22+
1523
public function getNumberOfCpuCores(): int
1624
{
1725
if ($this->count !== null) {
1826
return $this->count;
1927
}
2028

2129
try {
22-
$this->count = (new FidryCpuCoreCounter())->getCount();
30+
$this->count = (new FidryCpuCoreCounter())->getAvailableForParallelisation(0, null, $this->loadLimit)->availableCpus;
2331
} catch (NumberOfCpuCoreNotFound) {
2432
$this->count = 1;
2533
}

0 commit comments

Comments
 (0)