Featured image of post Rant: Modern Standby

Rant: Modern Standby

The Laptop That Couldn’t Sleep

I need to sleep

I can’t get no sleep

— Faithless

Retirement

After over fourteen years of trusted service, my veritable Asus K73 notebook started choking on 3D models. With mixed feelings I decided it was time to replace my beloved computer and retire it to a less demanding job. It now sits in my home workshop to be used for firmware debugging and some occasional logic sniffing.

As a replacement I ordered a refurbished 2021 Dell Precision 7550.

A few days later it arrived, in pristine condition and with a fresh Windows 11 Pro install. I tested the core features and then upgraded the operating system (that is, I wiped it and installed my favorite flavour of Linux1). I played with the machine for a bit, ran some benchmark tools and for one blissful moment I was a very happy man.

Until one morning when I found my new gadget with a dead battery. At first I thought I hadn’t put it in standby mode properly, so I recharged it and called it a day. But then, one evening while sitting on the couch enjoying some snacks and a beer, I thought I heard a distant fan noise.

I went to investigate and found the laptop - which had absolutely been put in standby this time - huffing and puffing as loudly as it could and trying to burn the varnish off my tabletop in the process. What was going on here?

In all honesty, I had encountered similar behavior in my work laptop (also a Precision 7550) in the past. I had however always assumed it was a Windows thing.

It turned out it wasn’t Windows…

Machine Insomnia

Apparently, in the over-a-decade when I lived a quiet life with my near-vintage machine, a new standby mode has been invented. It’s called ‘Modern Standby’, with modern in this context meaning: keeping parts of the computer running so it can do things while you think it’s sleeping. Microsoft Windows uses this to install updates or fetch emails when you’re not watching.

So, when I tell my beast of a workstation to go to sleep, it keeps one eye open and can start doing whatever it feels like.

Why is this a problem? Well, mobile workstations come with serious processors and serious graphics chips and they happen to get seriously hot, too. So when you shove your laptop in your bag after a day of running simulations and CAD models, it had better be sleeping tightly or it might seriously overheat (or set your bag on fire, which tends to be awkward). High performance machines and thermal issues aside, it’s also quite annoying to find your laptop with dead battery when you were planning on using it for something enjoyable.

How Devices Sleep

For the uninitiated, let’s take some time to elaborate on what going into standby actually means for a computer. This also applies to phones, tablets and e-readers because those are in fact small, portable computers.

The various internal organs of the computer (e.g. its processor, graphics system, connectivity devices, storage devices) can be turned off or put into a low power mode to save energy. The operating system is responsible for turning off or on the components. In order for the operating system to have knowledge of and control over the power states of its components, the ACPI2 standard was released in the early two-thousands. The standard defines an interface between the software and the power management hardware. Back in the day, the ACPI standard gave five sleep options to choose from, conveniently named S1 to S5. There is also an S0 state, but that’s not really a sleep state as everything keeps running and only the display of the device is turned off. So the computer is really just feigning sleep in that state.

Here’s a short description of each member of the sleep state family.

  • S1: The CPU stops but is not powered down. RAM remains powered on and most other devices are powered down.
  • S2: The CPU stops and its power is turned off. The contents of its registers are moved to RAM, which remains on. Other devices are powered down too.
  • S3: Suspend to RAM. Essentially S2 but in this state the power supply is also powered down (only supplying standby power). The RAM (which is dynamic RAM and needs some maintenance) is refreshed periodically.
  • S4: The contents of the RAM are being written to the hard disk (or other storage device, i.e. SSD) and then everything is powered down. The computer is off (can even be powered down by a mechanical switch) but restores its previous state when powered up again.
  • S5: This is called soft off, and by modern day standards it’s just means your computer is off. Though technically speaking it is still powered because part of the electronics remain active to watch for the power button to be pressed. In earlier days there were mechanical on/off switches that truly disconnected your device from the mains supply but those are as good as extinct now. But for the power-down purists out there, S5 is a sleep state.

Modernizing Sleep

The relatively new kid in sleep town is called s0ix, or modern standby. You could call it the bastard child of S2 and S0. It’s called a sleep mode, but in reality it just turns off your monitor and freezes user applications. The CPU does power down but can wake up periodically to perform background tasks.

You might be wondering who would invent such a bad implementation of a standby mode. It turns out to be a company that in some circles is infamous for their poorly implemented software. They call themselves Microsoft. Yes, Microsoft. They concocted a standard called ‘InstantGo’ 3 and introduced it in Windows 8.1. It was later renamed to Modern Standby (or Modern Sleep). Let’s have a look at how they see it 4.

