-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* syntax sugar * sequential option - no shortcut, as we do not use shortcut for other any other option * explicitly mark `ProcessFactory::getCommandArgs` as `@private`, to indicate it shall not be called from outside of this class, ref #7777 (comment) * `WorkerCommand` options written as single-liners, so unified as all other commands and easier to copy-paste * add explicit comment for hardcoded option * remove unused var * rename `ParallelRunnerConfigInterface` to `ParallelAwareConfigInterface` * make `ParallelConfig` only DTO and externalize factory methods to dedicated class * `Runner` - don't reevaluate `maxFixerPerProcess` in each loop * explicitly call generator, avoid simple 'job' as too similar to job-id * rename variables related to file chunks
- Loading branch information
Showing
18 changed files
with
159 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of PHP CS Fixer. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* Dariusz Rumiński <dariusz.ruminski@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace PhpCsFixer\Runner\Parallel; | ||
|
||
use Fidry\CpuCoreCounter\CpuCoreCounter; | ||
use Fidry\CpuCoreCounter\Finder\DummyCpuCoreFinder; | ||
use Fidry\CpuCoreCounter\Finder\FinderRegistry; | ||
|
||
/** | ||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com> | ||
*/ | ||
final class ParallelConfigFactory | ||
{ | ||
private function __construct() {} | ||
|
||
public static function sequential(): ParallelConfig | ||
{ | ||
return new ParallelConfig(1); | ||
} | ||
|
||
/** | ||
* @param null|positive-int $filesPerProcess | ||
* @param null|positive-int $processTimeout | ||
*/ | ||
public static function detect( | ||
?int $filesPerProcess = null, | ||
?int $processTimeout = null | ||
): ParallelConfig { | ||
$counter = new CpuCoreCounter([ | ||
...FinderRegistry::getDefaultLogicalFinders(), | ||
new DummyCpuCoreFinder(1), | ||
]); | ||
|
||
return new ParallelConfig( | ||
...array_filter( | ||
[$counter->getCount(), $filesPerProcess, $processTimeout], | ||
static fn ($value): bool => null !== $value | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.