Re: [RFC] Add num_available_processors
On Sat, May 24, 2025, at 19:37, Daniel Kesselberg wrote:
> Hi everyone,
>
> I'm happy to share my first RFC :) It proposes adding a small function
> to retrieve the number of available processors; a feature that's
> commonly found in other programming languages and one that I believe
> would be a useful addition to PHP.
>
> The related PR has already received a bit of early traction, and now
> that the RFC is complete, I'm looking forward to your feedback!
>
> RFC: https://wiki.php.net/RFC/num_available_processors
> Patch: https://github.com/php/php-src/pull/11137
>
> Best
> Daniel
>
Looks good!
My main question is: what is this actually counting? In the RFC it mentions "available
processing units" ... which means, what? What counts as a "processing unit"? Are we
talking about CPU Threads/cores; NPU cores; TPM cores; clocks? GPS? GPU? ... a modern computer has
many "processing units" for different purposes and workloads. I’m assuming this is CPU
Threads, not physical cores? I will refer to CPU Threads as "Logical Cores" so we all
don’t get confused since most of us here are programmers and saying "thread" has a
different meaning.
Secondly, how is it counting "available"? If I assign PHP to a specific CPU affinity mask
(say one logical core), will it return 1, or the total number of logical cores available on my
machine? I would expect it to be 1, since PHP only has access to 1, but I can also see the logic in
returning the total number.
— Rob
Thread (14 messages)