How does macOS decide when to use M1's performance vs. efficiency cores?

Solution 1:

In general the developer of the software can choose (or at least strongly indicate to the operating system) which type of core to use. The developer sets a quality-of-service expectation and the operating system generally follows that.

In addition to the developer supplied QoS expectation, the operating system monitors the application's workload over a period of time, as well as the whole system's workload over a period of time, and use heuristics to make an overall decision on whether to schedule a specific thread on a P-core (performance) or E-core (energy).

Note that applications and background processes are treated differently in this respect. For example a GUI application could be treated differently whether its window(s) are in the foreground or in the background. For background processes (such as BOINC computation) that doesn't apply.

You can read a relatively non-technical overview of how it works here:

https://developer.apple.com/news/?id=vk3m204o

And a bit more specifics (but still overview information) about the QoS-classes here:

https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon

Note that it is actually often possible for you as the user to override the QoS-class set by the developer. Get the PID (process ID) of the BOINC job you want to affect (using for example Activity Monitor) - and then use the taskpolicy command to set a new quality-of-service class.

Solution 2:

By the load set by you.

The more programs or more likely an algorithm that looks at the processor loading based on the activities in progress which brings in more or fewer cores as needed to meet a given performance rating.

Most processors will max out when provided with mains power and are throttled when on battery for a longer life.