Detect number of performance core on Apple Silicon at runtime

Hello, I have a macOS application which can utilize several CPU cores at the same time. For optimal performance, I need to know the number of CPU cores at runtime. On Intel-based Macs it was possible to get the number of available cores by running sysctl hw.ncpu.

Now on Apple Silicon SoCs, sysctl hw.ncpu returns the total count of performance and efficiency cores. This is problematic for me since I need to use the performace cores only. Using the performance and efficiency cores at the same time causes the performance cores to run at the same speed as the efficiency cores (which is very slow).

Is there some way to detect the number of performance cores at runtime?

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

Detect number of performance core on Apple Silicon at runtime
 
 
Q