sched-ext / scx

sched_ext schedulers and tools
https://bit.ly/scx_slack
GNU General Public License v2.0
844 stars 79 forks source link

scx_lavd: core compaction for low power consumption #338

Closed multics69 closed 3 months ago

multics69 commented 4 months ago

When system-wide CPU utilization is low, it is very likely all the CPUs are running with very low utilization. That means all CPUs run with low clock frequency thanks to dynamic frequency scaling and very frequently go in and out from/to C-state. That results in low performance (i.e., low clock frequency) and high power consumption (i.e., frequent P-/C-state transition).

The idea of core compaction is using less number of CPUs when system-wide CPU utilization is low. The chosen cores (called "active cores") will run in higher utilization and higher clock frequency, and the rest of the cores (called "idle cores") will be in a C-state for a much longer duration. Thus, the core compaction can achieve higher performance with lower power consumption.

One potential problem of core compaction is latency spikes when all the active cores are overloaded. A few techniques are incorporated to solve this problem.

1) Limit the active CPU core's utilization below a certain limit (say 50%).

2) Do not use the core compaction when the system-wide utilization is moderate (say 50%).

3) Do not enforce the core compaction for kernel and pinned user-space tasks since they are manually optimized for performance.

In my experiments, under a wide range of system-wide CPU utilization (5%—80%), the core compaction reduces 7-20% power consumption without sacrificing average and 99p tail latency.