From 2d98ddda8c95a42f1b9ceeaab5fc7c8a2272941a Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Fri, 16 Oct 2020 14:14:41 +0200 Subject: [PATCH] Revert "Debugging messages for parallel analysis" This reverts commit 8c5ee834f8c20da1fd96adfe0332c34a9a7a7323. --- src/Command/AnalyseApplication.php | 2 +- src/Command/AnalyserRunner.php | 9 ++------- src/Command/FixerWorkerCommand.php | 3 +-- src/Parallel/ParallelAnalyser.php | 18 +++--------------- src/Parallel/Process.php | 6 +++--- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/Command/AnalyseApplication.php b/src/Command/AnalyseApplication.php index 708b350b51..dd2e1a69aa 100644 --- a/src/Command/AnalyseApplication.php +++ b/src/Command/AnalyseApplication.php @@ -186,7 +186,7 @@ private function runAnalyser( $postFileCallback = null; } - $analyserResult = $this->analyserRunner->runAnalyser($files, $allAnalysedFiles, $preFileCallback, $postFileCallback, $debug, true, $projectConfigFile, null, null, $input, $errorOutput); + $analyserResult = $this->analyserRunner->runAnalyser($files, $allAnalysedFiles, $preFileCallback, $postFileCallback, $debug, true, $projectConfigFile, null, null, $input); if (isset($progressStarted) && $progressStarted) { $errorOutput->getStyle()->progressFinish(); diff --git a/src/Command/AnalyserRunner.php b/src/Command/AnalyserRunner.php index 19443d9370..055cb95d66 100644 --- a/src/Command/AnalyserRunner.php +++ b/src/Command/AnalyserRunner.php @@ -57,8 +57,7 @@ public function runAnalyser( ?string $projectConfigFile, ?string $tmpFile, ?string $insteadOfFile, - InputInterface $input, - Output $output + InputInterface $input ): AnalyserResult { $filesCount = count($files); @@ -72,17 +71,13 @@ public function runAnalyser( $mainScript = $_SERVER['argv'][0]; } - if ($output->isDebug()) { - $output->writeLineFormatted(sprintf('Schedule: %d processes, %d jobs', $schedule->getNumberOfProcesses(), count($schedule->getJobs()))); - } - if ( !$debug && $allowParallel && $mainScript !== null && $schedule->getNumberOfProcesses() > 1 ) { - return $this->parallelAnalyser->analyse($schedule, $mainScript, $postFileCallback, $projectConfigFile, $tmpFile, $insteadOfFile, $input, $output); + return $this->parallelAnalyser->analyse($schedule, $mainScript, $postFileCallback, $projectConfigFile, $tmpFile, $insteadOfFile, $input); } return $this->analyser->analyse( diff --git a/src/Command/FixerWorkerCommand.php b/src/Command/FixerWorkerCommand.php index 34938b5596..f191ac5c99 100644 --- a/src/Command/FixerWorkerCommand.php +++ b/src/Command/FixerWorkerCommand.php @@ -154,8 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $configuration, $tmpFile, $insteadOfFile, - $input, - $inceptionResult->getErrorOutput() + $input ); $result = $resultCacheManager->process( $this->switchTmpFileInAnalyserResult($intermediateAnalyserResult, $tmpFile, $insteadOfFile), diff --git a/src/Parallel/ParallelAnalyser.php b/src/Parallel/ParallelAnalyser.php index eb0395aaf4..7160e10716 100644 --- a/src/Parallel/ParallelAnalyser.php +++ b/src/Parallel/ParallelAnalyser.php @@ -7,7 +7,6 @@ use Nette\Utils\Random; use PHPStan\Analyser\AnalyserResult; use PHPStan\Analyser\Error; -use PHPStan\Command\Output; use PHPStan\Dependency\ExportedNode; use PHPStan\Process\ProcessHelper; use React\EventLoop\StreamSelectLoop; @@ -53,8 +52,7 @@ public function analyse( ?string $projectConfigFile, ?string $tmpFile, ?string $insteadOfFile, - InputInterface $input, - Output $errorOutput + InputInterface $input ): AnalyserResult { $jobs = array_reverse($schedule->getJobs()); @@ -133,7 +131,7 @@ public function analyse( $commandOptions, $input ), $loop, $this->processTimeout); - $process->start(function (array $json) use ($process, &$internalErrors, &$errors, &$dependencies, &$exportedNodes, &$jobs, $postFileCallback, &$internalErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier, $errorOutput): void { + $process->start(function (array $json) use ($process, &$internalErrors, &$errors, &$dependencies, &$exportedNodes, &$jobs, $postFileCallback, &$internalErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier): void { foreach ($json['errors'] as $jsonError) { if (is_string($jsonError)) { $internalErrors[] = sprintf('Internal error: %s', $jsonError); @@ -177,24 +175,14 @@ public function analyse( } if (count($jobs) === 0) { - if ($errorOutput->isDebug()) { - $errorOutput->writeLineFormatted(sprintf('Process %s ended successfully - no more jobs remaining.', $processIdentifier)); - } $this->processPool->quitProcess($processIdentifier); return; } - if ($errorOutput->isDebug()) { - $errorOutput->writeLineFormatted(sprintf('Process %s analysis successful - queueing a new job.', $processIdentifier)); - } - $job = array_pop($jobs); $process->request(['action' => 'analyse', 'files' => $job]); - }, $handleError, function ($exitCode, $termSignal, string $output) use (&$internalErrors, &$internalErrorsCount, $processIdentifier, $errorOutput): void { + }, $handleError, function ($exitCode, string $output) use (&$internalErrors, &$internalErrorsCount, $processIdentifier): void { $this->processPool->tryQuitProcess($processIdentifier); - if ($errorOutput->isDebug()) { - $errorOutput->writeLineFormatted(sprintf('Process %s exited - exit code %s, term signal %s, output: %s', $processIdentifier, $exitCode ?? 'null', $termSignal ?? 'null', $output)); - } if ($exitCode === 0) { return; } diff --git a/src/Parallel/Process.php b/src/Parallel/Process.php index 6f697a22f0..944b575239 100644 --- a/src/Parallel/Process.php +++ b/src/Parallel/Process.php @@ -48,7 +48,7 @@ public function __construct( /** * @param callable(mixed[] $json) : void $onData * @param callable(\Throwable $exception) : void $onError - * @param callable(?int $exitCode, ?int $termSignal, string $output) : void $onExit + * @param callable(?int $exitCode, string $output) : void $onExit */ public function start(callable $onData, callable $onError, callable $onExit): void { @@ -69,7 +69,7 @@ public function start(callable $onData, callable $onError, callable $onExit): vo $this->process->start($this->loop); $this->onData = $onData; $this->onError = $onError; - $this->process->on('exit', function ($exitCode, $termSignal) use ($onExit): void { + $this->process->on('exit', function ($exitCode) use ($onExit): void { $this->cancelTimer(); $output = ''; @@ -84,7 +84,7 @@ public function start(callable $onData, callable $onError, callable $onExit): vo if (is_string($stdErr)) { $output .= $stdErr; } - $onExit($exitCode, $termSignal, $output); + $onExit($exitCode, $output); fclose($this->stdOut); fclose($this->stdErr); });