You are on page 1of 5

The 1st IEEE Global Conference on Consumer Electronics 2012

Method to accelerate the resume transtion for


hibernation by selective swapout in computer system
Takumi Imai

Hiroshi Itoh

Hiroyuki Sumi

TVT & Notebook SW Dev, Lenovo Japan


mc700444@lenovo.com

Research & Technology, Lenovo Japan


hiroit@lenovo.com

TVT & Notebook SW Dev, Lenovo Japan


EB37264@lenovo.com

like to propose a method to accelerate the resume transition for


the hibernation, describe how the method is implemented by
software, and show how much the hibernation resume can be
improved by test results on Microsoft Windows computers.

AbstractThe Sleep and the hibernation are provided as power


saving mode on computers. This paper discusses the advantage of
the hibernation, proposes a method to accelerate the resume
transition by more than a few times, and shows the test results on
Windows system. This method is implemented in ThinkPad
that is a brand of laptop computers developed by Lenovo.

TABLE I.

SLEEP AND HIBERNATION COMPARISON

Keywords-sleep; hibernation; hiberfile; pagefile; swapout

I.

INTRODUCTION

The sleep and the hibernation state are provided as power


saving mode on computers as defined in ACPI specification
[1][2]. In the sleep state, the system context is stored in a
system memory and most of the devices are turned off except
minimal components such as a memory or a chipset. In the
hibernation state, the system context is stored as the hiberfile in
a non-volatile storage like a hard disk, and almost all devices
are turned off.
The TABLE I shows the comparison between the sleep and
the hibernation. Power consumption is measured on a
ThinkPad computer. The sleep power is much bigger than the
hibernation. When a computer is kept in the sleep all through
the night (e.g. from 5 p.m. to 9 a.m.), 4.8Wh is consumed and
the remaining battery percentage reduces to 85% on a
computer with 32Wh capacity battery. When a computer is
kept in the hibernation all through the night, battery is not
almost reduced. Power consumption of the hibernation is less
than 5mW on the computer that is well optimized for low
power. ENERGY STAR program has power consumption
criteria for the sleep/hibernation state because the standby
power of electronic devices is important for green energy [3].

Sleep

Hibernation

Power consumption

~300mW

~5mW

Resume performance

< 2 seconds

~ a few minutes

Security level

Low

High

Figure 1. Usage of sleep, hibernation, and shutdown

II.

METHODOLOGY

A. Examination of resume transition for hibernation


In the beginning, we will examine how a computer resume
s from the hibernation state, why it takes so long time, and
identify the key factor to improve resume performance. The
resume transition for the hibernation involves the sub phases of
BIOS initialization, hiberfile read, device resume, and service /
application resume [7][8] as shown in the Figure 2.

The hibernation resume performance, however, is much


slower. The resume performance varies depending on the
memory usage. Bigger the In Use memory is, more time it
takes to resume. When In Use memory is, for example, more
than 8GB, it may take more than one minute to resume. From
security perspective, the hibernation is more secure than the
sleep. In the sleep state, a computer may be vulnerable to hard
disk password snooping. Also, Microsoft does not recommend
the sleep when BitLocker drive encryption is used [4][5].

POST

Hiberfile
Read

Resume
Devices

Contents of hiberfile are


read into memory

Although the hibernation has big advantages over the sleep


from power and security point of view, a study [6] shows the
usage of the hibernation is only 11% in comparison with the
sleep and shutdown as shown in the Figure 1. It is reasonable
to suppose that one of the reason for less usage of the
hibernation is too slow resume performance. In this paper, Id

ResumeApps
ResumeServices
PostResume

Time

Services / Apps
are resumed

Processor begins
Devices are resumed by
executing powerkernel power manager
on transition
Figure 2. Mechanism of the resume transition for the hibernation

509

Breakdown on resume transition




POST. The first subphase is BIOS Power-On Self Test.

HiberfileRead. Hiberfile is read into memory. This


subphase applies only to hibernation transitions.

ResumeDevices. Windows notifies device drivers that the


system is resuming.

ResumeApps. Windows notifies applications to process


the resume event if needed.

ResumeServices.
handler is called.

PostResume.
This is a conceptual subphase that
encompasses the time that follows the resume transition
until the system returns to a fairly idle state.

