Share via


Tales of PC Insomnia

Power Plan Settings

[note: An update on a couple of the issues mentioned here can be found in my follow-up post here.] 

Sleep is a wonderful thing.  Particularly if it saves you energy.  Of course I’m talking about PC sleep (although I suppose it applies to your own sleep as well).  If you’re using Windows XP, chances are your PC isn’t sleeping automatically unless you manually configured it to do so.  However if you’re using Windows Vista or Windows 7, you might have noticed that your PC will sleep automatically after 30 minutes or so.  If you are running Windows on a work PC, you may have discovered that your IT manager turned off automatic sleep, making you responsible for turning your computer off. 

Turning on automatic sleep takes care of this “chore” for you, and it’s easy to configure in the power control panel.  Fortunately, many IT managers are revisiting their decision to disable automatic sleep given the potentially large savings that can be had.  However, if group policy settings prevent you from configuring your PC to sleep automatically, then you can at least use manual sleep instead of shutting down Windows to save power.  On modern PCs, sleep uses only a tiny bit more power than shutting down, but resumes much faster than booting from cold.

Windows 7 PC Insomnia Diagnostic tool

However, there are times when mysteriously your PC won’t go to sleep automatically, even though you can put it to sleep manually.  This is phenomena is commonly known as “PC insomnia”.  Up until Windows 7, it was pretty much impossible for the average user or even IT administrator to determine why a PC wouldn’t go to sleep automatically.  Fortunately Windows 7 includes a new built-in tool to help you diagnose PC insomnia.

In Windows 7, powercfg.exe has been enhanced with a couple of options to help diagnose power management problems, including sleep issues.  One of these options is the ‘/requests’ switch which will tell you what components are requesting that the system not go to sleep automatically.  The following is output from the powercfg tool using the /requests switch.

C:\Windows\system32>powercfg /requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume2\Program Files\Microsoft Office\Office12\POWERPNT.EXE

SYSTEM:
[PROCESS] \Device\HarddiskVolume2\Program Files\Microsoft Office\Office12\POWERPNT.EXE

AWAYMODE:
None.

(you’ll need to do this from an elevated command prompt – type command at the start menu search box, in the search results, right click on “Command Prompt” and chose ‘Run as Administrator’)

In this particular example, Microsoft Office PowerPoint is running in slide show mode and is asking Windows to not automatically turn off the display or put the system to sleep.  This is perfectly reasonable, because having your computer go off in the middle of a presentation is not particularly helpful!  Similarly, if you install an update from Windows Update, the updater process will keep the machine awake until the installation is complete to ensure it doesn’t go into sleep in the middle of an update.

Unintended Consequences of not using Power Availability Requests and Presentation Mode.

Conversely, if you’ve ever wondered why your computer display sometimes blanks during the middle of a presentation or while you’re watching a video in a web browser, it’s because the application is not explicitly making a power availability (PA) request to keep the display awake during the activity.  Unfortunately, there’s no reliable way for the computer to know that you’re passively watching (or listening) to the computer, so it is usually up the the application to make the appropriate PA request to prevent the display from dimming or the computer from sleeping.  Even then, keeping the display/computer on might not make sense for the majority of scenarios - for instance, you really don’t want Excel to to keep the display or system awake on the off chance that you are presenting your latest sales numbers. 

One option for long running videos and presentations is to put the PC in presentation mode.  To do this, open the Windows Mobility center by holding down the Windows logo key and pressing X (Windows+X) and choose Presentation mode.  This runs a small app that will raise a PA request to prevent the display blanking or the system sleeping.  Presentation mode is smart enough to turn itself off if the system is manually put to sleep, so the next time the system wakes, it will go to sleep automatically as usual.  Just remember to turn off presentation mode when you’re done.

Causes of PC Insomnia

So what about the occasions when there is no obvious reason why your machine stays awake?  Sometimes the reason is justified – you just don’t know what it is – other times the app is just badly designed (although typically not deliberately).

A few examples illustrate these two cases.

Opening Files Across a Network

The first is an example of a good reason your PC should stay awake.  When a file is opened in read/write mode on a remote file system (e.g. you open a PowerPoint presentation that resides on remote file server share),  the local SMB (or CIFS as it’s sometimes known) redirector will raise a PA request to keep your machine awake so that the chances of data loss are minimized – having the machine go to sleep while the file is open could possibly corrupt the file.  Similarly the SMB server on the remote machine (assuming it is a Windows machine) will also raise a power availability request until the file is closed.

While this makes perfect sense, in many situations the end user probably isn’t going to be aware that this particular act (i.e. editing a file that resides on a remote machine) is what is responsible for keeping their PC awake. 

