High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001 1 Adaptive Page Replacement to...
-
date post
19-Dec-2015 -
Category
Documents
-
view
214 -
download
0
Transcript of High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001 1 Adaptive Page Replacement to...
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
1
Adaptive Page Replacement to Protect Thrashing in Linux
Song Jiang, Xiaodong Zhang
College of William and Mary
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
2
What Thrashing in Linux We Target?
Multiprogramming environment Memory shortage spread Each process has lots of page faults Very low CPU utilization
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
3
Existing Schemes and Our Approach
We address the problem by adjusting page replacement.
Local replacement; Kill some processes (e.g. Linux); Load control (e.g. BSD);
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
4
Outline
How thrashing develops in the kernel? Analysis of page replacement variations in Linux; How our Thrashing Protection Facility (TPF) works? Performance evaluation Conclusion
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
5
How thrashing develops in the kernel?
Proc1
Proc2
CPU
CPU
CPU
Memory demand
paging
paging
paging
paging
IDLE
Physical memory
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
6
Factors Related to Thrashing
The size of memory space in the system;The number of processes;The dynamic memory demands;The page replacement scheme.
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
7
Outline
How thrashing develops in the kernel? Analysis of page replacement variations in Linux; How our Thrashing Protection Facility (TPF) works? Performance evaluation Conclusion
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
8
Framework of Linux Page ReplacementAn NRU (Not Recently Used) page searching starts from where
it was done last time.
(1) Select a swappable process to find NRU pages;
(2) Check through the virtual memory pages in the
selected process; if not find NRU pages, go to (1) for
next process.
in a process by process, and page by page fashion
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
9
Two Aspects Related to Thrashing
How many NRU pages in a selected process are allowed to replace continuously?
How easily NRU pages can be generated?
Allow a large amount of
pages to be replaced from a
specific process once a time
Prepare enough NRU
pages for eviction
Memory shortage concentrate
on one or a few specific
processes
Help others to build up
their working set, and
reduce thrashing possibility
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
10
NRU page contributions are distributed; NRU pages are generated by aging.
Encourages spreading the memory shortage burden over processes, so that no one can build up its working set.
Replacement in Kernel 2.0
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
11
Kernel 2.0
Ready to go to next proc
Try to find an NRU page in p
NRU page found?
Ready to go to next proc
--count>0?
succeed
fail
Let p be current
swappable process
p->swap_cnt==0?
p->swap_cnt = RSS/MB
p->swap_cnt --
p->swap_cnt==0?
Y
Y
N
N
Y
N
Y
N
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
12
A selected process continuously contribute
its NRU pages;
No page aging any more.
Penalize the memory usage of one process at a
time. Thus others have more chances to build up their
working sets.
Replacement in Kernel 2.2
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
13
Kernel 2.2
Try to find an NRU page in pbest
NRU page found? --count>0?succeed
fail
For each process p:
p->swap_cnt = p->RSS
Y
Find the process pbest with maximum p->swap_cnt
pbest->swap_cnt = 0
For all process Pp->swap_cnt = 0 ?
N
N
Y
YN
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
14
Replacement in Kernel 2.4
Addressing concerns on memory performance of
Kernel 2.2 by re-introducing:
proportional NRU page distribution;
page aging.
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
15
Kernel 2.4
--count>0? done
Let P be the next process
NY
Walk about 6% of the address space of p
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
16
Summary of the Replacement Behavior during Thrashing
Kernels 2.0 2.2 2.4
Keep CPUbusy No Yes No
Keep memorywell utilized Yes No Yes
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
17
Why an adaptive policy is needed for thrashing protection?
Conflicting interests in the design:
Regarding CPU utilization, keep at least one process active
Regarding memory utilization, apply the LRU principle
consistently to all the processes.
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
18
The Goal of Our Adaptive Solution
When CPU utilization is not a concern, make
memory resource be efficiently used.
When CPU utilization is low due to thrashing,
change replacement behavior adaptively.
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
19
Outline
How thrashing develops in the kernel? Analysis of page replacement variations in Linux; How our Thrashing Protection Facility (TPF) works? Performance evaluation Conclusion
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
20
Basic Idea of Thrashing Protection Facility
(TPF) Multiple “CPU cycle
eager” processes but with
high page fault rates
Low CPU utilization
Temporal tuning on page
replacement to help specific
process build up its working set
CPU utilization increased
Return to normal page replacement
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
21
Parameters of TPFCPU_Low: the lowest CPU utilization the system
can tolerate. CPU_High: the targeted CPU utilization for TPF to
achieve. PF_High: the page fault rate threshold for a process
to potentially cause thrashing. PF_Low: the targeted page fault rate of the identified
process for TPF to achieve. In addition, the list “high_PF_proc” records
processes with high page fault rates
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
22
TPF state transition
Monitoring
State
Normal
State
Protection
State
Length
(high_PF_pro
c)>
1
Length
(high_PF_pro
c)<=1
CPUutilization<CPU_Low and and
length(high_pf_proc)>=2
Page fault rate of
protected proc<PF_Low oror
CPU utilization>CPU_High
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
23
Outline
How thrashing develops in the kernel? Analysis of page replacement variations in Linux; How our Thrashing Protection Facility (TPF) works? Performance evaluation Conclusion
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
24
Characterizations of Workloads
Programs Description MemoryReq. (MB)
Exec.Time (s)
bit-r Bit-reversal 130.0 326.1
LU LU decomposition 162.0 99.2
gcc Optimized C compilerfrom SPEC2000
145.0 218.7
vortex Database applicationfrom SPEC2000
131.2 398.0
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
25
Experiment settings
Pentium II of 400 MHz Red Hat Linux release 6.1 with Kernel 2.2.14. The predetermined threshold values are set as follows:
CPU_Low = 40%, CPU_High = 80%, PF_High = 10 faults/second, PF_Low = 1 fault/second.
We instrumented the kernel to adjust the available user memory so that different memory constraints can be formed to facilitate our experiments.
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
26
X axis: execution time
Y axis: number of pages
Time-space figures of dedicated execution
MAD: the number of pages requested
RSS: the number of resident pages
bit-
r
LU
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
27
gcc vortex
Time-space figures of dedicated execution
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
28
Comparison for gcc+vortex (42% memory shortage)
Without
TPF
With
TPF
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
29
Comparison for gcc+bit-r (31% memory shortage)
Without
TPF
With
TPF
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
30
Comparison for LU1+LU2 (35% memory shortage)
Without
TPF
With
TPF
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
31
Comparison of Execution Time
0
300
600
900
1200
1500
Exe
c. T
ime
(s)
without TPF with TPF
vortexgccgcc
vortexgcc gcc
bit-t bit-tLU1
LU2
LU1LU2
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
32
Comparisons of Numbers of Page Faults
0
50000
100000
150000
200000
250000
300000
Num
ber
of F
ault
s
without TPF with TPF
vortexgccgcc
vortexgcc gcc
bit-t bit-tLU1
LU2LU1
LU2
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
33
Comparison of Total Execution Time
0
300
600
900
1200
1500
gcc + vortex gcc + bit-r LU1 + LU2
Exe
c. T
ime
(s)
without TPF with TPF ideal
High Performance Computing and Software Lab, W&M ALS '01, 11/10/2001
34
ConclusionThrashing can be easily triggered by: (1) Dynamical memory usage, (2) Common memory reference patterns, and (3) Serious memory shortage.
TPF is highly responsive to stop thrashing triggered by (1) and (2);
TPF has little intervention to multiprogramming environment;
Load control will be used only when it is truly necessary.