logoalt Hacker News

m132yesterday at 3:40 PM1 replyview on HN

It's the combination of the two that yields the best of both worlds.

Android SoCs have adopted heterogenous CPU architectures ("big.LITTLE" in the ARM sphere) years before Apple, and as a result, there have been multiple attempts to tackle this in Linux. The latest, upstream, and perhaps the most widely deployed way of efficiently using such processors involves using Energy-Aware Scheduling [1]. This allows the kernel to differentiate between performant and efficient cores, and schedule work accordingly, avoiding situations in which brief workloads are put on P cores and the demanding ones start hogging E cores. Thanks to this, P cores can also be put to sleep when their extra power is not needed, saving power.

One advantage macOS still has over Linux is that its kernel can tell performance-critical and background workloads apart without taking guesses. This is beneficial on all sorts of systems, but particularly shines on those heterogenous ones, allowing unimportant workloads to always occupy E cores, and freeing P cores for loads that would benefit from them, or simply letting them sleep for longer. Apple solved this problem by defining a standard interface for the user-space to communicate such information down [2]. As far as I'm aware, Linux currently lacks an equivalent [3].

Technically, your application can still pin its threads to individual cores, but to know which core is which, it would have to parse information internal to the scheduler. I haven't seen any Linux application that does this.

[1] https://www.kernel.org/doc/html/latest/scheduler/sched-energ...

[2] https://developer.apple.com/library/archive/documentation/Pe...

[3] https://github.com/swiftlang/swift-corelibs-libdispatch?tab=...


Replies

zozbot234yesterday at 4:52 PM

> As far as I'm aware, Linux currently lacks an equivalent

SCHED_BATCH and SCHED_IDLE scheduling policies. They've been there since forever.