Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Hibernation is supposed to write out RAM contents to disk, and coming back from hibernation is supposed to fill back RAM with saved contents. Why is coming back from hibernation slow, e.g. system is very unresponsive in general for quite some time?

share|improve this question
1  
You should try a computer which uses a solid-state drive (SSD), such as a MacBook Pro. It's almost instant, most of the time. –  Stewart Jun 10 '13 at 6:04
1  
capture a hibernation/resume trace with xbootmgr and analyze what is slow: msfn.org/board/index.php?showtopic=140247 –  magicandre1981 Jun 10 '13 at 18:50
    
I use hibernate on my work laptop, but to speed it up I close all my apps first (using a small utility called closeall ntwind.com/software/utilities/close-all.html ) –  MorganTiley Sep 27 '13 at 20:41

4 Answers 4

up vote 17 down vote accepted

The main cause is disk I/O. Reading and writing to a physical disk is much slower than from RAM. When your computer resumes from disk (hibernation) it also has to power up the components which may cause some slowdown. This is highly dependent on the computer. A SSD will have almost the same resume speed from disk as from RAM. Some computers let you move the mouse around before the ram has been completely filled up again, causing low response times.

Note: Assume you have 8GB of RAM and a SSD with 400MB/s throughput. It will still take 8*1024MB/400MB/s = 20.48s. This is not the same speed as resume from RAM.

Assuming a RAM throughput of 15,000MB/s, the resume time is 0.55 seconds.

share|improve this answer
4  
Reading and writing to a physical disk is much slower than from RAM. Yes, but reading is faster than writing, so why would it take so much longer to read the HDD than to write it? –  Synetech Jun 10 '13 at 2:50
1  
@Synetech is it? If you're just timing the hibernate from hitting the option to the screen blanking (as opposed to the drive activity stopping) the OS is probably blanking it early so it looks like it didn't stall. If you are measuring shutdown via IO time there're a few possibilities. With an SDD I'd check to see if the page file is fragmented because SSDs are faster on random writes than random reads. Otherwise I'd speculate that dehibernate is slower due to delays in restarting some hardware components that were shut down not due to IO performance. –  Dan Neely Jun 10 '13 at 14:02
    
@DanNeely, actually I know what you mean. I have often been annoyed that when I click Hibernate, the screen quickly turns off, but the drive itself is still thrashing for quite some time (often a minute or two more). This is really annoying because you cannot just pick up a laptop and throw it in the bag since the drive is still spinning and moving it would increase the chances of a head-crash (standby is better for quick shutdown). However, I also know what enthrops is saying; sometimes a resume takes a long time (well Windows resume fairly quickly, but the HDD LED stays lit for a long time). –  Synetech Jun 10 '13 at 15:11
    
@Synetech yet another reason to wish SSDs were cheap enough to be universal. –  Dan Neely Jun 11 '13 at 18:56

While RAM is very fast, the hard disk is the exact opposite. Imagine you have to copy your RAM contents, which might be about 16 GB, from the hard disk. That's 4 DVDs. See?

share|improve this answer

It's a tradeoff. Do we pull everything that was in RAM before hibernation back from the disk into RAM all at once, or only a little bit at a time, as needed?

We all know that reading a sector from a spinning disk takes practically the same amount of time as writing that sector to the same spinning disk -- the seek + rotate time. So we might expect that writing information from RAM to disk (on hibernate) would take about the same time as reading that same RAM from disk (resume from hibernate). But it doesn't happen that way, because of demand paging.

If the OS pulled in everything at once, then resume from hibernate would take dozens of seconds, but after that it would act the same as if you had never hibernated at all.

OS programmers typically choose demand paging instead. In other words, the OS pulls only a little bit at a time from disk, as needed. That has the advantage that resume from hibernate takes much less time before it starts responding to the keyboard and mouseclicks. On the other hand, when you use something for the first time after hibernation, there's a small but noticeable delay when the OS finally gets around to loading it up. That happens even when "the first time" you use something may be several minutes after the hibernate. So after resuming from a hibernate (i.e., after you see a screen that appears to be more-or-less identical to the screen just before the hibernate), working with the machine may seem sluggish for a while.

As Synetech pointed out, there's a bit of human psychology also involved: Because the screen turns off right away at the beginning of hibernation, it seems like it shuts down fast. And the user can immediately go on with whatever else you wanted to do. But after a resume from hibernation, the user is trying to do something, and the little delays are annoying because they get in the way of what the user is trying to do.

share|improve this answer

I know what you mean. It does indeed seem like the HDD LED flashes for a long time after resuming from hibernation.

Some reasonable explanations have been given about delays due to starting up hardware (and driver acceleration?) and fragmentation (you’ll notice that a system fresh from the factory will generally hibernate and resume fairly quickly while one that has been used for some time will be much slower to do so). There are a couple of more explanations for this behavior.

When you hibernate, Windows flushes the RAM to the drive. Despite high speeds for reading RAM and writing to disk (even with a defragmented hibernation file on a big, empty drive), it still takes quite a while to write several gigabytes (you will notice that hibernating and resuming a system with small amounts of RAM is farily fast). The screen goes off quickly, but the drive (and motherboard, fans, etc.) all remain running for a while until it finishes flushing the RAM to disk. (Make sure not to throw a laptop with an HDD around until after it has finished and completely turned the drive off).

You can do some experimental tests to measure the time it takes from clicking Hibernate until the system is powered down, and the time it takes from the moment you see the Resuming Windows screen until the HDD LED stops flashing. They will likely be approximately equal. (Windows does attempt to make it seem like it resumes from hibernation very fast by writing and then reading the kernel and stuff to the hibernation file first, so that it can get back up and running immediately and then continues to load in the rest in the background and as needed until it has all been resumed—you can see this behavior in action because the login screen is shown very quickly.)

Why then does it seem like resuming takes longer. There’s two explanations for this.

  1. It’s psychological. As Dan pointed out, because the screen turns off right away when you hibernate, it seems like it shuts down fast, while you see the entire resume process (opening screen and HDD LED flashing).

  2. It’s paging. Since most people use hibernate instead of shutdown because they want to avoid exiting programs and such so that they can pick up where they left off, it means that when Windows resumes, there are a bunch of programs already running and already consuming memory. Because a significant amount of time has passed since the last time that Windows’ memory-manager checked on the system, it will likely end up doing a bunch of memory swapping since from its perspective, some programs have been dormant for a while and others have become active. This swapping of course takes a while and thrashes the drive for some time.

The end result is likely a combination of factors and interactions between hardware activation, paging, psychology, and fragmentation.

If you are up to it, you can definitively find out (at least on your system) what is the bottleneck by performing a few simple tests such as using Process Monitor to observe drive/file activity while Windows hibernates and resumes to see whether all that thrashing is due to access to hiberfil.sys or pagefile.sys.

share|improve this answer
    
i like the psychological approach. Hibernation on plain old hard drives is bad designed in a UX way, or it should never have existed. –  smonff Jun 14 '13 at 20:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.