How to get the number of high-performance cores on Apple Silicon?

I have the legacy app that maintain its own thread pool to do cpu intensive work. It uses NSProcessInfo.processInfo.activeProcessorCount to get number cores and max thread pool size. It worked quite fine for Intel-based Macs but for Apple Silicon Macs it does not make much sense to create more threads than there are high-performance cores.

How do I get the number of high-performance cores on Apple Silicon Macs?
I also have this question.

Can we utilize all 8 cores or only 4 cores at once?

If only 4 cores are available, how we should detect a number of really available cores?

If all 8 cores are available, we should know a number of high-performance cores and number of high-efficienty cores.

I hope to get a reply from Apple.


If you still seek the answer, then you can get the Performance cores via sysctl along with:

hw.perflevel0.physicalcpu OR hw.perflevel0.physicalcpu_max OR hw.perflevel0.logicalcpu OR hw.perflevel0.logicalcpu_max

and for Efficiency cores:

hw.perflevel1.physicalcpu OR hw.perflevel1.physicalcpu_max OR hw.perflevel1.logicalcpu OR hw.perflevel1.logicalcpu_max

.logicalcpu and .logicalcpu_max are probably max threads (which is 1:1 for M1 Macs)

Regards

How to get the number of high-performance cores on Apple Silicon?
 
 
Q