Run Pint analysis in Parallel
thbley opened this issue · 6 comments
Pint Version
v1.16.0
PHP Version
8.3.7
Description
Currently pint is always running in sequential mode. Running in parallel would be very nice!
Problem probably related to FixCode::execute() line 60 missing arguments for ParallelConfig and InputInterface.
Steps To Reproduce
Normal execute, use top to verify that only 1 php process is running instead of multiple.
Thanks for your proposal! Right now we don't have plans for this. Should you wish, you're free to attempt a PR yourself. Thanks!
Pint should be able to support running in parallel. I only see it running single-threaded as well.
As the Autor of the PR, I hoped, that pint would run in parallel without much of a hassle. But there could be more adjustments which need to be done, like something with building the binary. (This needs experimentation time and probably a good understanding about processes)
You are always free to try a PR, to make adjustments, so that pint actually runs in parallel. As this is only an improvement.
Looked a bit into this and I think there are several issues.
As initially mentioned above, due to the direct usage of Runner
, ParallelConfig
and InputInterface
need to be passed as arguments (otherwise it will fallback to sequential).
The bigger issue is the way how processes are created here https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/src/Runner/Parallel/ProcessFactory.php#L27
In a phar realpath
will not work and it seems as a workaround a check based on argv
and php-cs-fixer
is used to define the binary to be executed in spawned processes.
Additionally the wrong assumption that several arguments are present in the input (when called through pint) will lead to issues.
I don't see a clean way to solve this using the current approach, without adjustments to PHP-CS-Fixer.
In a project with ~5000 php files to analyze, it takes several minutes to run Pint. It feels like a major downgrade when switching from native php-cs-fixer.