This can be a leading cause of insomnia for PCs, including those running Windows Vista.  Vendors such as 1E and Verdiem have recognized this and provide sleep overrides which will automatically save files and put the computer to sleep, and notify the user of the action taken when the machine is turned back on.

While it may be annoying to some folks that a machine with open files across the network doesn’t sleep automatically, this is in fact a prudent and rationale design decision.  You really don’t want your PC potentially  “auto-corrupting” files by going to sleep automatically, or people will turn off automatic sleep entirely.

However, this behavior is application dependent.  For instance, Microsoft Word 2007 copies the file to the local disk and manages any edits there, only writing the contents back to the original location during a save operation. 

In Windows 7, this problem has been addressed somewhat by changes to the way offline files/folders work.  Offline files allow users to work with server-based documents even when they are not connected to the server by making a cache of the documents (typically the whole folder) available locally. (Time for a PSA here:  If you are an IT administrator in charge of ensuring that PC data gets backed up, Offline files has been enhanced in Windows 7 and is a great solution.)  By ensuring that files are always edited using the cached version, Windows 7 can prevent the insomnia caused by users that leave edited server-based documents open. 

[Unfortunately there appears to be a issue in the way Offline files treats the temporary files created by PowerPoint and Excel, so opening a PPT or XLS file from a folder marked offline still causes a PA request to get raised.   I’m working with the Offline files and Office team and we’ll hopefully see this fixed soon.]

Windows 7 Search Indexer and the Remote File System Redesign

There are other examples where application design can inadvertently keep PCs awake by causing PA requests to get raised for no good reason.  One particular example we discovered during the development of Windows 7 involved the Windows search indexer.  When adding a remote folder to a local “library” (a very cool feature in W7 that makes it much easier to group and search across your various files regardless of where they are stored), the search indexer opens a named pipe to the remote indexer (assuming the indexer service is running on the remote machine) to keep track of the files on the remote machine.  As a result of this action, a PA request was raised – forever.  This meant your machine would never go to sleep automatically.  It turns out the the Windows 7 file system redirector was raising the PA request in response to the remote named pipe being open.

After discussing this issue at length with the indexer and remote file systems teams, it was determined that it was bad design to have the redirector arbitrarily raise PA requests whenever a remote named pipe was open, simply because there was no way to know whether the application really needed the machine to stay awake.  Instead the application that opens the named pipe should raise the PA request if need be.  In the case of the indexer, it was determined that it’s not necessary to keep the PC awake, so no action was taken on their part (i.e. fixing the named pipe code meant that the indexer was fixed for free).  The good news is that was addressed in early on for W7 RC1, so you can add as many network shares as you like to your W7 libraries and be confident that this won't keep your PC awake.

Adobe Flash Video

Probably one of the most common causes of insomnia on consumer PCs is Flash Video, in use on many web sites (e.g. Youtube, Hulu, MSN Video).   Flash has the unfortunate characteristic of streaming silence to the audio stack when the video finishes or even if the audio/video stream is paused.  Streaming audio (even ‘silence) through the Windows audio stack causes a PA request to be raised because its assuming you don’t want the PC to go to sleep automatically while it is playing music.   There’s not much you can do about this right now so the best advice right now is to make sure you close any web pages that have Flash video on them after you have finished viewing.   This problem also manifests itself with some web display ads as well and you don’t need to be explicitly interacting with the ad in order to be affected by this.  Unfortunately there is no word from Adobe on when they will address this problem, but I am hopeful that we might see an update from them before the end of the year.

Conclusion

As you can see there are sometimes legitimate and non-legitimate reasons why your PC experiences “insomnia”.  Any application (including built-in Windows components) can purposely or inadvertently (if not designed correctly) prevent your PC from sleeping automatically.  With Windows 7, Microsoft has added new capabilities to help diagnose these issues, and continues to work to ensure that its own applications are being good “power citizens”. 

Third parties also have a significant responsibility here as well.  Fortunately, there is plenty of guidance available for developers on microsoft.com to help make systems, applications and devices more power aware, including specific advice on when and how to raise power availability requests.

Part 2 of this topic is here.

Comments

  • Anonymous
    October 28, 2009
    The comment has been removed

  • Anonymous
    March 26, 2010
    THanks for this excellent post.  Unfortunately, we're running a legacy version of MS Solomon that prevents our 7 machines from sleeping ('A file has been opened across the network'), even when the file is obviously closed and associated processes have terminated :(  Guess it's time to request an upgrade to Dynamics.

  • Anonymous
    April 09, 2010
    Andy...if this is something that is causing you an issue it would be worth looking at the 1E offering.  Not only can we provide the ability to circumvent the issue but we provide a number of other features essential to a power saving strategy.