4

Every time I hibernate Windows 7 and then resume later on, the whole system seems fine for a while, then everything gets slow until the system takes about 10 seconds to load a webpage where it was load instantly before.

Is there something that can be done to stop this from happening?

I already tried sfc /scannow, it doesn't make any difference.

I have seen this asked a few times, but never with a solution that works for me.

warsong
  • 515
  • 2
  • 12
  • 27
  • what is ratio of hibernate.sys and RAM? – malakrsnaslava Jan 28 '13 at 21:24
  • Hmm, strange, 2.89gb to 4gb. I was expecting to see 1:1. – warsong Jan 28 '13 at 21:26
  • @warsong, it is normal to have a `hiberfile.sys` that is less than the total installed RAM because Windows’t doesn’t save the entire RAM (that would be pointless), only parts that were in use. However “in use” doesn’t necessarily correspond to what you see in Task Manager; Windows has its own definition based on its internal memory-management system. – Synetech Sep 07 '13 at 14:58
  • @Synetech As of Windows 7, the hibernation file is compressed (default 75%). It looks like it does take a full snapshot, though - or maybe it just includes the disk cache, which leaves almost no actually unused memory. – Bob Sep 07 '13 at 15:17
  • @Bob, interesting; I’ll have to take a look at that. Where did you read that? – Synetech Sep 07 '13 at 15:31
  • @Synetech Hm. That'll teach me not to take Wikipedia seriously (or maybe I just suck at reading comprehension and skimmed it too quickly). [This KB article](http://msdn.microsoft.com/en-us/windows/hardware/gg463468.aspx#EUNAC) and [this blog post](http://blogs.msdn.com/b/tims/archive/2010/10/29/pdc10-mysteries-of-windows-memory-management-revealed-part-two.aspx) seem to indicate that caching memory is actually *not* written. – Bob Sep 07 '13 at 16:36
  • Specifically: *> Before Windows XP writes to the hibernation file, all memory pages on the zero, free, and standby lists are freed; these pages do not need to be written to disk. Memory pages are also compressed before being written.* and *> The Available field (right) shows all the pages in the zero, free and standby lists.* (If I'm not wrong, caching memory counts as 'available'.) – Bob Sep 07 '13 at 16:37

2 Answers2

5

Every time I hibernate Windows 7 and then resume later on, the whole system seems fine for a while, then everything gets slow until the system takes about 10 seconds to load a webpage where it was load instantly before.

Look at the HDD LED on your system. I’ll bet that for a few minutes after resuming from hibernation, the HDD LED flashes furiously (or even goes solid).

This is normal. When Windows resumes from hibernation, it does not read the entire hibernation file (which could be a few gigabytes in size) into memory. Instead, it loads the parts that are crucial to getting up and running again (the kernel, the memory of drivers, services, active programs, etc.) and loads the rest in the background. This way, you can start working again right away instead of waiting for a minute or two.

Naturally this means that the system will be bogged down while Windows continues to load the rest of the system in the background. Of course it tries its best to be as responsive as possible, but not surprisingly, this is easier said than done. This is particularly true since since activity keeps forcing it to side-track from the background-load to prioritize something else, so for example, if you un-minimize a program, Windows has to try to stop loading whatever it was working on and quickly restore the memory for that other program, but it may have to finish the current operation before side-tracking.

I already tried sfc /scannow, it doesn't make any difference.

Because there’s nothing wrong with the drive.

Is there something that can be done to stop this from happening?

Aside from getting more memory and a faster drive (e.g., SSD), the best thing that you can do to improve post-hibernation performance is to exit as many programs and freeing up as much memory as possible before hibernating. Obviously this somewhat defeats the purpose of hibernation, but nothing is free, and if you want performance on this end, then you have to pay on that end, and vice versa.

As a bonus, if you reduce the number of running programs and used memory before hibernating, then you also get the benefit that Windows hibernates faster since it doesn’t have to save as much memory to disk.

Also, the MSDN article that Bob mentioned explains another reason why resuming is slow(er than hibernating):

Boot loader enhancements also provide similar improvements in hibernation resume times, mainly by streamlining the I/O paths used by Ntldr to read the hibernation image. The hibernation file is compressed as it is written, and for efficiency, the compression algorithm overlaps with the file I/O. However, when resuming from hibernation, Ntldr is using the BIOS to perform the I/O; therefore, it is not feasible to overlap the disk I/O reads with the decompression.

To optimize the hibernation process in Windows XP, several improvements have been implemented. The compression algorithm has been optimized to compress and decompress large blocks (64K) of data. In addition, the compression is overlapped with the disk write. As the current data block is being transferred to the disk, the next block of data is being compressed. Overlapping the compression with disk writes makes the compression time virtually free. Also, the hibernation file is written using IDE DMA instead of PIO mode. Most modern IDE controllers and disks achieve their best performance only in DMA mode.

In other words, the hibernation process occurs in Windows with all of the drivers and such loaded and ready so that Windows can access the hardware (i.e., the drives) at maximum speed. However when you resume, Windows is not loaded, so it is using the BIOS which only provides a basic level of service—if even that much—after all, the B in BIOS stands for Basic.

The situation for Windows 7 on EFI systems is a little better, but still essentially the same. It would be impossible for an EFI to have “drivers” for every possible hardware device, so even an EFI system cannot provide full access with maximum performance.


Therefore, resuming from hibernation will always be somewhat slow (at least the part that gets Windows up and running; the background loading of the remainder would be a little faster). In fact, the more memory you have installed, the longer it takes because there is more data that has to be read from the disk—hibernation is one of the only downsides to having more memory.

Synetech
  • 68,243
  • 36
  • 223
  • 356
  • @Bob, I’m not clear on what you mean. `I suppose it might also clear the in-memory disk cache on hibernation` It [does seem to](http://superuser.com/questions/453453/does-windows-flush-drive-caches-on-standby) flush the disk caches, but that wouldn’t really take much time (it’s only a few MB). `(to avoid writing all that extra data)` You mean to the hibernation file? Why would it write the disk caches to that? It’s only for the memory. – Synetech Sep 07 '13 at 15:16
  • I meant RAM set aside for disk caching ("cached memory"? I never did like that term.) - which can easily rise into the gigabytes and does play a large part in speeding up frequent disk access. – Bob Sep 07 '13 at 16:43
1

After hibernate process is complete, just put the computer to sleep again. Wake it up and surprisingly windows will start working with full speed again.

Sanss
  • 21
  • 1
  • there is something to support this workarround? – Francisco Tapia Jul 14 '15 at 14:04
  • Your solution works for me! I think I found the source cause, due to a bug in windows, but I don't think it will be ethical, not even rational to give for free: Microsoft closed-licence policies have cause me lot of trouble and money loss, so I will never give them back anything for free or support their OSes providing fixes. Hope anyone else acts like me. – earizon Mar 04 '16 at 16:34