This used to happen to my MacBook Pro, although it was a non Apple Silicon one. The issue was that I had changed the DHCP lease time on my router from the default to a really low value. I believe I had set it to 15 minutes. What I believe was happening was the MBP was waking up to renew its IP address every 15 minutes and by the time it went to sleep again, it was probably waking back up to repeat the process. Changing the value on the router back to its default completely fixed the battery drain issue on my MacBook Pro. I'd never have guessed the cause-effect except I made the change around the same time I purchased that new MacBook Pro and was paying more attention to any issues that might arise.
A functional DHCP client will request renewal of it's IP address 50% of the way through the lease, so it was probably worse than you thought.
> I had changed the DHCP lease time on my router from the default to a really low value. I believe I had set it to 15 minutes.
What were you hoping to achieve by doing that?
I like low lease times. DHCP server knows what's really on the network, and if something requests lots and lots of the pool you'll be fine in 15-30 minutes.
If things are set to a really long time, >=12 hours, you find out the next day when everything is broken (or you get alerts in the middle of the night). If you set them to a randomized 15-90m span, you get things breaking immediately when you screw up the dhcp server.
Hah. Your answer just has more questions. What on earth is requesting so many DHCP leases?
You've never accidentally spun something up that consumes all the leases?
It's just been a couple of times, but I've definitely done it (e.g. bridged a couple of networks that shouldn't have been).
But mostly, it's the other two things: it provides me with a list of hosts active now, and if the DHCP server is subtly broken I get a sentinel signal of something being wrong earlier (and it tends to be a partial instead of complete failure).
One more bonus: if I move something to a static lease, out of the pool, it'll renumber in a reasonable time and I don't need to go kick link state to get it to request again.
Things like really big caches and really long lease times: They're good for average performance, and they can let you ride out small problems. The flip side is that they tend to mask problems and to create really big demand transients at times. The trick is always to find a good middle ground.
Excellent answer - new appreciation for low lease times, thank you
Yeah, there's a lot of room to play between 900 and 86400 seconds.
Extremes of any sort generally aren't good. You fucked around and you found that out.
> You fucked around and you found that out.
I haven't had any notable issues with values in the 600-1200 second range, actually. (My macs don't wakeup to keepalive network on battery, though).
Modern devices will randomize MAC unless told not to when connecting / reconnecting to a wifi/Ethernet network.
When on a pretty standard /24 network subnet, if there are more than a few dozen devices coming and going, the lease table can fill up until older lease reservations expire.
I was trying to determine if a lease expired, if my router would immediately try to lease that same IP out to another machine on the network. It felt like it cached an expired lease mapping and would try to keep that old IP un-leased in case the original machine to which it was mapped came back online. I was just trying to better understand the behaviour.
Did you want certain IPs to be fixed to certain devices or do you prefer they be randomly allocated?
Neither really, though my ISP's router would allow me to assign IPs by MAC address so they're effectively reserved to a device. The router's web UI displayed a list of devices. I wanted to see if devices would start dropping off this list as soon as the DHCP lease time expired. When they did drop off this list, I had thought they reappeared with the same IP without me explicitly using the reservation functionality. So how was this happening? I figured the web UI might not be showing the full picture of all the data about devices; that the router held records of formerly connected devices beyond the DHCP lease time for some unknown reason.
That is so weird. How much mAh can a single “wake and renew lease” possibly take? Like it has to be milliamp-milliseconds (mAmS?). I mean my phone is chattering with the cell network probably all the time even in a fairly deep sleep mode. The laptop is lighting up the WiFi stack to send and receive (and process) like a few packets?
Like you said though, it’s pre Apple silicon so who really knows! Maybe it decided to do some other stuff while it was awake?
Your cell phone modem is completely decoupled from the main processor and is a complete, independent system in itself, so it's optimized to do that.
Bluetooth and WiFi radios on Macs are also semi-independent. They can keep connections alive while the system is in deep sleep.
Waking a big processor, frequency scaling it and turning it off is surprisingly complicated. We disabled SpeedStep in our clusters since frequency scaling visibly affected performance of the systems due to overhead incurred by frequency change. Same is true for waking / sleeping big silicon.
It's complicated, it's wasteful.
Some of the Intel's biggest improvements as their micro-architecture evolved were reduction of the frequency scaling overhead and its performance impact, but this never made the news back in the day because its effect was invisible in consumer class systems even in its most primitive form.
> Maybe it decided to do some other stuff while it was awake?
That's called Power Nap and is enabled only if your computer is connected to power, by default.
It may stay on longer than the amount of time it takes to renew. Perhaps for every wake it stays on for 60 seconds; it is also doing other things like checking mail.
I wonder if some user-space process lights up and throws a wrench in things.
I’m sure both Microsoft and Apple have entire teams with incredibly full backlogs dealing with power management. And I’m sure half their time is spent dealing with “messes” caused by other teams doing wild and crazy (but somehow theoretically useful) shit.
It’s clearly not an easy problem.
Woah just found out my router (mikrotik) defaults to 10 minute lease durations.
Mine defaults to 24h on RouterOS 7.16.x.
This is a macOS bug; it doesn’t need an IP address while it’s asleep. Waking up to renew a DHCP lease is crazy.
Closed source OSes are such a bane.
That’s a little obtuse. Macs can still poll for certain messages while they’re asleep (Power Nap.)
Macs doesn't need to wake completely to renew their DHCP leases. Bluetooth and Wi-Fi radios can act independently and on their own for this low level operations.
On the other hand, I don't consider my computer to wake up, take a backup, check system/app updates and my mails and handle those while I'm sleeping as a feature, not a bug.
That is pre-Apple Silicon, before together integration of software and wakeups.
I can see a continuously renewed DHCP lease — with nothing else - useful for reducing the time to reconnected to your network, esp maybe on old/slow networks or routers.
You can Touch ID and get back in a second, and maybe for 5-10% of users, it was resulting in initial network connection slowdowns or errors with buggy online-only apps.
Find My (your device wants to maintain a connection if you have it enabled) is another reason. It must regularly connect (perhaps a long running socket), and I want to be able to remotely lock and wipe my device at any time possible, for example.
> That is pre-Apple Silicon, before together integration of software and wakeups.
My 2014 Intel MacBook Pro has Power Nap and behaves the same when it comes to radios when compared to my M1. It's not new.
> it was resulting in initial network connection slowdowns or errors with buggy online-only apps.
Just because your radio is up, connected to the AP and keeping L2 active doesn't mean your processor/OS is keeping TCP connections up, or even talked to the hardware and updated itself. It's normal.
Find My doesn't keep a connection open 24/7. It pulls the commands the moment system wakes up. I have it enabled and check my devices sometimes, and it's not extraordinary to see "15 minutes ago" or "2 hours ago" for a laptop sitting on the table, not connected to power and its lid closed.
> This is a macOS bug; it doesn’t need an IP address while it’s asleep. Waking up to renew a DHCP lease is crazy.
It's actually not. As a user I'd expect the device to wake up and still have the same IP address via a continuation of the lease.
Yes, the correct way would be a longer lived DHCP lease, but el-cheapo ISP routers often lock down such settings.
Interesting, as a different user, I'd expect the opposite: If my computer is "asleep" I don't expect it to do anything, and it shouldn't be able to wake itself up.
The definition of waking itself up is unclear. Surely you expect clicking on your mouse or typing in the keyboard wakes it up? That means USB events or Bluetooth can wake your computer. Still it's user-triggered and doesn't count as waking itself up. And I expect that initiating an SSH connection to that computer causes it to wake up, because I initiated that SSH connection; so it doesn't count as waking itself up. I further configured my computer to back up to my NAS every day at midnight. Since I configured it myself I expect it to wake up on a timer and it still doesn't count as waking itself up.
that's called "off".
Turning a machine off loses any existing application state, and requires both applications and the OS to be re-launched.
When I put a machine into standby, I want it to go in a standby state, and then stay there until I explicitly wake it -- not keep doing whatever background tasks the OS developers, app developers, or whatever other third parties think they need to keep doing.
Btw, what’s the functionality which needs this half sleep state with running WiFi and Bluetooth? Laptops worked for decades without this, and I’ve never felt the need to change this. It caused headache for me too many times, and I don’t even know why I would need this.
i suppose we have come to expect 4 states: - off: no power, no activity - hibernate: no power, no activity session state saved to non-volatile storage - sleep: Minimal power, RAM remains powered with the session state, can be resumed quickly - on
now we essentially have sleep++ and no option to set it back to vanilla sleep.
Those are the states I expect, indeed, but lately I find them increasingly unreliable. I've had Windows unable to sleep, Linux crashing after hibernating, MacOS issues are addressed aplenty here.
I thought this was a solved issue. How are all OSs suddenly so bad at this? I only really trust on and off anymore.
You do have that option, it's just not the defaut.
For most people these days the primary device is their phone, and so that is the model that modern laptops are trying to follow, as that is what most users will expect.
> As a user I'd expect the device to wake up and still have the same IP address via a continuation of the lease.
Most users don't know what IP addresses even are, let alone care what theirs is. I don't think Apple is (or should be) optimizing for you.
Okay, then… As a user I’d expect the device not to waste any time connecting to my wireless network and getting a dhcp lease, instead being already connected when I open the lid.
This is a good point (running processes might break if the IP address suddenly changed after wake-up). However, why should the renewal process take on the order of 15 minutes? And why would it require a complete wake up?