Skip to content

Commit 9406203

Browse files
committed
Removed parallel processing from output, when using '--debug'.
1 parent 0e8fb2d commit 9406203

4 files changed

Lines changed: 11 additions & 22 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,12 @@ jobs:
440440
cd e2e/vvv-with-debug
441441
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv --debug test.php 2>&1)
442442
echo "$OUTPUT"
443-
../bashunit -a contains '# of spawned processes: 1' "$OUTPUT"
443+
../bashunit -a not_contains 'Parallel processing scheduler' "$OUTPUT"
444444
- script: |
445445
cd e2e/vvv-with-debug
446446
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv --debug --configuration parallel.neon test.php 2>&1)
447447
echo "$OUTPUT"
448-
../bashunit -a contains '# of spawned processes: 1' "$OUTPUT"
448+
../bashunit -a not_contains 'Parallel processing scheduler' "$OUTPUT"
449449
450450
steps:
451451
- name: Harden the runner (Audit all outbound calls)

src/Command/AnalyserRunner.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,20 @@ public function runAnalyser(
7171
);
7272
}
7373

74-
$schedule = $this->scheduler->scheduleWork($this->cpuCoreCounter->getNumberOfCpuCores(), $files, $debug);
75-
$mainScript = null;
76-
if (isset($_SERVER['argv'][0]) && is_file($_SERVER['argv'][0])) {
77-
$mainScript = $_SERVER['argv'][0];
78-
}
79-
8074
if (
8175
!$debug
8276
&& $allowParallel
8377
&& function_exists('proc_open')
8478
&& $mainScript !== null
8579
&& $schedule->getNumberOfProcesses() > 0
8680
) {
81+
$schedule = $this->scheduler->scheduleWork($this->cpuCoreCounter->getNumberOfCpuCores(), $files);
82+
83+
$mainScript = null;
84+
if (isset($_SERVER['argv'][0]) && is_file($_SERVER['argv'][0])) {
85+
$mainScript = $_SERVER['argv'][0];
86+
}
87+
8788
$loop = new StreamSelectLoop();
8889
$result = null;
8990
$promise = $this->parallelAnalyser->analyse($loop, $schedule, $mainScript, $postFileCallback, $projectConfigFile, $tmpFile, $insteadOfFile, $input, null);

src/Parallel/Scheduler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ public function __construct(
4242
public function scheduleWork(
4343
int $cpuCores,
4444
array $files,
45-
bool $debug = false,
4645
): Schedule
4746
{
4847
$jobs = array_chunk($files, $this->jobSize);
49-
$numberOfProcesses = $debug ? 1 : min(
48+
$numberOfProcesses = min(
5049
max((int) floor(count($jobs) / $this->minimumNumberOfJobsPerProcess), 1),
5150
$cpuCores,
5251
);

tests/PHPStan/Parallel/SchedulerTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@ public static function dataSchedule(): array
6868
1,
6969
[1],
7070
],
71-
[
72-
16,
73-
16,
74-
2,
75-
20,
76-
100,
77-
1,
78-
[20, 20, 20, 20, 20],
79-
true,
80-
],
8171
];
8272
}
8373

@@ -97,12 +87,11 @@ public function testSchedule(
9787
int $numberOfFiles,
9888
int $expectedNumberOfProcesses,
9989
array $expectedJobSizes,
100-
bool $debug = false,
10190
): void
10291
{
10392
$files = array_fill(0, $numberOfFiles, 'file.php');
10493
$scheduler = new Scheduler($jobSize, $maximumNumberOfProcesses, $minimumNumberOfJobsPerProcess);
105-
$schedule = $scheduler->scheduleWork($cpuCores, $files, $debug);
94+
$schedule = $scheduler->scheduleWork($cpuCores, $files);
10695

10796
$this->assertSame($expectedNumberOfProcesses, $schedule->getNumberOfProcesses());
10897
$jobSizes = array_map(static fn (array $job): int => count($job), $schedule->getJobs());

0 commit comments

Comments
 (0)