Long story short, my oldie MBP 2011' battery started bloating, I've contacted a repair service center and they advised me to remove the battery and use it on AC power, while they get a new battery for a replacement. What I've noticed a few days back, that my MBP starts extremely lagging from time to time. After a restart, it works fine for 12 - 20 hours and then the problem appears again. I've noticed that when the lagging starts, kernel_task begins consuming up to 500% CPU. So I bet that the problem's source is kernel_task, but what causes its extreme rise? Could it be a removed battery?
2 Answers
One troubleshooting step is to see which files are being modified while kernel_task is consuming 500% CPU. In Terminal:
sudo fs_usage -f filesys
You will see a lot of files fly by. Just scroll up to get an idea of what files are being written or read.
-
I would add that
sysdiagnose
would be amazing to run - perhaps once after a clean restart after the Mac is off for an hour or more, and once before the problem happens but the Mac is up to operating temp and RAM usage in addition to a snapshot when the problem is reproduced. That would cover cases where filesystem usage isn't the culprit - butfs_usage
would nail it if it were filesystem activity as a root cause.– bmike ♦Commented Feb 5, 2015 at 14:35
Actually, I have heard anecdotal evidence that removal of the battery does cause the system to throttle the CPU under certain circumstances. I also believe this can cause the kernel task to "absorb" the theoretical CPU capacity that would be there if it were running at full frequency.
The steps to isolate this would be to monitor the internal temperatures when the anomalous performance statistics are in effect. By keeping the machine cool, you will be sending a signal to the CPU that it can run at full capacity. Also, if the magsafe power adapter is getting old or the power circuitry on the Mac is starting to fail, it could also cause the internal voltages to drop and that also could affect the CPU.
It's much, much, much more likely you have a run of the mill software bug where some program has a memory leak or spins off children processes - so running sudo sysdiagnose
before and during the periods of bad activity will help collect the logs needed to tell if it's an ordinary software issue or a much less likely "oddball" effect of having no battery to keep the voltage high when current draw is high and/or some aging hardware that is interacting with the CPU throttling firmware.