-1

I have noticed that sometimes when I open my laptop the battery had dropped to 99% or even 97% after a day or so.

I have it set up to sleep after being closed for 5 seconds, and I've verified that by seeing that if it is closed for longer than five seconds I need to use touch-ID or a password to start using it.

There's probably a smarter way to find out or look up if/when it last entered sleep mode, but I don't know of it.

But sometimes while working I suddenly need to stop for hours or longer, and in some cases I am running Python from iTerm2 and have a matplotlib plot open that I don't want to close (I use widgets and it has a control panel and settings I want to continue to use later).

And sometimes I notice that when I open my MacBook Air again the battery is down.

Testing, I see that I still need to use touch ID after 5 seconds when in this state.

Questions:

  1. Could running Python and Matplotlib be keeping my computer from sleeping?
  2. Is there some way I can find out or look up if/when it last entered sleep mode? This will be helpful in debugging of this problem.

power settings power settings

click for full size

uhoh
  • 1,718
  • One question per question is best. The could this be happening is a pretty poor yes/no question so if you don’t get great answers, maybe rephrase this to be how can I troubleshot sleep on my Mac that runs these programs. – bmike Nov 16 '20 at 02:47

1 Answers1

-1

I have noticed that sometimes when I open my laptop the battery had dropped to 99% or even 97% after a day or so.

A 1 to 3% drop in battery over a 24 to 48 hour period is very normal and expected. When you put your Mac to sleep, any processes will be suspended (provided you don't close the iTerm windows).

The small drop in battery is likely due to PowerNap (MacBook Air support since 2010) which will periodically wake the computer to check for email, updates, sync iCloud documents, messages, notes etc.

Could running Python and Matplotlib be keeping my computer from sleeping?

Could it? Yes. But based on the symptoms you presented, no it's not. Your Mac wouldn't go for "a day or two" and only lose 1-3% charge if there was an active process preventing it from sleeping. A super easy way to confirm this is to check the process of the script (you never mentioned what it does so my answer is generic here), if the script has finished or made progress during that time then it was obviously running. If it's right where you left it, then your Mac was asleep.

Is there some way I can find out or look up if/when it last entered sleep mode? This will be helpful in debugging of this problem.

There's no problem to debug.

What you're seeing is completely normal. A 1-3% (average 2%) battery charge drop over "a day or so" is well within the norm even with PowerNap disabled. If your Mac wasn't sleeping, your complaint would be vastly different - it would be that the battery drained completely and crashed your app/process. To diagnose that issue, you'd issue the command

% pmset -g assertions

That will tell you what's preventing your Mac from sleeping. It should return zeros.

The other reason why "a problem" shouldn't be assumed is that there's a very important distinction between sleep and hibernation. When your Mac sleeps, the CPU goes into a lower power mode (not off) and the current state is held in memory (there's a lot more, but let's limit it to these major functions). This means there is a power draw. If you want to stop the power draw (technically you can't completely stop a battery from discharging due to physics and chemistry governing the battery), you have to hibernate your computer. This is where the state will be written to disk and the power turned off.

Now, to see when your Mac went to sleep, you can obtain the log from pmset as well:

% pmset -g log | grep -i "sleep\|wake" 

The problem with this is that with the newer versions of macOS, the computer will still wake for arbitrary reasons even with PowerNap disabled. I know this because I can hear a bar code scanner "reset" (it makes a tone when connected to USB) periodically even though I have the Mac sleeping with PowerNap disabled. For some reason, it resets the USB bus. I haven't investigated this more because a) it happens on every Mac I've used and b) the Mac has never had any ill effects when woken. All processes were suspended as they were supposed to.

By limiting the scope of symptoms to the drop in battery charge over a period of days, you'll end up looking for solution to a non-problem.

Allan
  • 101,432
  • It's enabled by default. See the link for how to disable (in power settings). As for the 3 percent, over the course of the battery's lifetime isn't going to make any difference. First, you have Batt. Heath Management which was released with Mojave/Catalina that will bring the charge under 90%. Secondly, you will have to have it do a 3% discharge 33 times (100 times for 1%) to be one charge cycle. This is a non-issue for battery life. – Allan Nov 15 '20 at 03:08
  • No. You're conflating two totally different things. A charge cycle is one full discharge and one full charge. Or, to put it another way, it is .03 of a charge cycle. So, if every two days you open the lid of your MacBook and the battery has gone down 3%, it will take you 2.5 months for it to be equal to one charge cycle. Your battery has an expected lifespan between 3 and 5 years. So, in other words, the effect on your battery is significantly less than negligible. This is not something to worry about. – Allan Nov 16 '20 at 00:53
  • The system dropping to around 90-ish percent is the system doing this per Battery Health Management. This is also something you don't want to (and can't actually) micro manage. If you come back in two days and your system has only dropped 3% of battery - it's sleeping. If it were running, you'd be out of battery by the end of the work day (8-12 hours) – Allan Nov 16 '20 at 00:54
  • That link is not relevant. It's looking at battery capacity measured over time not amount of charge left (what you're looking at) which are two very different things. I don't know how else to tell you that what you are seeing is perfectly normal. Your old Mac doesn't have PowerNap nor Battery Health Mgmt nor is it known it's usage pattern. Your Mac is sleeping and what you've described is symptomatic of nothing. That's the answer. You're convinced there's a problem and you want me to prove that there isn't. How do you prove a negative condition? – Allan Nov 16 '20 at 02:13
  • You're also hyper-focused on this 3% number while forgetting you also estimated at the other end a 1% drop. Split it down the middle - 2%. 2% over two days is perfectly normal and symptomatic of nothing. If you're convinced your script is running, then it should have some sort of progress - does it? – Allan Nov 16 '20 at 02:18
  • The question you asked and that I answered is in the first line. But...run this command pmset -g log | grep -i sleep. Post the results. – Allan Nov 16 '20 at 02:29
  • No. You've got several questions in there and I decided to start at what is the core issue - you see symptoms that you perceive as a problem. This type of question is asked a lot - many of them fall under the category "I am hacked;" this one just happens to be about power consumption. It's not "why are you asking" it's "here's why there's no problem to solve." – Allan Nov 16 '20 at 04:32
  • That was my fear. There's a presumption of a problem and the fact there are many log entries will reinforce that. However, in the last hour, I updated my answer significantly. – Allan Nov 16 '20 at 04:40