May 10th, 2011

Why is hybrid sleep off by default on laptops? (and how do I turn it on?)

Hybrid sleep is a type of sleep state that combines sleep and hibernate. When you put the computer into a hybrid sleep state, it writes out all its RAM to the hard drive (just like a hibernate), and then goes into a low power state that keeps RAM refreshed (just like a sleep). The idea is that you can resume the computer quickly from sleep, but if there is a power failure or some other catastrophe, you can still restore the computer from hibernation.

A hybrid sleep can be converted to a hibernation by simply turning off the power. By comparison, a normal sleep requires resuming the computer to full power in order to write out the hibernation file. Back in the Windows XP days, I would sometimes see the computer in the next room spontaneously turn itself on: I’m startled at first, but then I see on the screen that the system is hibernating, and I understand what’s going on.

Hybrid sleep is on by default for desktop systems but off by default on laptops. Why this choice?

First of all, desktops are at higher risk of the power outage scenario wherein a loss of power (either due to a genuine power outage or simply unplugging the computer by mistake) causes all work in progress to be lost. Desktop computers typically don’t have a backup battery, so a loss of power means instant loss of sleep state. By comparison, laptop computers have a battery which can bridge across power outages.

Furthermore, laptops have a safety against battery drain: When battery power gets dangerously low, it can perform an emergency hibernate.

Laptop manufacturers also requested that hybrid sleep be off by default. They didn’t want the hard drive to be active for a long time while the system is suspending, because when users suspend a laptop, it’s often in the form of “Close the lid, pick up the laptop from the desk, throw it into a bag, head out.” Performing large quantities of disk I/O at a moment when the computer is physically being jostled around increases the risk that one of those I/O’s will go bad. This pattern doesn’t exist for desktops: When you suspend a desktop computer, you just leave it there and let it do its thing.

Of course, you can override this default easily from the Control Panel. Under Power Options, select Change plan settings, then Changed advanced power settings, and wander over into the Sleep section of the configuration tree.

If you’re a command line sort of person, you can use this insanely geeky command line to enable hybrid sleep when running on AC power in Balanced mode:

powercfg -setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e
                          238c9fa8-0aad-41ed-83f4-97be242c8f20
                          94ac6d29-73ce-41a6-809f-6363ba21b47e 1

(All one line. Take a deep breath.) [Update: Or you can use powercfg -setacvalueindex SCHEME_BALANCED SUB_SLEEP HYBRIDSLEEP 1, as pointed out by Random832. I missed this because the ability to substitute aliases is not mentioned in the -setacvalueindex documentation. You have to dig into the -aliases documentation to find it.]

Okay, what do all these insane options mean?

-setacvalueindex sets the behavior when running on AC power. To change the behavior when running on battery, use -setdcvalueindex instead. Okay, that was easy.

The next part is a GUID, specifically, the GUID that represents the balanced power scheme. If you want to modify the setting for a different power scheme, then substitute that scheme’s GUID.

After the scheme GUID comes the subgroup GUID. Here, we give the GUID for the Sleep subgroup.

Next we have the GUID for the Hybrid Sleep setting.

Finally, we have the desired new value for the setting. As you might expect, 1 enables it and 0 disables it.

And where did these magic GUIDs come from? Run the powercfg -aliases command to see all the GUIDs. You can also run powercfg -q to view all the settings and their current values in the current power scheme.

Bonus reading:

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.