Skip to content

Commit

Permalink
Revert "Debugging messages for parallel analysis"
Browse files Browse the repository at this point in the history
This reverts commit 8c5ee83.
  • Loading branch information
ondrejmirtes committed Oct 16, 2020
1 parent cec1be7 commit 2d98ddd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/Command/AnalyseApplication.php
Expand Up @@ -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();
Expand Down
9 changes: 2 additions & 7 deletions src/Command/AnalyserRunner.php
Expand Up @@ -57,8 +57,7 @@ public function runAnalyser(
?string $projectConfigFile,
?string $tmpFile,
?string $insteadOfFile,
InputInterface $input,
Output $output
InputInterface $input
): AnalyserResult
{
$filesCount = count($files);
Expand All @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/Command/FixerWorkerCommand.php
Expand Up @@ -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),
Expand Down
18 changes: 3 additions & 15 deletions src/Parallel/ParallelAnalyser.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Parallel/Process.php
Expand Up @@ -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
{
Expand All @@ -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 = '';
Expand All @@ -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);
});
Expand Down

0 comments on commit 2d98ddd

Please sign in to comment.