Closed sebastianbergmann closed 1 month ago
Hi @sebastianbergmann, thanks for reporting the problem. Unfortunately, most probably this is not something we can do on our side, as we utilise fidry/cpu-core-counter
which does the CPU auto-detection. We can only suggest creating an issue there, or configuring Fixer with the exact ParallelConfig
you would like to use.
But maybe @theofidry can suggest if there's something we can fix on our side? We currently use FinderRegistry::getDefaultLogicalFinders()
with a fallback to 1 core using DummyCpuCoreFinder
.
I ran cpu-core-finder
's bin/diagnose.php
script and saw that it looks at the output from nproc --all
. This prints 128
for me:
❯ nproc --all
128
However, just nproc
prints the correct number (or at least the number I would expect):
❯ nproc
6
We blindly rely on cpu-core-finder logic, I believe this should be raised/fixed there.
It's already in progress in https://github.com/theofidry/cpu-core-counter/pull/127, when this is released, we need to change the usage to utilise new API.
what is the part there that would change to have 6
and not 128
?
it would change that instead:
->getCount() - 1 OR 1 if crashed
we would have
->getAvailableParallelism()
but getAvailableParallelism
calls getCount
under the hood, right? I dont see the fix for 128 vs 6
@keradus
I will add more parameters in the future to address the points mentioned above, but they will be added as default parameters hence will not break the API.
I think we just need to use new API and it will at some point detect CPUs properly 😅. @theofidry correct me if I'm wrong 🙂.
I think we just need to use new API and it will at some point detect CPUs properly
Yes the incorrect number of cores detected there is a separate issue and will be addressed separately.
Checking again this issue, I could reproduce it temporarily: this is due to the VMWare configuration which overcommits the resources available.
This is a bit annoying as I expected nproc to be more reliable than the CPU info... I guess I'll have to revisit that.
I can no longer reproduce this:
❯ ./tools/php-cs-fixer fix
PHP CS Fixer 3.64.0 (209f776) Space Sets by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.11
Running analysis on 6 cores with 10 files per process.
Thanks @sebastianbergmann for self-maintenance and the feedback 🍻!
Problem description
I am using PHP-CS-Fixer inside a virtual machine (VMware Workstation 17 Pro) that is running Fedora 40. This virtual machine has 6 cores, as can be seen by looking at
/proc/cpuinfo
:However, PHP-CS-Fixer detects 128 cores:
In this virtual machine, the parallel test runner is siginificantly slower than the sequential runner, especially when there is nothing to fix (3.849 seconds parallel, 0.034 seconds sequential):
Minimal reproducer
Not applicable.
Fixer version
3.59.3
PHP version
8.3.9
How do you run Fixer?
PHAR
Contribution Checks