How to execute terminal command on energy efficient cores on M1 chip? I want to run nodejs process on E cores, but when I run it I see that it uses P cores even if there is a 0.3 second task.
What you want to do is technically known as setting a &quot;CPU affinity&quot;, i.e. letting the operating system scheduler know, which CPU core a process should be allowed to run on.
As far as I know, macOS does not come with a GUI or command line program for setting CPU affinity. This is unlike some other operating systems, such as for example Linux that features a simple taskset command for that purpose.
However, the absence of a nice tool does not mean that it is impossible to do. Far from it. Apple does provide an API for programmers that allow them to set CPU affinity.
As you indicate that you want to set the CPU affinity for various nodejs processes, it seems likely that you're developing software or running open-source software where you can modify the source code. In that case you can set the CPU affinity by way of the thread_policy_set() function.
For example if you have a Mach thread named thread that you want to schedule only on core #7, you can do it like this:
thread_affinity_policy_data_t policy = { 7 };
thread_policy_set(thread, THREAD_AFFINITY_POLICY, (thread_policy_t)&amp;policy, 1);