45
40
35
30
]
[s 25
e
m
it 20
15
10
5
0

Each services power management

ResumeDevices
HiberfileRead
POST

1500 2000 2500 3000 3500


System memory usage [MB]

Lenvo ThinkPad T430s (CPU: Intel Core i5 2.60GHz, Memory: DDR3


4GB, SSD, OS: Windows 7 SP1 64bit

Figure 3 shows how much time each subphase takes


depending on the memory usage on a computer which storage
device is a HDD. Figure 4 also shows the time on a SSD
computer. BIOS POST time is measured by a stop watch since
we would like to measure the actual user experience. Other
subphases are measured by Windows Performance Tools Kit
released by Microsoft [9].

Figure 4. Breakdown of resume transition for hibernation on SSD system

B. Prooposal to accelerate resume transition


Let us examine the usage of the physical memory and how
hiberfile is created. Figure 5 shows the global memory usage
on Windows [10][11].

These results clearly show that the time of HiberfileRead is


the longest. Also, it is obvious that HiberfileRead will take
longer time when system memory size is bigger. The system
memory is supported up to 16GB on T430. HiberfileRead will
take much longer time on the computer with a 16GB memory.
The reason why HiberfileRead takes so long time is that the
resume transition causes many disk I/O operations which are
relatively slow performance. The resume performance is better
on the SSD computer since the disk I/O performance is much
better than the HDD. It is quite likely that resume transition for
the hibernation is accelerated by reducing the disk footprint of
hiberfile. ResumeDevices and ResumeApps subphases are
affected by all device drivers and applications resume
performance. They are well optimized and there is less room
for improvement. BIOS POST time is also well tuned and it is
hard to reduce the time. We will focus on and discuss
HiberfileRead subphase in the following chapter.

Figure 5. Global Memory usage

Breakdown of resume transition


45
40
35
30
]
s
[ 25
e
m
20
ti
15
10
5
0

ResumeApps/Services

Free Page List. The Free page list tracks memory pages
that have not been allocated for a purpose or were
previously allocated and returned to the memory manager
for reuse.

Standby List. The Standby list contains unmodified


pages that have been removed from process working sets,
which effectively makes the Standby list a cache. If a
process needs a page that is on the Standby list, the
memory manager immediately returns the page to its
working set.

Modified List. The Modified page list contains pages that


have been modified but have not been accessed for some
time and have been removed from a process working set.

In Use Memory. In Use memory is calculated by adding


the sizes of the Modified, Standby, and Free list and
subtracting this from the amount of recognized memory.

Hardware Reserved. A part of memory is reserved by


System BIOS, mother board resources such as APIC, any
devices that requires memory-mapped I/O, PCI Express
configuration space and so on.

ResumeApps/Services
ResumeDevices
HiberfileRead
POST

1500 2000 2500 3000 3500


System memory usage [MB]

Lenvo ThinkPad T430 (CPU: Intel Core i5 2.80GHz, Memory: DDR3


4GB, HDD: 5400rpm, OS: Windows 7 SP1 64bit)

Figure 3. Breakdown of resume transition for hibernation on HDD system

510

We experimentally find that only Modified List and In Use


memory are written to hiberfile. Standby List and Free Page
are not written to hiberfile. It is clear that the resume transition
is accelerated if the area written to hiberfile is reduced by
compression. Operation system, however, compresses the
memory content at the hibernation entry and there is no room
for more compression [12].

III.

SOFTWARE IMPLEMENTATION

We developed a Windows application and a device driver


to realize the proposed method. In this chapter, Id like to show
how the software is implemented and detail of the proposed
method. Important point to implement the proposed feature is
how to force swap out memory content. Another point is how
to hook the hibernation entry and get a control from Windows.

Pagefile is a space on a secondary storage like a hard disk


used as virtual memory extension of a computers real memory.
Normally, least recently used area in a main memory is
swapped out to pagefile. To improve resume performance,
wed like to propose the method to force to swap out
unnecessary processes at the hibernation entry to reduce the
footprint of hiberfile as shown in Figure 6. In case of the
normal hibernation, the memory content is written to only the
hiberfile. Our method splits and writes memory content both to
the hiberfile and the pagefile. Since only the hiberfile is
restored to a system memory while resuming, number of disk
I/O count reduces and resume performance will be improved.
The pagefile will be restored to the system memory on
demand from Operating System (OS) later as shown in Figure
7 (S4 means hibernation). Since the total amount of disk I/O
during the hibernation entry is same no matter if the memory
content is written to the hiberfile or the pagefile, the
hibernation entry performance will not change.

A. Force swap out


Figure 8 shows how memory content is swapped out.
Process Working Set is the working set of a process that is in
use at a given time. Process Working Set can be trimmed by
Window standard API (Application Program Interface) and
pages in Process Working Set can be moved to Modified Page
List. All running processes are enumerated and each Process
Working Set should be trimmed. Pages in Modified List can be
swapped out to the pagefile by a Windows undocumented API.

Figure 8. Force swap out

Processes swapped out to the hiberfile will take longer time


to be responsive after the resume because the process has to be
restored from a hard disk to the memory. For example, when a
window process is swapped out, the window can not be moved
immediately after the resume, and the window will be
responsive after a few seconds. It is not a good idea to swap out
every processes, since swapping out every processes leads to
poor responsiveness after the resume. Processes should be
selectively swapped out. Following processes are not swapped
out and are kept in the memory to avoid the negative impact on
responsiveness after resume.

Figure 6. Method of accelerated resume from hibernation

System processes and services

Processes to show Desktop

Foreground window process

System processes are owned by Windows and are key


components for Windows. Services are also sometimes key
components that are running with higher privilege [13][14]. It
is safe not to touch system processes and services. Processes to
show Desktop are components used to draw Desktop image
(e.g. Desktop Window Manager). When these processes are
swapped out, it takes longer time to draw Desktop image after
the resume and it seems that the resume takes longer time. A
foreground window process is a process that creates and shows
a topmost window on Desktop. It is likely that user is
interacting with the topmost window and it is better not to
swap out the process. Figure 9 shows the flow chart of the
selective swap out.

Figure 7. Disk I/O during entry and resume transition

511

1.

The driver module registers hook for the power dispatch


routine during the startup to get a control point at the
hibernation entry

2.

When driver module retrieves a hibernation query, it


notifies the service module of the hibernation entry by
named event, and waits for the service module reply. The
Windows hibernation process is blocked to force swapout
by this operation

3.

When the service module retrieves the notification from


the driver module, it starts force swap out operation

4.

When the service module completes the swapout


operation, it resets the named event and notify the driver
module of the completion.

5.

When the driver module retrieves the completion


notification or when time out happens, it returns the
control to Windows, and Windows continues the
hibernation entry process.
IV.

TEST RESULTS

Figure 11 shows the measurement results of the hibernation


resume time with various sizes of In Use memory on a HDD
computer. Resume performance is affected not only by the size
of In User Memory, but also by the content of In Use memory.
This figure shows the resume time both when the physical
memory is filled at random and when the system memory is
filled by the static value of 0xff. Fast hibernate means the
hibernation and resume transition accelerated by the method
proposed in this paper. Normal hibernate means the normal
Windows hibernation as it is.

Figure 9. Flow chart of force swapout operation

B. Hibernation entry hook


Since the memory content should be swapped out at the
hibernation entry, it is needed to hook the hibernation entry and
get a control from OS. Although the sleep and the hibernation
entry can be hooked in User mode on Windows system, the
sleep and the hibernation can not be distinguished. If processes
are swapped out at the sleep entry, the sleep entry time will
increases although the sleep resume time is not improved. It is
needed to distinguish between the sleep and the hibernation to
force swap out only at the hibernation entry. A kernel mode
driver is able to read Power IRP (I/O request packet) to
distinguish between the sleep and the hibernation. The force
swap out operation needs to be implemented in a service
module (user mode) to selectively swap out running processes
as mentioned before. Figure 10 shows how the hibernation
entry is hooked and processes are swapped out by the service
and the kernel mode driver module.

When the system memory is filled by static value,


Windows compresses the memory content effectively at the
hibernation entry, and the resume transition for the normal
hibernation is faster. When In Use memory is 7000MB, the
resume time of random fill case is 106 seconds while 0xff fill
case is 53 seconds. The resume time of the normal hibernation
increases in proportion to In Use memory size. In case of the
fast hibernation, the resume time is almost same no matter how
much the system memory is used. When no application is
running and the memory is not allocated for applications, there
is no advantage for Fast hibernate over Normal hibernate.
When In Use memory is 7000MB and memory is randomly
filled, resume time is 106 seconds for Normal hibernation
while it is 29 seconds for Fast hibernation. That is, the resume
transition is accelerated 3.6 times faster.
Now, we will need to examine the entry transition for the
hibernation because swap out during the entry transition may
have a negative impact on the hibernation entry performance.
Figure 12 shows the time required to enter the hibernation. In
case of the random fill, the hibernation entry performance is
same because the amount of the disk I/O operation is same no
matter if memory content is split to the pagefile or not. In case
memory is filled by only 0xff, the normal hibernation entry is
much faster because of the hiberfile compression by Windows.
It is reasonable, however, to suppose that the system memory is
filled at random in normal use. The total amount of time for the
hibernation entry and resume is 134 [s] (=105 + 29) for Fast

Figure 10. Hibernation etnry hook

512

hibernate, while it is 208 [s] (=102+106) for Normal hibernate.


This result shows that the amount of the transition time is
reduced by 36% by the proposed method as well.

Windows computers. The hibernation resume time is


accelerated by up to 3.6 times on the computer with the 8GB
system memory. The advantage of proposed method will be
bigger on those computers with larger memory size. Also we
showed that the entry transition for the hibernation is not
affected by the force swap out when memory is filled at
random.

Effect of fast hibernation resume


120

Proposed technique is provided to ThinkPad users as part of


the Power Manager application (version 6.0 or later) which
is available on the Lenovo web site [15]. Power Manager
works only on ThinkPad computers.

100

Fast hibernate (0xff fill)

]s
[ 80
e
m
ti
e 60
m
us
eR 40

Fast hibernate (random)

ACKNOWLEDGEMENT

Normal hibernate (0xff fill)

I would like to thank John Mese, Nicholas Roberts, Rod


Waterman, Yasumichi Tsukamoto, Naoyuki Araki, Mikio
Hagiwara, Yoshikage Ochi, Keiko Kokubun and Hiromoto
Takahashi for their detailed comments, suggestions, and
constant support. I am also grateful to Junichi Asoh, Joe
Pennisi, Jim Hunt and Dave Higgins for their constant support.
Without them, this paper would not be possible.

Normal hibernate (random)

20
0
0

2000
4000
6000
Physical memory used [MB]

8000

Lenovo ThinkPad T420 (CPU: Intel Core i5, Memory: DDR3 8GB,
HDD: 5400rpm, OS: Windows 7 64bit)

REFERENCES
Figure 11. Resume performance comparison

[1]

Hibernation entry time

[2]

120
100

[3]

Fast hibernate (0xff fill)

]s80
[
e
im
t 60
yr
tn
E40

[4]

Normal hibernate (0xff fill)

[5]

Normal hibernate (random)

20
0

Fast hibernate (random)

2000
4000
6000
Physical memory used [MB]

[6]

8000

Lenovo ThinkPad T420 (CPU: Intel Core i5, Memory: DDR3 8GB,
HDD: 5400rpm, OS: Windows 7 64bit)

[7]
[8]
[9]

Figure 12. Impact on hibernation entry


[10]

V.

CONCLUSION

[11]

In this paper, the comparison of the sleep and the


hibernation of computer is discussed, and the importance to
accelerate the resume transition for the hibernation is
mentioned. It is clarified that the Disk I/O to read hiberfile
takes the longest time among the subphases of the resume
transition and causes the poor resume performance for the
hibernation on both HDD and SSD computers.

[12]
[13]
[14]
[15]

The method is proposed to swap out unnecessary processes


and reduce the footprint of hiberfile to accelerate the resume
transition. The proposed method is proven to be effective on

513

Hewlett-Packard Corporation, Intel Corporation, Microsoft Corporation,


Phoenix Corporation, Toshiba Corporation, Advacned Configuration
and Power Interface Specification Revision 5.0 Dec 2011
D. Korn, R. Huang, D. Beavers, T. Bolioli, M. Walker, "Power
management of computers," isee, pp.128-131, International Symposium
on Electronics and the Environment (ISEE'04), 2004
ENERGY STAR program in United States Environmental Potection
Agency, Energy Star Program Requirements for Computers,
http://www.energystar.gov/index.cfm?c=revisions.computer_spec
MACIVER, D. Penetration testing Windows Vista BitLocker drive
encryption. Presentation, Hack In The Box, Sept. 2006.
J. Alex Halderman, Seth D. Schoen, Nadia Heninger, William Clarkson,
William Paul, Joseph A. Calandrino, Ariel J. Feldman, Jacob
Appelbaum, Edward W. Felten: Lest We Remember, Cold Boot
Attacks on Encryption Keys USENIX Security Symposium 2008: 4560
Microsoft blog, Delivering fast boot times in Windows 8,
http://blogs.msdn.com/b/b8/archive/2011/09/08/delivering-fast-boottimes-in-windows-8.aspx
On Microsoft whitepaper, The Science of Sleep, 2010
On Microsoft whitepaper, Windows On/Off Transition performance
Analysis, 2011
On Microsoft whitepaper, Performance Testing Guide for Windows,
2009
On Microsoft whitepaper, Advances in Memory Management for
Windows, 2007
On Microsoft whitepaper, Memory Sizing Guidance for Windows 7,
2010
On Microsoft whitepaper, Reducing the Disk Footprint for Windows 7
Hibernation, 2009
On Microsoft whitepaper, Impact of Session 0 Isolation on Services
and Drivers in Windows, 2009
On Microsoft whitepaper, Services in Windows, 2010
Power
Manager
for
Windows
7
notebook,
http://support.lenovo.com/en_US/detail.page?LegacyDocID=MIGR7060

You might also like