Comment by pauljara

2 days ago

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.

  • 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.

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.

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.

      1 reply →

  • > 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.

      7 replies →

    • > 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.

      1 reply →

    • 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?