Microsoft conceputalizes modern sleep as equivalent to traditional S3 sleep, with the added benefit of allowing value-added software activities to run periodically.

Value-added software activities. I never knew Microsoft were able to make value-added software. Frankly, if you consider this Modern Standby to be an equivalent to S3 sleep, I can only conclude that you completely misunderstood the concept of sleep states.

But there’s more. Running software isn’t the only reason for keeping computers half awake. Dell give an interesting bit of background on another motive behind Modern Standby on their website 5:

Microsoft introduced Modern Standby in 2012 to improve battery life and the transition between power states, allowing Windows computers to transition between on or off states faster, like your smartphone does.

Looks like Microsoft want Windows to be more like the real mobile operating systems. Pity the battery life improvement didn’t work out. I hate to break it, but keeping a computer from staying in standby does not normally increase battery life. Running ‘value-added’ software takes more energy than keeping everything suspended to RAM (i.e. S3 sleep).

To be honest, the concept of Modern Standby absolutely makes sense for mobile devices like phones. It’s actually what your phone does all the time. Phones are designed to be used periodically and then get shoved back into your pocket or handbag. They have to respond quickly to incoming calls or text messages and have to wake up immediately if you need them. Traditional S3 sleep doesn’t cut it for phones and tablets because it takes a few seconds to wake up from, and while the device sleeps, it’s unconnected.

Laptop computers on the other hand have a completely different use case. You actually use your laptop computer for the majority of time and put it in standby when you carry it around or go for a break. It only has to wake up from sleep every now and then. It will take a few seconds to wake up from the S3 state, but is that really a problem? Modern Standby shaves a few seconds off the wake-up time to give that instant-on experience. But do you really always need that for the couple of times a day when you wake your computer? And is it worth the severe degradation in battery life? I think it isn’t and to me it feels like Modern Standby in laptop computers favors convenience over functionality. As for the background tasks running, I doubt whether it makes a difference if that email comes thirty seconds later and Windows updates can be run at the next reboot if you ask me. Updates will always remain annoying so let’s not also sacrifice battery life for it.

The Cure (for Linux)

With most phones running Linux, it is obvious that the Linux Kernel also implements Modern Standby. It’s called S2idle6 and personally I find that a more fitting name than Modern Standby. On the Linux Kernel website it is described as a standby mode for devices that don’t support deeper sleep states. The point of reduced latency when resuming from sleep is also mentioned. I think those are better reasons to implement a half-baked sleep mode than to run ‘value-added software’.

While I like the S2idle name better, I can’t deny I was a little disappointed to find out that this sleep mode seems to be the default setting in many (or all?) Linux flavours. I tried to find out a bit more about what a Linux system is supposed to be doing when it periodically wakes up but I was unable to find anything concrete. According to the Linux kernel website the system can be woken from hardware interrupts but I couldn’t figure out what specific interrupt woke up my own system or why it didn’t return to sleep after handling it.

Luckily, there is way around S2idle in Linux, but only if the S3 sleep state is still supported by your hardware. I found some forum posts online of people not being able to choose S3 instead of S2Idle and that may indicate that not all hardware out there still supports suspend to RAM. In some cases however there is a BIOS setting that has to be changed in order to enable S3.

To find out if your Linux box supports S3 (or deep sleep), you will have to take a look in the /sys/power/mem_sleep system file. In there you will find all the supported sleep modes with the current default mode showing in square brackets. A system that supports both S3 and S2idle would show you the following:

[s2idle] deep

In this case the system default is S2idle, but deep sleep (S3) is available as an option. The default sleep state for the current session can be changed by writing the desired state to /sys/power/mem_sleep:

echo deep > /sys/power/mem_sleep

The mem_sleep file will then contain:

deep [s2idle]

This fix will only last until the next reboot. For a permanent solution the boot loader settings have to be changed in order to send an extra argument to the kernel at boot time. This is done by editing /etc/default/grub. Find the following parameter:

GRUB_CMDLINE_LINUX_DEFAULT

And add:

mem_sleep_default=deep

Then run:

update-grub

Sleep Tight

So, although the issue was highly annoying and induced in me a fear of having bought a computer that would drain its battery forever (and potentially set fire to itself), it got fixed in the end. The computer can now sleep soundly again. Personally, I would have appreciated it if this hadn’t been made the default option for laptop computers. Phones, yes, but laptops, no.

As a bonus for anyone running Debian on a Dell Precision: check out this Github page.

Built with Hugo
Theme Stack designed by Jimmy