File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ parameters:
9595 maximumNumberOfProcesses : 8
9696 minimumNumberOfJobsPerProcess : 2
9797 buffer : 134217728 # 128 MB
98+ loadLimit : 1.0
9899 phpVersion : null
99100 polluteScopeWithLoopInitialAssignments : true
100101 polluteScopeWithAlwaysIterableForeach : true
Original file line number Diff line number Diff 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 )),
Original file line number Diff line number Diff line change 44
55use Fidry \CpuCoreCounter \CpuCoreCounter as FidryCpuCoreCounter ;
66use Fidry \CpuCoreCounter \NumberOfCpuCoreNotFound ;
7+ use PHPStan \DependencyInjection \AutowiredParameter ;
78use 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 }
You can’t perform that action at this time.
0 commit comments