Whatever your use case may be, it is possible on at least macOS 10.15+ to modify the number of CPU cores that are currently online or available in realtime. The available CPU core count can be modified using a utility called cpuctl
.
To get a list of currently active CPU cores issue sudo cpuctl list
. This will output which cores are currently active. Here is the output on my two core, four thread MBP:
sudo cpuctl list Password: CPU0: online type=7,8 master=1 CPU1: online type=7,8 master=0 CPU2: online type=7,8 master=0 CPU3: online type=7,8 master=0
To limit core count to just two issue sudo cpuctl offline 2 3
. Now a list will show the following:
CPU0: online type=7,8 master=1 CPU1: online type=7,8 master=0 CPU2: offline type=7,8 master=0 CPU3: offline type=7,8 master=0
To bring them back online a simple online operation can be done – sudo cpuctl online 2 3
. Now the listing has returned the normal:
CPU0: online type=7,8 master=1 CPU1: online type=7,8 master=0 CPU2: online type=7,8 master=0 CPU3: online type=7,8 master=0
Keep in mind you should not offline the CPU marked as “master”, doing so will cause your system to become unresponsive even if you leave others running.
For detailed information take a look at the man page for it (man cpuctl
).