Hacker News new | ask | show | jobs
by causi 1678 days ago
high CPU usage by kernel_task is caused by high Thunderbolt Left Proximity temperature, which is caused by charging and having normal peripherals plugged in at the same time.

Did anyone ever figure out why exactly the temperature sensor was making kernel_task go crazy?

1 comments

The comment by jksoegaard may explain it: "the purpose of the thread is to force idleness". I guess it uses up all the CPU without actually making the CPU do anything, so other processes can't use the CPU and produce more heat than it can handle.
Wow! This brings back memories. I don't remember which generation of CPUs this was.. maybe Pentium III or AthlonXP. But there was an issue in Windows where the chip would overheat when idle.

There was an app called Rain that you could download and it would just keep the idle process from running away and causing heat. I may need to research this on my lunch break and report back.

EDIT: Here's a related thread: https://arstechnica.com/civis/viewtopic.php?f=8&t=1060257

That wasn't exactly an issue, more like a feature that didn't exist yet.

The Pentium IIIs were the first CPUs that could consume enough power to cause heat problems if not throttled. OSes didn't yet anticipate that; they didn't yet have the concept of issuing halt instructions when there was no application work to do, they just let the CPU spin faster on a waiting-for-message loop. The OS makers soon recognized the need, and halting the CPU became built in to the OS by the time of either Windows 98 or 2000, so yeah, in the interim, tools like Rain were what you used.

> One of the functions of kernel_task is to help manage CPU temperature by making the CPU less available to processes that are using it intensely. In other words, kernel_task responds to conditions that cause your CPU to become too hot

If it's about CPU temperature, why does Apple schedule a task instead of just downclocking the CPU, like everyone else? This question predates the release of M1 Macbooks, and everyone else does thermal management of Intel Core processors via clock speed, not artificial idle load.

I'm not an expert, but I know are two forms of throttling under MacOS – the CPU frequency limit, and the "scheduling limit". The CPU reduces frequency under thermal stress just like other machines, but there's a minimum frequency that it can be downclocked to. So if that's not enough to meet the thermal envelope, the scheduler will additionally start to limit the amount of CPU time that can be used. I notice this in particular when the GPU is at full whack – such as running multiple external displays at high resolution with 3D graphics.
I've had my Mac mini throttle down to 180Mhz under Linux (due to incorrect ACPI settings), to the point where I could see the window elements being drawn :) So at least that generation Intel was capable of pretty extreme downclocking.
They almost certainly do adjust CPU frequency as well (although I don't have a 2020 Mac to check this). Lowering the frequency would mean fewer instructions can be processed per second which means you are more likely to see a higher CPU usage for all tasks. What you see is probably the combination of both of these effects.

It's annoying that the process monitor does not provide any way to distinguish high CPU load due to demand and high CPU load due to a low clock frequency but there is software that can display a CPU frequency chart which can give some insight:

https://pietschsoft.com/post/2020/02/15/macos-monitor-cpu-us...

> does not provide any way to distinguish high CPU load due to demand and high CPU load due to a low clock frequency

If you're on Linux, then the "tiptop" utility does just this.

The high cpu usage is essentially the evidence for running certain power-saving measures that "look" like the task is using a lot of CPU time (it does, sleeping the cpu).

There's similar behaviour on linux but it shows as specific kernel threads related to intel power throttling, so it's more obvious what's happening.

It would reduce latency of tasks to do it this way.
That's very interesting. I didn't know it was possible for a process to use the CPU without using the CPU, as it were. Rather I thought the CPU usage was more or less a direct measurement.
From [1]

On processors that have a halt instruction that stops the CPU until an interrupt occurs, such as x86's HLT instruction, it may save significant amounts of power and heat if the idle task consists of a loop which repeatedly executes HLT instructions.

--

I don't know how it is implemented in darwin, HLT is a privileged instruction, then again it's kernel_task.

1: https://en.m.wikipedia.org/wiki/Idle_(CPU)

I would expect that the CPU frequency would throttle down, rather than regularly running halt instructions.