New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate FidryCpuCoreCounter #2047
Integrate FidryCpuCoreCounter #2047
Conversation
One idea I have - it should differentiate between physical and virtual cores, offer different getters for that. That'd be really valuable. I want to use the virtual cores, no matter the operating system. I understand that on systems with hyperthreading, But of course it might be more complicated, I'm not a hardware expert. |
And if PHPStan should be able to use this library, right now it needs to support PHP 7.2+. |
6f0998a
to
22a9bfa
Compare
@ondrejmirtes should be good; there is now a distinction possible between physical and logical cores. The default picked is logical (as PHP source does and as was done previously here). If you fancy checking out what finder finds what, to find a bug or play around with the order or something, I can recommend those commands |
I really like your work, the library looks nice! But it looks like there's a related failure: https://github.com/phpstan/phpstan-src/actions/runs/3647730351/jobs/6160310175 |
Indeed and the failure is related I think. It's curious though as this is a piece of code coming from Infection and I thought I tested the case where the commands would fail... will look into it, but will probably have to rely on the CI here for that, at least partially |
Nevermind it's windows related, I'll be able to check that on a machine at home soon :) |
22a9bfa
to
eadd1a5
Compare
@ondrejmirtes green |
Not really: * https://github.com/phpstan/phpstan-src/actions/runs/3648030637/jobs/6161060710
|
827322b
to
2610417
Compare
See theofidry/cpu-core-counter#11 for the motivations. The code should be sensibly the same, the notable differences are: - fixed the deprecated usage of `hw.ncpu` - /proc/cpuinfo is check _last_ - nproc is checked first (before was not checked at all, it's considered to be more accurate and less convoluted than cpuinfo though) - not sure about the `return 2`, but this was not too clear [here](phpstan#514 (review)) neither. I could otherwise change the fallback value to return `1` if `proc_open` doesn't exist and 2 otherwise - add more ways to find the CPU cores count
2610417
to
ea9605a
Compare
@ondrejmirtes FINALLY it is green |
Nice :) Please definitely be ready for a round of feedback once this is released, maybe we broke some scenario that isn't in the test suite, but that's fine, it's an "unknown unknown", so if we learn about it, the better :) |
Thank you! |
See theofidry/cpu-core-counter#11 for the motivations.
The code should be sensibly the same, the notable differences are:
hw.ncpu
return 2
, but this was not too clear here neither. I could otherwise change the fallback value to return1
ifproc_open
doesn't exist and 2 otherwiseI would also wait on 1.x before merging this if you're happy with it. Technically the current version is fine, I'm just looking for a round of feedback before publishing 1.0.