Clock-Pro: An Effective
Replacement in OS Kernel

     Xiaodong Zhang

  College of William and Mary
How to Make LIRS Work in OS Kernels?
q   Most system kernels use the CLOCK algorithm, an
    approximation of LRU.
q   We have made efforts to directly implement LIRS in
    Linux kernels, but …
q   Our experience tells us that we must build on
    existing strength.
q   CLOCK is the base for LIRS.
Basic CLOCK Replacement
        All the resident pages are placed around a circular list, like a clock;
        Each page is associated with a reference bit, indicating if the page has been
       accessed.
                                                 1     0     0
                                                                      0
                                             1                            0
                                         0                                    1
                                                                              0
                                     1           CLOCK hand                        0
                                 0                                                     1
     On a HIT                   0                                                      0
  Set Reference bit to 1
(no algorithm operations)            1                                             0
                                         1                                    0
                                             0                            0
                                                 0           1    1
                                                      0
Basic CLOCK Replacement
 Starts from the currently pointed page, and evicts the page if it is”`0”;
 Move the clock hand until reach a “0” page;
 Give “1” page a second chance, and reset its “1” to “0”

                                                    1     0     0
                                                                         0
                                                1                            0
                                            0                                    0
                                                                                 1
On a sequence of                        1           CLOCK hand                       0
  two MISSes
                                    0                                                    0
                                    0                                                    1

                                        1                                            0
                                            1                                    0
                                                0                            0
                                                    0           1    1
                                                         0
The CLOCK with a Long History




  “In the Multics system a paging algorithm has been developed that
has the implementation ease and low overhead of the FIFO strategy
and is an approximation to the LRU strategy”

                “A paging Expreiment with the Multics System” MIT Project MAC
Report MAC-M-384, May 1968, Fernando J. Corbato (1990 Turing Award Laureate)
The CLOCK has been Widely Used

Major OS                  Major OS Textbooks

Multics                    Tanebaum & Woodhull

UNIX/AIX/Linux/BSD         Silberschatz & Galvin

VAX/VMS                    Stallings (for undergraduate)

DB2

Windows/Oracle/Solaris
Prior Work on LRU versus CLOCK
LRU related work               CLOCK related work
   FBR (1990, SIGMETRICS)
                                 GCLOCK (1978, ACM TDBS)
   LRU-2 (1993, SIGMOD)

   2Q (1994, VLDB)

   SEQ (1997, SIGMETRICS)

   LRFU (1999, OSDI)

   EELRU (1999, SIGMETRICS)

   MQ (2001, USENIX)
                                 1968              2003
   LIRS (2002, SIGMETRICS)    CAR (2004, FAST)

   ARC (2003, FAST)           CLOCK-Pro (2005, USENIX)
GCLOCK Replacement

 Introduce additional page access information.
 A counter is associated with each page rather than a
 single bit;
 The counter is incremented on a page hit;
 The clock hand periodically moves, and decrements
 the counter of each block;
 The page with its counter of 0 is replaced.
Age-Based CLOCK in Linux and FreeBSD

 An age is associated with each page in addition to a
  reference bit;

 When the clock hand sweeps through pages, it
  increases its age if the page’s bit is 1, otherwise it
  decreases its age.

 The page with its age of 0 is replaced.
CAR: CLOCK with Adaptive Replacement
 Two  clocks T1 and T2, one is for cold pages touched only once recently (Recency),
another is for hot pages touched at least twice (“Frequency”);
 Queues B1 and B2 are for pages recently replaced from T1 and T2;
 The memory allocations for T1 or T2 depend on the ratio of references
   to B2 and B1.
Limits of CAR

 A page that is regularly accessed with its reuse distance a little bit
larger memory size has no hits in T1 or T2. (inherited LRU problem).
 A page in T2 can stay in memory without any accesses because
frequency does not reflect ``reuse distance”.
 No system implementations yet
Basic Ideas of CLOCK-Pro

 It is an approximation of LIRS based on the CLOCK infrastructure.
 Pages categorized into two groups: cold pages and hot pages
  based on their reuse distances (or IRR).
 There are three hands: Hand-hot for hot pages,
  Hand-cold for cold pages, and Hand-test for running a reuse
  distance test for a block;
 The allocation of memory pages between hot pages (Mhot) and
  cold pages (Mcold ) are adaptively adjusted. (M = Mhot + Mcold)
 All hot pages are resident (=Lir blocks), some cold pages are also
  resident (= Hir Blocks); keep track of recently replaced pages
  (=non-resident Hir blocks)
0   1 Cold resident        CLOCK-Pro Structure
0   1   Hot
                                                             1   24
    Cold non-resident                             2                    23
                                 Hand-hot: find a hot     0
                                         3       0               0
                                 page to be demoted                   0         22
                                 into a cold 0
                                             page.                          1
                                    4
                                         0
                                                                                 0 21
                                5    0                hand-hot
                                                                                     0 20
Two reasons for a resident cold page:                  All hands move
                              6                                                       1 19
• A fresh replacement: a first access.       hand-cold in the clockwise
• It is demoted from a hotused to find
              Hand-cold is page.                       direction. hand-test
                              7
              a page for replacement.                                                 0 18

                                8                                                    0 17
                        Hand-test: (1) to determine if a
                                         0
                        cold page is promoted to be hot; (2)
                                      9                                              16
                        remove non-resident cold pages out                 0
                        of the clock.    10                                 15
                                                          1      0
                                                11                    14
                                                        12       13
Accessing Sequence:                                                       1           24                                        1                5
….27, 7, 26, 25, 4, 23                                           2                               23                                 0        0
                                                                          0           0
                                                    3                0                       0             22
                                                        0                                             1                             0        04
                                            4                                                                                   3
                                                0                                                                   21
                                                                                                               0                     Resident
                                    5                                                                                               Cold Pages
                                            0                        hand-hot                                              20
                                                                                                                    0
                               6
                                                    hand-cold                 Clock
                                                                                                                       1    19


                               7                                                           hand-test                 0      18


                                   8                                                                               0       17
              2       24

      9       0       0        23               0
          0                0                9
                                                                                                                   16
                                                                                                      0                         7        6
                                       22
13   0                         1                10
                                                                                  0                       15
                                                            11                               14                        8                         16
15
     0                         0       21
                                                                         12           13

          0                0                                                                                        10                               14
     17           0   1        20

              18     19                                                                                                   11      12
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1           24                                      1                5
Page 23                                                          2                             23                                 0        0
                                                                          0           0
Hit!                                                3                0                       0
                                                                                             1           22
Set reference bit of                                    0                                           1                             0        04
Page 23 to 1.                               4                                                                                 3
                                                                                                                  21
No other operation                              0
                                                                                                             0                     Resident
                                    5                                                                                             Cold Pages
                                            0                        hand-hot                                            20
                                                                                                                  0
                               6
                                                    hand-cold                 Clock
                                                                                                                     1    19


                               7                                                           hand-test               0      18


                                   8                                                                             0       17
              2       24

      9       0       0        23               0
          0                0
                           1                9                                                                    16
                                                                                                    0                         7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                        15
                                                            11                               14                      8                         16
15
     0                         0       21
                                                                         12           13

          0                0                                                                                      10                               14
     17           0   1        20

              18     19                                                                                                 11      12
              Hot Pages                                                                                          Non-resident Cold Pages
Current accessing:                                                        1           24                                        1                5
Page 4                                                           2                               23                                 0        0
                                                                          0           0
Hit!                                                3                0                       1             22
Set reference bit of                                    0                                             1                             0        04
                                                                                                                                             1
Page 4 to 1.                                4                                                                                   3
                                                                                                                    21
No other operation                              0
                                                1                                                              0                     Resident
                                    5                                                                                               Cold Pages
                                            0                        hand-hot                                              20
                                                                                                                    0
                               6
                                                    hand-cold                 Clock
                                                                                                                       1    19


                               7                                                           hand-test                 0      18


                                   8                                                                               0       17
              2       24

      9       0       0        23               0
          0                1                9                                                                      16
                                                                                                      0                         7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                          15
                                                            11                               14                        8                         16
15
     0                         0       21
                                                                         12           13

          0                0                                                                                        10                               14
     17           0   1        20

              18     19                                                                                                   11      12
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1           24                                        1                5
Page 25                                                          2                               23                                 0        0
                                                                          0           0
Miss!                                               3                0                       1             22
                                                        0                                             1                             0        14
(1) run hand-cold---                        4                                                                                   3
                                                                                                                    21
reclaim the first met                           1
cold page with ref bit 0                                                                                       0                     Resident
                                    5                                                                                               Cold Pages
(Page 5)                                    0                        hand-hot                                              20
                                                                                                                    0
(2) Reclaim cold page
5 and remove it from           6
resident cold page list                             hand-cold                 Clock
                                                                                                                       1    19


                               7                                                           hand-test                 0      18


                                   8                                                                               0       17
              2       24

      9       0       0        23               0
          0                1                9                                                                      16
                                                                                                      0                         7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                          15
                                                            11                               14                        8                         16
15
     0                         0       21
                                                                         12           13

          0                0                                                                                        10                               14
     17           0   1        20

              18     19                                                                                                   11      12
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1           24                                        1
Page 25                                                          2                               23                                 0
                                                                          0           0
(3) Leave non-resident                              3                0                       1             22
cold page 5 in the                                      0                                             1                             0          14
original position of                        4                                                                                   3
                                                                                                                    21
clock list                                      1
                                                                                                               0                     Resident
                                       5                                                                                            Cold Pages
(4) Add page 5 into                                                  hand-hot                                              20
non-resident cold                                                                                                   0
page list
                               6
(5) run hand-test to                                hand-cold                 Clock
                                                                                                                       1    19

find a position for
page 5                         7                                                           hand-test                 0      18


                                   8                                                                               0       17
              2       24

      9       0       0        23               0
          0                1                9                                                                      16
                                                                                                      0                         7         Non-
                                                                                                                                             6
                                                                                                                                        resident
                                       22
13   0                         1                10
                                                                                  0
                                                                                                          15                             colde
                                                                                                                                        page list
                                                            11                               14                        8                 is full!   16
15
     0                         0       21
                                                                         12           13

          0                0                                                                                        10                              14
     17           0   1        20

              18     19                                                                                                   11      12
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1           24                                        1
Page 25                                                          2                               23                                 0
                                                                          0           0
(5) Add page 5 to non-                              3                0                       1             22
resident cold page list                                 0                                             1                             0        14
                                            4                                                                                   3
                                                                                                                    21
Reorganize clock list                           1
                                                                                                               0                     Resident
                                       5                                                                                            Cold Pages
                                                                     hand-hot                                              20
                                                                                                                    0
                               6
                                                    hand-cold                 Clock
                                                                                                                       1    19


                               7                                                           hand-test                 0      18


                                   8                                                                               0       17
              2       24

      9       0       0        23               0
          0                1                9
                                                                                                      0                         7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                          15
                                                                                                                                                 5
                                                            11                                                         8
     0
                                                                                             14                                              0
15                             0       21
                                                                         12           13

          0                0                                                                                        10                           14
     17           0   1        20

              18     19                                                                                                   11      12
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1           25                                        1               25
Page 25                                                          2                              24                                  0      0
                                                                          0       0
Now we already have                                 3                0                         0          23
one empty room for                                      0                                            1                              0       14
page 25                                     4                                                                                   3
                                                                                                                   22
                                                1                                                             1                      Resident
(6) Check page 25 in
                                                                         hand-hot
                                       5                                                                                            Cold Pages
non-resident page                                                                                                          21
list---it is not in it                                                                                             0
(7) Add page 25 into           6
clock and resident                                  hand-cold                 Clock
                                                                                                                       0    20

cold page list
                               7                                                                                       1    19
                                                                                           hand-test
                                   8                                                                              0        18
              2       24

      9       0       0        23               0                                                             0
          0                1                9                                                                     17
                                                                                                     0                          7
                                                                                                                                        page 25
                                                                                                                                        does not
                                                                                                                                         6
                                       22                                                                                                 exit!
13   0                         1                10
                                                                                  0
                                                                                                         15
                                                                                                                                                5
                                                            11                                                         8
     0
                                                                                               14                                           0
15                             0       21
                                                                         12           13

          0                0                                                                                       10                              14
     17           0   1        20

              18     19                                                                                                  11      12
              Hot Pages                                                                                           Non-resident Cold Pages
Current accessing:                                                        1           25                                        1                25
Page 26                                                          2                              24                                  0        0
                                                                          0       0
Miss!                                               3                0                         0          23
                                                        0                                            1                              0        14
(1) run hand-cold to                        4                                                                                   3
                                                                                                                   22
reach the first met                             1                                                             1                      Resident
cold resident page                                                       hand-hot
                                       5                                                                                            Cold Pages
with reference bit 0                                                                                                       21
                                                                                                                   0
                               6
                                                    hand-cold                 Clock
                                                                                                                       0    20


                               7                                                                                       1    19
                                                                                           hand-test
                                   8                                                                              0        18
              2       24

      9       0       0        23               0                                                             0
          0                1                9                                                                     17
                                                                                                     0                          7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                         15
                                                                                                                                                 5
                                                            11                                                         8
     0
                                                                                               14                                            0
15                             0       21
                                                                         12           13

          0                0                                                                                       10                             14
     17           0   1        20

              18     19                                                                                                  11      12
              Hot Pages                                                                                           Non-resident Cold Pages
Current accessing:                                                        1           25                                        1                25
Page 26                                                          2                              24                                  0        0
                                                                          0       0
Page 4 has reference                                3                0                         0          23
bit 1, it should be                                     0                                            1                              0        14
upgraded to hot list.                       4                                                                                   3
                                                                                                                   22
                                                1                                                             1                      Resident
                                                                         hand-hot
1. Remove it from                      5                                                                                            Cold Pages
resident cold page list                                                                                                    21
                                                                                                                   0
                               6
                                                    hand-cold                 Clock
                                                                                                                       0    20


                               7                                                                                       1    19
                                                                                           hand-test
                                   8                                                                              0        18
              2       24

      9       0       0        23               0                                                             0
          0                1                9                                                                     17
                                                                                                     0                          7        6
                                       22
13   0                         1                10
                                                                                  0
                                                                                                         15
                                                                                                                                                 5
                                                            11                                                         8
     0
                                                                                               14                                            0
15                             0       21
                                                                         12           13

          0                0                                                                                       10                             14
     17           0   1        20

              18     19                                                                                                  11      12
              Hot Pages                                                                                           Non-resident Cold Pages
Current accessing:                                                                        1           25                                        1                25
Page 26                                                                          2                              24                                  0        0
                                                                                          0       0
Page 4 has reference                                                3                0                         0          23
bit 1, it should                                                        0                                            1                              0
upgrade to a hot page.                                                                                                                          3
                                                                                                                                   22
1. Remove it from
                                                                                         hand-hot                             1                      Resident
                                                       5                                                                                            Cold Pages
resident cold page list                                                                                                                    21
                                                                                                                                   0
2. Reset the reference                                               hand-cold
bit of page 4 and add it                       6
to hot page list                                                                              Clock
                                                                                                                                       0    20



                          4
                                              7                                                                                        1    19

                      0                                                                                    hand-test
                                                   8                                                                              0        18
              2               24

      9       0               0              23                 0                                                             0
          0                          1                      9                                                                     17
                                   Hot page
                                                                                                                     0                          7        6
                                                       22
13   0                                       1
                                   list is full!                10
                                                                                                  0
                                                                                                                         15
                                                                                                                                                                 5
                                                                            11                                                         8
     0
                                                                                                               14                                            0
15                                           0         21
                                                                                         12           13

          0                            0                                                                                           10                             14
     17           0           1              20

              18     19                                                                                                                  11      12
              Hot Pages                                                                                                           Non-resident Cold Pages
Current accessing:                                                                1           25                                        1                25
Page 26                                                                  2                              24                                  0        0
                                                                                  0       0
run hand-hot: degrade                                       3                0                         0          23
the first met hot page                                          0                                            1                              0
with reference bit 0 to                                                                                                                 3
                                                                                                                           22
a cold resident page
                                                                                 hand-hot                             1                      Resident
                                               5                                                                                            Cold Pages
                                                                                                                                   21
                                                                                                                           0
                                                             hand-cold
                                       6
                                                                                      Clock
                                                                                                                               0    20



                          4
                                       7                                                                                       1    19

                      0                                                                            hand-test
                                           8                                                                              0        18
              2               24

      9       0               0        23               0                                                             0
          0                        1                9                                                                     17
                                                                                                             0                          7        6
                                               22
13   0                                 1                10
                                                                                          0
                                                                                                                 15
                                                                                                                                                         5
                                                                    11                                                         8
     0
                                                                                                       14                                            0
15                                     0       21
                                                                                 12           13

          0                        0                                                                                       10                             14
     17           0           1        20

              18     19                                                                                                          11      12
              Hot Pages                                                                                                   Non-resident Cold Pages
Current accessing:                                                               1           25                                       1                 25
Page 26                                                                 2                                                                 0        0
                                                                                 0       0
Run hand-hot:                                              3                0                                   23
degrade first met hot                                          0                                           1                              0
page with ref bit 0 to a                                                                                                              3
                                                                                                                         22
cold resident page
                                                                                hand-hot                            1                      Resident
                                              5                                                                                           Cold Pages
Reorganize clock list                                                                                                            21
                                                                                                                         0                     24
                                                            hand-cold
                                      6
                                                                                                                             0    20           0
                                                                                     Clock


                          4
                                      7                                                                                      1    19

                      0                                                                           hand-test
                                          8                                                                             0        18
              2

      9       0                       23               0                                                            0
          0                       1                9                                                                    17
                                                                                                           0                          7        6
                                              22
13   0                                1                10
                                                                                         0
                                                                                                               15
                                                                                                                                                        5
                                                                   11                                                        8
     0
                                                                                                      14                                            0
15                                    0       21
                                                                                12           13

          0                       0                                                                                      10                              14
     17           0           1       20

              18     19                                                                                                        11      12
              Hot Pages                                                                                                 Non-resident Cold Pages
Current accessing:                                                          1           25                                      1                25
Page 26                                                            2                             4                                  0        0
                                                                            0       0
Page 4 is added into                                 3                 0                     0       24
hot page list.                                            0                                          0                              0        0 24
                                               5                                                                                3
                                                                                                                   23
Page 24 is added into
cold page list.
                                                                                                              1                      Resident
                                       6                                                                                            Cold Pages
                                                                                   hand-hot                                22
                                                                                                                   1
                                                         hand-cold
                                  7
                                                                                Clock
                                                                                                                       0    21


                                  8                                                                                    0    20


                                      9        0                                         hand-test                1        19
              2           4
      9       0       0           23                                                                          0
          0                   1                10
                                                                                                     0            18
                                                                                                                                7        6
                                          22
13   0                            1                 11                                       0           17
                                                              12
                                                                            0                                          8
                                                                                                                                                 5
     0
                                                                                             15                                              0
15                                0       21
                                                                           13           14

          0                   0                                                                                    10                             14
     17           0   1           20

              18     19                                                                                                  11      12
              Hot Pages                                                                                           Non-resident Cold Pages
Current accessing:                                                          1           25                                      1                25
Page 26                                                            2                             4                                  0        0
                                                                            0       0
run hand-cold:                                       3                 0                     0       24
Page 3 has reference                                      0                                          0                              0        0 24
bit 0, reclaim it and                          5                                                                                3
                                                                                                                   23
move hand-cold to the                                                                                         1                      Resident
next position                          6                                                                                            Cold Pages
                                                                                   hand-hot                                22
                                                                                                                   1
                                                         hand-cold
                                  7
                                                                                Clock
                                                                                                                       0    21


                                  8                                                                                    0    20


                                      9        0                                         hand-test                1        19
              2           4
      9       0       0           23                                                                          0
          0                   1                10
                                                                                                     0            18
                                                                                                                                7        6
                                          22
13   0                            1                 11                                       0           17
                                                              12
                                                                            0                                          8
                                                                                                                                                 5
     0
                                                                                             15                                              0
15                                0       21
                                                                           13           14

          0                   0                                                                                    10                             14
     17           0   1           20

              18     19                                                                                                  11      12
              Hot Pages                                                                                           Non-resident Cold Pages
Current accessing:                                                     1           25                                      1                   25
Page 26                                                       2                             4                                  0        0
                                                                       0       0
Reclaim page 3 and                                   3            0                     0       24
add it into non-                                                                                0                                       0 24
resident cold page list.                       5                                                              23
1. Leave non-resident
                                                                                                         1                      Resident
                                       6                                                                                       Cold Pages
cold page 3 in the old                                   hand-cold            hand-hot                                22
position in clock list.                                                                                       1
2. run hand-test: move            7
14 from non-resident                                                       Clock
                                                                                                                  0    21

cold page list.
                                  8                                                                               0    20


                                      9        0                                    hand-test                1        19               3
              2           4                                                                                                        0
      9       0       0           23                                                                     0
          0                   1                10
                                                                                                0            18
                                                                                                                                      Non-
                                                                                                                                    resident
                                                                                                                           7          6
                                                                                                                                   cold page
                                          22
13   0                            1                 11                                  0           17                             list is full!

                                                         12
                                                                       0                                          8
                                                                                                                                               5
     0
                                                                                        15                                                 0
15                                0       21
                                                                      13           14

          0                   0                                                                               10                                   14
     17           0   1           20

              18     19                                                                                             11      12
              Hot Pages                                                                                      Non-resident Cold Pages
Current accessing:                                                     1           25                                      1                25
Page 26                                                       2                             4                                  0        0
                                                                       0       0
Add page 3 into non-                                 3            0                     0       24
resident cold page list.                                                                        0                                       0 24
                                               5                                                              23
Reorganize clock list
                                                                                                         1                      Resident
                                       6                                                                                       Cold Pages
                                                         hand-cold            hand-hot                                22
                                                                                                              1
                                  7
                                                                           Clock
                                                                                                                  0    21


                                  8                                                                               0    20


                                      9        0                            hand-test                        1        19
              2           4
      9       0       0           23                                                                     0
          0                   1                10
                                                                                                0            18
                                                                                                                           7        6
                                          22
13   0                            1                 11                                  0           17
                                                         12
                                                                       0                                          8
                                                                                                                                            5
     0
                                                                                        15                                              0
15                                0       21
                                                                      13

          0                   0                                                                               10                                 3
     17           0   1           20

              18     19                                                                                             11      12
              Hot Pages                                                                                      Non-resident Cold Pages
Current accessing:                                                     1           25                                         1                 25
Page 26                                                       2                                4                                   0        0
                                                                       0       0
Add page 26 into                                     3            0                        0       24
resident cold page list                                                                            0                          26
                                                                                                                                   0        0 24
and clock list                                 5                                                                 26
                                                                                                            0                       Resident
                                       6                                                                                           Cold Pages
                                                         hand-cold                                                       23
                                                                                        hand-hot                 1
                                  7
                                                                           Clock
                                                                                                                     1    22


                                  8                                                                                  0    21


                                      9        0                            hand-test                           0        20
              2           4
      9       0       0           23                                                                        1
          0                   1                10
                                                                                                   0            19
                                                                                                                              7         6
                                          22
13   0                            1                 11                                     0           18
                                                         12
                                                                       0       0                                     8
                                                                                                                                                5
     0
                                                                                           17                                               0
15                                0       21
                                                                      13           15

          0                   0                                                                                  10                                  3
     17           0   1           20

              18     19                                                                                                11      12
              Hot Pages                                                                                         Non-resident Cold Pages
Current accessing:                                                     1           25                                         1                 25
Page 7                                                        2                                4                                   0        0
                                                                       0       0
Miss!                                                3            0                        0       24

(1) run hand-cold:                                                                                 0                          26
                                                                                                                                   0        0 24
                                               5                                                                 26
reclaim the first met
resident cold page                                                                                          0                       Resident
                                       6                                                                                           Cold Pages
(page 1)                                                 hand-cold                                                       23
                                                                                        hand-hot                 1
                                  7
                                                                           Clock
                                                                                                                     1    22


                                  8                                                                                  0    21


                                      9        0                            hand-test                           0        20
              2           4
      9       0       0           23                                                                        1
          0                   1                10
                                                                                                   0            19
                                                                                                                              7         6
                                          22
13   0                            1                 11                                     0           18
                                                         12
                                                                       0       0                                     8
                                                                                                                                                5
     0
                                                                                           17                                               0
15                                0       21
                                                                      13           15

          0                   0                                                                                  10                                  3
     17           0   1           20

              18     19                                                                                                11      12
              Hot Pages                                                                                         Non-resident Cold Pages
Current accessing:                                                    1            25                                                             25
Page 7                                                        2                                4                                            0
                                                     3            0            0           0       24
1. Leave page 1 in the
old position in clock                                                                              0                          26
                                                                                                                                   0        0 24
list.                                          5                                                                 26

2. run hand-test: to
                                                                                                            0                       Resident
                                       6                                                                                           Cold Pages
find a position for                                      hand-cold                                                       23
page 1                                                                                  hand-hot                 1
                                  7
                                                                           Clock
                                                                                                                     1    22


                                  8                                                                                  0    21


                                      9        0                            hand-test                           0        20
              2           4
      9       0       0           23                                                                        1
          0                   1                10
                                                                                                   0            19
                                                                                                                                          Non-
                                                                                                                                        resident
                                                                                                                              7           6
                                                                                                                                       cold page
                                          22
13   0                            1                 11                                     0           18                              list is full!

                                                         12
                                                                       0       0                                     8
                                                                                                                                                   5
     0
                                                                                           17                                                 0
15                                0       21
                                                                      13           15

          0                   0                                                                                  10                                    3
     17           0   1           20

              18     19                                                                                                11      12
              Hot Pages                                                                                         Non-resident Cold Pages
Current accessing:                                                1            25                                                           25
Page 7                                                    2                                4                                            0
                                                     3        0            0           0       24
3. Add page 1 into
non-resident cold                                                                              0                          26
                                                                                                                               0        0 24
page list.                                     5                                                             26
                                                                                                        0                       Resident
                                       6                                                                                       Cold Pages
                                                         hand-cold                                                   23
                                                                                    hand-hot                 1
                                  7
                                                                       Clock
                                                                                                                 1    22


                                  8                                                                              0    21


                                      9        0                        hand-test                           0        20
              2           4
      9       0       0           23                                                                    1
          0                   1                10
                                                                                               0            19
                                                                                                                          7         6
                                          22
13   0                            1                 11                                 0           18
                                                                   0       0                                     8
                                                                                                                                            5
     0
                                                                                       17                                               0
15                                0       21
                                                                  13           15

          0                   0                                                                              10                                  3
     17           0   1           20

              18     19                                                                                            11       1
              Hot Pages                                                                                     Non-resident Cold Pages
Current accessing:                                                        1            25                                                           25
Page 7                                                            2                                4                                            0
                                                             3        0            0           0       24
Now we have one
empty slot in memory                                                                                   0                          26
                                                                                                                                       0        0 24
                                                       5                                                             26
(1) check non-resident
cold page list and find                                                                                         0                       Resident
                                              6                                                                                        Cold Pages
it---we need to                                                  hand-cold                                                   23
upgrade it to hot page
                                                                                            hand-hot                 1
(2) run hand-hot:                         7
degrade the first met                                                          Clock
                                                                                                                         1    22

hot page with
reference bit 0 to cold                  8                                                                               0    21
page

                                              9        0                        hand-test                           0        20
              2           4
      9       0       0                 23                                                                      1
          0                     1                      10
                                                                                                       0            19
                              Hot page                                                                                            7         6
                                                  22
13   0                                  1
                              list is full!                 11                                 0           18
                                                                           0       0                                     8
                                                                                                                                                    5
     0
                                                                                               17                                               0
15                                      0         21
                                                                          13           15

          0                       0                                                                                  10                                  3
     17           0   1                 20

              18     19                                                                                                    11       1
              Hot Pages                                                                                             Non-resident Cold Pages
Current accessing:                                                        1            25                                                           25
Page 7                                                            2                                4                                            0
                                                             3        0            0           0       24
Page 23 has reference
bit 1---reset it to 0                                                                                  0                          26
                                                                                                                                       0        0 24
                                                       5                                                             26
                                                                                                                0                       Resident
                                               6                                                                                       Cold Pages
                                                                 hand-cold                                                   23
                                                                                            hand-hot                 0
                                                                                                                     1

                                                                               Clock
                                                                                                                         1    22


                          7               8                                                                              0    21
                      0
                                              9        0                        hand-test                           0        20
              2                   4
      9       0               0           23                                                                    1
          0                           0
                                      1                10
                                                                                                       0            19
                                                                                                                                            6
                                                  22
13   0                                    1                 11                                 0           18
                                                                           0       0                                     8
                                                                                                                                                    5
     0
                                                                                               17                                               0
15                                        0       21
                                                                          13           15

          0                           0                                                                              10                                  3
     17           0           1           20

              18     19                                                                                                    11       1
              Hot Pages                                                                                             Non-resident Cold Pages
Current accessing:                                                        1            25                                                           25
Page 7                                                            2                                4                                            0
                                                             3        0            0           0       24
Page 22 has reference
bit 1---reset it to 0                                                                                  0                          26
                                                                                                                                       0        0 24
                                                       5                                                             26
                                                                                                                0                       Resident
                                               6                                                                                       Cold Pages
                                                                 hand-cold                                                   23
                                                                                                                     0
                                                                                            hand-hot
                                                                               Clock
                                                                                                                         0
                                                                                                                         1    22


                          7               8                                                                              0    21
                      0
                                              9        0                        hand-test                           0        20
              2                   4
      9       0               0           23                                                                    1
          0                           0                10
                                                                                                       0            19
                                                                                                                                            6
                                                  22
13   0                                    0
                                          1                 11                                 0           18
                                                                           0       0                                     8
                                                                                                                                                    5
     0
                                                                                               17                                               0
15                                        0       21
                                                                          13           15

          0                           0                                                                              10                                  3
     17           0           1           20

              18     19                                                                                                    11       1
              Hot Pages                                                                                             Non-resident Cold Pages
Current accessing:                                                        1            25                                                          25
Page 7                                                            2                               4                                            0
                                                             3        0            0          0       24
Page 21 has reference
bit 0---degrade it                                                                                    0                          26
                                                                                                                                      0        0 24
                                                       5                                                            26
                                                                                                               0                       Resident
                                               6                                                                                      Cold Pages
                                                                 hand-cold                                                  23
                                                                                                                    0

                                                                               Clock        hand-hot                    0    22


                          7               8                                                                             0    21
                      0
                                              9        0                        hand-test                          0        20
              2                   4
      9       0               0           23                                                                   1
          0                           0                10
                                                                                                      0            19
                                                                                                                                           6
                                                  22
13   0                                    0                 11                               0            18
                                                                           0       0                                    8
                                                                                                                                                   5
     0
                                                                                              17                                               0
15                                        0       21
                                                                          13           15

          0                           0                                                                             10                                  3
     17           0           1           20

              18     19                                                                                                   11       1
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                        1            25                                                              25
Page 7                                                            2                               4                                                0
                                                             3        0            0          0       24
(3) Degrade page 21 to
resident cold page                                                                                    0                          26
                                                                                                                                      0            0 24
                                                       5                                                            26
Reorganize clock list
                                                                                                               0                       Resident
                                               6                                                                                      Cold Pages
                                                                 hand-cold                                                  23
                                                                                                                    0

                                                                               Clock
                                                                                            hand-hot                    0    22


                          7                                                                                                               21
                                          8
                      0                                                                                                                        0
                                              9        0                        hand-test                          0        20
              2                   4
      9       0               0           23                                                                   1
          0                           0                10
                                                                                                      0            19
                                                                                                                                               6
                                                  22
13   0                                    0                 11                               0            18
                                                                           0       0                                    8
                                                                                                                                                       5
     0                                                                    13           15
                                                                                              17                                                   0
15
          0                           0                                                                             10                                      3
     17           0           1           20

              18     19                                                                                                   11       1
              Hot Pages                                                                                            Non-resident Cold Pages
Current accessing:                                                         1           25                                   21                25
Page 7                                                           2                                4                              0        0
                                                    3                0             0          0       24
(4) insert page 21 to
resident cold page and                                                                                0                     26
                                                                                                                                 0        0 24
clock list                                     5                                                               26

(5) insert page 7 to hot
                                                                                                           0                      Resident
                                       6                                                                                         Cold Pages
page and clock list                                         hand-cold                                                  23
                                                                                                               0
                                  8
                                                                               Clock
                                                                                            hand-hot               0       22


                                  9        0                                                                    0          21


                                      10                                 hand-test                             0       7
              2           4
      9       0       0           23
          0                   0             11
                                                                                                      0    20
                                       22
                                                        0                                                                             6
13   0                            0                13            0                           1        20
                                                            15
                                                                           0           0                        8
                                                                                                                                              5
     0
                                                                                              19                                          0
15                                0    7
                                                                          17           18

          0                   0                                                                                10                                 3
     17           0   1           20

              18     19                                                                                           11       1
              Hot Pages                                                                                    Non-resident Cold Pages
Clock-Pro Implementation in Kernels
q   The Linux kernel for our implementation is 2.4.21.
    q   The VM management is well documented. (a Prentice
        Hall book in 04, Mel Gorman)
q   We are able to adjust the memory size available to the
    system and to the user in our experiment environment.
q   All pages are placed in a single clock list in CLOCK-PRO
    implementation with three hands.
q   SPEC 2000 and memory intensive software tools
    are used as benchmarks to test the CLOCK-Pro.
q   Compare the modified kernel with the original.
clock-pro
clock-pro
What is the Current Status of Clock-Pro?
q   Linux community is actively implementing it
    for its inclusion in the Kernel.
    q   Clock-Pro-Approximation.
    q   In Linux VM:
        q   Mhot == active list
        q   Mcold == inactive list
        q   Mtest == recently evicted pages

More Related Content

PPTX
Git commands
PPTX
GitHub Basics - Derek Bable
PDF
Git & GitHub WorkShop
PPTX
Introduction to git & GitHub
PPTX
Introduction to Git/Github - A beginner's guide
PDF
git and github
PPTX
Github basics
PDF
GIT | Distributed Version Control System
Git commands
GitHub Basics - Derek Bable
Git & GitHub WorkShop
Introduction to git & GitHub
Introduction to Git/Github - A beginner's guide
git and github
Github basics
GIT | Distributed Version Control System

What's hot (20)

PPTX
Igor Nicoli: External scripts O poder do Zabbix em suas mãos
PDF
MyRocks Deep Dive
PDF
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
PDF
DOAG Oracle Unified Audit in Multitenant Environments
PDF
FPGA+SoC+Linux実践勉強会資料
PDF
The linux networking architecture
PDF
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
PDF
HBase Advanced - Lars George
PPTX
Récupération d’une Base De Données & Flashback Database
PDF
Hive 입문 발표 자료
PDF
MySQL GTID 시작하기
PPTX
RocksDB compaction
PDF
Physical Memory Management.pdf
PDF
外部キー制約に伴うロックの小話
PDF
The MySQL SYS Schema
PDF
Etsy Activity Feeds Architecture
PDF
Best practices for MySQL High Availability Tutorial
PPTX
M|18 Deep Dive: InnoDB Transactions and Replication
PDF
Linux Performance Analysis: New Tools and Old Secrets
PDF
Kernel Recipes 2019 - Suricata and XDP
Igor Nicoli: External scripts O poder do Zabbix em suas mãos
MyRocks Deep Dive
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
DOAG Oracle Unified Audit in Multitenant Environments
FPGA+SoC+Linux実践勉強会資料
The linux networking architecture
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
HBase Advanced - Lars George
Récupération d’une Base De Données & Flashback Database
Hive 입문 발표 자료
MySQL GTID 시작하기
RocksDB compaction
Physical Memory Management.pdf
外部キー制約に伴うロックの小話
The MySQL SYS Schema
Etsy Activity Feeds Architecture
Best practices for MySQL High Availability Tutorial
M|18 Deep Dive: InnoDB Transactions and Replication
Linux Performance Analysis: New Tools and Old Secrets
Kernel Recipes 2019 - Suricata and XDP
Ad

Viewers also liked (15)

PDF
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
PPT
Sistemas Operativos
PPT
Operating system lecture1
PPT
Mca ii os u-4 memory management
PPT
General Electric Company
PPTX
Cloudera Impala - Las Vegas Big Data Meetup Nov 5th 2014
PDF
Oozie sweet
PDF
CoreOS : 설치부터 컨테이너 배포까지
PDF
HBase 훑어보기
PDF
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
PPTX
처음 접하는 Oozie Workflow, Coordinator
PDF
하둡 (Hadoop) 및 관련기술 훑어보기
PDF
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
PDF
3 Things Every Sales Team Needs to Be Thinking About in 2017
PDF
How to Become a Thought Leader in Your Niche
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
Sistemas Operativos
Operating system lecture1
Mca ii os u-4 memory management
General Electric Company
Cloudera Impala - Las Vegas Big Data Meetup Nov 5th 2014
Oozie sweet
CoreOS : 설치부터 컨테이너 배포까지
HBase 훑어보기
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
처음 접하는 Oozie Workflow, Coordinator
하둡 (Hadoop) 및 관련기술 훑어보기
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
3 Things Every Sales Team Needs to Be Thinking About in 2017
How to Become a Thought Leader in Your Niche
Ad

Similar to clock-pro (20)

PPT
Ee2 chapter13 counters
PDF
Concurrency And Erlang
PDF
Effective and Efficient Shape-Based Pattern Detection over Streaming Time Series
PDF
Effective and efficient shape based pattern
PDF
Chapter2
PDF
Microsoft Word Hw#2
PPTX
Counter
PPTX
Counter with memes
PPTX
Counter with memes
PPT
Counters
PDF
A new approach to ward off error propagation effect of aes –
PPT
MSI Shift Registers
ODS
Conversor nº binarios a decimales y viceversa 2
PDF
16%20 lecture
PDF
Project lfsr
PDF
Finpro be inspired Ideo
PDF
Virus Detection System
PDF
Shift register
PDF
Informe simulacion digital yolfred uzcategui - 25.242.800
PDF
Bits, Bytes and Blobs
Ee2 chapter13 counters
Concurrency And Erlang
Effective and Efficient Shape-Based Pattern Detection over Streaming Time Series
Effective and efficient shape based pattern
Chapter2
Microsoft Word Hw#2
Counter
Counter with memes
Counter with memes
Counters
A new approach to ward off error propagation effect of aes –
MSI Shift Registers
Conversor nº binarios a decimales y viceversa 2
16%20 lecture
Project lfsr
Finpro be inspired Ideo
Virus Detection System
Shift register
Informe simulacion digital yolfred uzcategui - 25.242.800
Bits, Bytes and Blobs

Recently uploaded (20)

PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
Computer Architecture Input Output Memory.pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
Climate Change and Its Global Impact.pptx
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PDF
Complications of Minimal Access-Surgery.pdf
Introduction to pro and eukaryotes and differences.pptx
Computer Architecture Input Output Memory.pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
What’s under the hood: Parsing standardized learning content for AI
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Climate Change and Its Global Impact.pptx
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
Core Concepts of Personalized Learning and Virtual Learning Environments
Unit 4 Computer Architecture Multicore Processor.pptx
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Environmental Education MCQ BD2EE - Share Source.pdf
Literature_Review_methods_ BRACU_MKT426 course material
Complications of Minimal Access-Surgery.pdf

clock-pro

  • 1. Clock-Pro: An Effective Replacement in OS Kernel Xiaodong Zhang College of William and Mary
  • 2. How to Make LIRS Work in OS Kernels? q Most system kernels use the CLOCK algorithm, an approximation of LRU. q We have made efforts to directly implement LIRS in Linux kernels, but … q Our experience tells us that we must build on existing strength. q CLOCK is the base for LIRS.
  • 3. Basic CLOCK Replacement  All the resident pages are placed around a circular list, like a clock;  Each page is associated with a reference bit, indicating if the page has been accessed. 1 0 0 0 1 0 0 1 0 1 CLOCK hand 0 0 1 On a HIT 0 0 Set Reference bit to 1 (no algorithm operations) 1 0 1 0 0 0 0 1 1 0
  • 4. Basic CLOCK Replacement Starts from the currently pointed page, and evicts the page if it is”`0”; Move the clock hand until reach a “0” page; Give “1” page a second chance, and reset its “1” to “0” 1 0 0 0 1 0 0 0 1 On a sequence of 1 CLOCK hand 0 two MISSes 0 0 0 1 1 0 1 0 0 0 0 1 1 0
  • 5. The CLOCK with a Long History “In the Multics system a paging algorithm has been developed that has the implementation ease and low overhead of the FIFO strategy and is an approximation to the LRU strategy” “A paging Expreiment with the Multics System” MIT Project MAC Report MAC-M-384, May 1968, Fernando J. Corbato (1990 Turing Award Laureate)
  • 6. The CLOCK has been Widely Used Major OS Major OS Textbooks Multics Tanebaum & Woodhull UNIX/AIX/Linux/BSD Silberschatz & Galvin VAX/VMS Stallings (for undergraduate) DB2 Windows/Oracle/Solaris
  • 7. Prior Work on LRU versus CLOCK LRU related work CLOCK related work FBR (1990, SIGMETRICS) GCLOCK (1978, ACM TDBS) LRU-2 (1993, SIGMOD) 2Q (1994, VLDB) SEQ (1997, SIGMETRICS) LRFU (1999, OSDI) EELRU (1999, SIGMETRICS) MQ (2001, USENIX) 1968 2003 LIRS (2002, SIGMETRICS) CAR (2004, FAST) ARC (2003, FAST) CLOCK-Pro (2005, USENIX)
  • 8. GCLOCK Replacement  Introduce additional page access information.  A counter is associated with each page rather than a single bit;  The counter is incremented on a page hit;  The clock hand periodically moves, and decrements the counter of each block;  The page with its counter of 0 is replaced.
  • 9. Age-Based CLOCK in Linux and FreeBSD  An age is associated with each page in addition to a reference bit;  When the clock hand sweeps through pages, it increases its age if the page’s bit is 1, otherwise it decreases its age.  The page with its age of 0 is replaced.
  • 10. CAR: CLOCK with Adaptive Replacement  Two clocks T1 and T2, one is for cold pages touched only once recently (Recency), another is for hot pages touched at least twice (“Frequency”);  Queues B1 and B2 are for pages recently replaced from T1 and T2;  The memory allocations for T1 or T2 depend on the ratio of references to B2 and B1.
  • 11. Limits of CAR  A page that is regularly accessed with its reuse distance a little bit larger memory size has no hits in T1 or T2. (inherited LRU problem).  A page in T2 can stay in memory without any accesses because frequency does not reflect ``reuse distance”.  No system implementations yet
  • 12. Basic Ideas of CLOCK-Pro  It is an approximation of LIRS based on the CLOCK infrastructure.  Pages categorized into two groups: cold pages and hot pages based on their reuse distances (or IRR).  There are three hands: Hand-hot for hot pages, Hand-cold for cold pages, and Hand-test for running a reuse distance test for a block;  The allocation of memory pages between hot pages (Mhot) and cold pages (Mcold ) are adaptively adjusted. (M = Mhot + Mcold)  All hot pages are resident (=Lir blocks), some cold pages are also resident (= Hir Blocks); keep track of recently replaced pages (=non-resident Hir blocks)
  • 13. 0 1 Cold resident CLOCK-Pro Structure 0 1 Hot 1 24 Cold non-resident 2 23 Hand-hot: find a hot 0 3 0 0 page to be demoted 0 22 into a cold 0 page. 1 4 0 0 21 5 0 hand-hot 0 20 Two reasons for a resident cold page: All hands move 6 1 19 • A fresh replacement: a first access. hand-cold in the clockwise • It is demoted from a hotused to find Hand-cold is page. direction. hand-test 7 a page for replacement. 0 18 8 0 17 Hand-test: (1) to determine if a 0 cold page is promoted to be hot; (2) 9 16 remove non-resident cold pages out 0 of the clock. 10 15 1 0 11 14 12 13
  • 14. Accessing Sequence: 1 24 1 5 ….27, 7, 26, 25, 4, 23 2 23 0 0 0 0 3 0 0 22 0 1 0 04 4 3 0 21 0 Resident 5 Cold Pages 0 hand-hot 20 0 6 hand-cold Clock 1 19 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 0 9 16 0 7 6 22 13 0 1 10 0 15 11 14 8 16 15 0 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 15. Current accessing: 1 24 1 5 Page 23 2 23 0 0 0 0 Hit! 3 0 0 1 22 Set reference bit of 0 1 0 04 Page 23 to 1. 4 3 21 No other operation 0 0 Resident 5 Cold Pages 0 hand-hot 20 0 6 hand-cold Clock 1 19 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 0 1 9 16 0 7 6 22 13 0 1 10 0 15 11 14 8 16 15 0 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 16. Current accessing: 1 24 1 5 Page 4 2 23 0 0 0 0 Hit! 3 0 1 22 Set reference bit of 0 1 0 04 1 Page 4 to 1. 4 3 21 No other operation 0 1 0 Resident 5 Cold Pages 0 hand-hot 20 0 6 hand-cold Clock 1 19 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 1 9 16 0 7 6 22 13 0 1 10 0 15 11 14 8 16 15 0 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 17. Current accessing: 1 24 1 5 Page 25 2 23 0 0 0 0 Miss! 3 0 1 22 0 1 0 14 (1) run hand-cold--- 4 3 21 reclaim the first met 1 cold page with ref bit 0 0 Resident 5 Cold Pages (Page 5) 0 hand-hot 20 0 (2) Reclaim cold page 5 and remove it from 6 resident cold page list hand-cold Clock 1 19 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 1 9 16 0 7 6 22 13 0 1 10 0 15 11 14 8 16 15 0 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 18. Current accessing: 1 24 1 Page 25 2 23 0 0 0 (3) Leave non-resident 3 0 1 22 cold page 5 in the 0 1 0 14 original position of 4 3 21 clock list 1 0 Resident 5 Cold Pages (4) Add page 5 into hand-hot 20 non-resident cold 0 page list 6 (5) run hand-test to hand-cold Clock 1 19 find a position for page 5 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 1 9 16 0 7 Non- 6 resident 22 13 0 1 10 0 15 colde page list 11 14 8 is full! 16 15 0 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 19. Current accessing: 1 24 1 Page 25 2 23 0 0 0 (5) Add page 5 to non- 3 0 1 22 resident cold page list 0 1 0 14 4 3 21 Reorganize clock list 1 0 Resident 5 Cold Pages hand-hot 20 0 6 hand-cold Clock 1 19 7 hand-test 0 18 8 0 17 2 24 9 0 0 23 0 0 1 9 0 7 6 22 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 20. Current accessing: 1 25 1 25 Page 25 2 24 0 0 0 0 Now we already have 3 0 0 23 one empty room for 0 1 0 14 page 25 4 3 22 1 1 Resident (6) Check page 25 in hand-hot 5 Cold Pages non-resident page 21 list---it is not in it 0 (7) Add page 25 into 6 clock and resident hand-cold Clock 0 20 cold page list 7 1 19 hand-test 8 0 18 2 24 9 0 0 23 0 0 0 1 9 17 0 7 page 25 does not 6 22 exit! 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 21. Current accessing: 1 25 1 25 Page 26 2 24 0 0 0 0 Miss! 3 0 0 23 0 1 0 14 (1) run hand-cold to 4 3 22 reach the first met 1 1 Resident cold resident page hand-hot 5 Cold Pages with reference bit 0 21 0 6 hand-cold Clock 0 20 7 1 19 hand-test 8 0 18 2 24 9 0 0 23 0 0 0 1 9 17 0 7 6 22 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 22. Current accessing: 1 25 1 25 Page 26 2 24 0 0 0 0 Page 4 has reference 3 0 0 23 bit 1, it should be 0 1 0 14 upgraded to hot list. 4 3 22 1 1 Resident hand-hot 1. Remove it from 5 Cold Pages resident cold page list 21 0 6 hand-cold Clock 0 20 7 1 19 hand-test 8 0 18 2 24 9 0 0 23 0 0 0 1 9 17 0 7 6 22 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 23. Current accessing: 1 25 1 25 Page 26 2 24 0 0 0 0 Page 4 has reference 3 0 0 23 bit 1, it should 0 1 0 upgrade to a hot page. 3 22 1. Remove it from hand-hot 1 Resident 5 Cold Pages resident cold page list 21 0 2. Reset the reference hand-cold bit of page 4 and add it 6 to hot page list Clock 0 20 4 7 1 19 0 hand-test 8 0 18 2 24 9 0 0 23 0 0 0 1 9 17 Hot page 0 7 6 22 13 0 1 list is full! 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 24. Current accessing: 1 25 1 25 Page 26 2 24 0 0 0 0 run hand-hot: degrade 3 0 0 23 the first met hot page 0 1 0 with reference bit 0 to 3 22 a cold resident page hand-hot 1 Resident 5 Cold Pages 21 0 hand-cold 6 Clock 0 20 4 7 1 19 0 hand-test 8 0 18 2 24 9 0 0 23 0 0 0 1 9 17 0 7 6 22 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 25. Current accessing: 1 25 1 25 Page 26 2 0 0 0 0 Run hand-hot: 3 0 23 degrade first met hot 0 1 0 page with ref bit 0 to a 3 22 cold resident page hand-hot 1 Resident 5 Cold Pages Reorganize clock list 21 0 24 hand-cold 6 0 20 0 Clock 4 7 1 19 0 hand-test 8 0 18 2 9 0 23 0 0 0 1 9 17 0 7 6 22 13 0 1 10 0 15 5 11 8 0 14 0 15 0 21 12 13 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 26. Current accessing: 1 25 1 25 Page 26 2 4 0 0 0 0 Page 4 is added into 3 0 0 24 hot page list. 0 0 0 0 24 5 3 23 Page 24 is added into cold page list. 1 Resident 6 Cold Pages hand-hot 22 1 hand-cold 7 Clock 0 21 8 0 20 9 0 hand-test 1 19 2 4 9 0 0 23 0 0 1 10 0 18 7 6 22 13 0 1 11 0 17 12 0 8 5 0 15 0 15 0 21 13 14 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 27. Current accessing: 1 25 1 25 Page 26 2 4 0 0 0 0 run hand-cold: 3 0 0 24 Page 3 has reference 0 0 0 0 24 bit 0, reclaim it and 5 3 23 move hand-cold to the 1 Resident next position 6 Cold Pages hand-hot 22 1 hand-cold 7 Clock 0 21 8 0 20 9 0 hand-test 1 19 2 4 9 0 0 23 0 0 1 10 0 18 7 6 22 13 0 1 11 0 17 12 0 8 5 0 15 0 15 0 21 13 14 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 28. Current accessing: 1 25 1 25 Page 26 2 4 0 0 0 0 Reclaim page 3 and 3 0 0 24 add it into non- 0 0 24 resident cold page list. 5 23 1. Leave non-resident 1 Resident 6 Cold Pages cold page 3 in the old hand-cold hand-hot 22 position in clock list. 1 2. run hand-test: move 7 14 from non-resident Clock 0 21 cold page list. 8 0 20 9 0 hand-test 1 19 3 2 4 0 9 0 0 23 0 0 1 10 0 18 Non- resident 7 6 cold page 22 13 0 1 11 0 17 list is full! 12 0 8 5 0 15 0 15 0 21 13 14 0 0 10 14 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 29. Current accessing: 1 25 1 25 Page 26 2 4 0 0 0 0 Add page 3 into non- 3 0 0 24 resident cold page list. 0 0 24 5 23 Reorganize clock list 1 Resident 6 Cold Pages hand-cold hand-hot 22 1 7 Clock 0 21 8 0 20 9 0 hand-test 1 19 2 4 9 0 0 23 0 0 1 10 0 18 7 6 22 13 0 1 11 0 17 12 0 8 5 0 15 0 15 0 21 13 0 0 10 3 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 30. Current accessing: 1 25 1 25 Page 26 2 4 0 0 0 0 Add page 26 into 3 0 0 24 resident cold page list 0 26 0 0 24 and clock list 5 26 0 Resident 6 Cold Pages hand-cold 23 hand-hot 1 7 Clock 1 22 8 0 21 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 1 10 0 19 7 6 22 13 0 1 11 0 18 12 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 31. Current accessing: 1 25 1 25 Page 7 2 4 0 0 0 0 Miss! 3 0 0 24 (1) run hand-cold: 0 26 0 0 24 5 26 reclaim the first met resident cold page 0 Resident 6 Cold Pages (page 1) hand-cold 23 hand-hot 1 7 Clock 1 22 8 0 21 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 1 10 0 19 7 6 22 13 0 1 11 0 18 12 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 32. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 1. Leave page 1 in the old position in clock 0 26 0 0 24 list. 5 26 2. run hand-test: to 0 Resident 6 Cold Pages find a position for hand-cold 23 page 1 hand-hot 1 7 Clock 1 22 8 0 21 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 1 10 0 19 Non- resident 7 6 cold page 22 13 0 1 11 0 18 list is full! 12 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 12 Hot Pages Non-resident Cold Pages
  • 33. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 3. Add page 1 into non-resident cold 0 26 0 0 24 page list. 5 26 0 Resident 6 Cold Pages hand-cold 23 hand-hot 1 7 Clock 1 22 8 0 21 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 1 10 0 19 7 6 22 13 0 1 11 0 18 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 34. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 Now we have one empty slot in memory 0 26 0 0 24 5 26 (1) check non-resident cold page list and find 0 Resident 6 Cold Pages it---we need to hand-cold 23 upgrade it to hot page hand-hot 1 (2) run hand-hot: 7 degrade the first met Clock 1 22 hot page with reference bit 0 to cold 8 0 21 page 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 1 10 0 19 Hot page 7 6 22 13 0 1 list is full! 11 0 18 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 35. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 Page 23 has reference bit 1---reset it to 0 0 26 0 0 24 5 26 0 Resident 6 Cold Pages hand-cold 23 hand-hot 0 1 Clock 1 22 7 8 0 21 0 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 0 1 10 0 19 6 22 13 0 1 11 0 18 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 36. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 Page 22 has reference bit 1---reset it to 0 0 26 0 0 24 5 26 0 Resident 6 Cold Pages hand-cold 23 0 hand-hot Clock 0 1 22 7 8 0 21 0 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 0 10 0 19 6 22 13 0 0 1 11 0 18 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 37. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 Page 21 has reference bit 0---degrade it 0 26 0 0 24 5 26 0 Resident 6 Cold Pages hand-cold 23 0 Clock hand-hot 0 22 7 8 0 21 0 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 0 10 0 19 6 22 13 0 0 11 0 18 0 0 8 5 0 17 0 15 0 21 13 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 38. Current accessing: 1 25 25 Page 7 2 4 0 3 0 0 0 24 (3) Degrade page 21 to resident cold page 0 26 0 0 24 5 26 Reorganize clock list 0 Resident 6 Cold Pages hand-cold 23 0 Clock hand-hot 0 22 7 21 8 0 0 9 0 hand-test 0 20 2 4 9 0 0 23 1 0 0 10 0 19 6 22 13 0 0 11 0 18 0 0 8 5 0 13 15 17 0 15 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 39. Current accessing: 1 25 21 25 Page 7 2 4 0 0 3 0 0 0 24 (4) insert page 21 to resident cold page and 0 26 0 0 24 clock list 5 26 (5) insert page 7 to hot 0 Resident 6 Cold Pages page and clock list hand-cold 23 0 8 Clock hand-hot 0 22 9 0 0 21 10 hand-test 0 7 2 4 9 0 0 23 0 0 11 0 20 22 0 6 13 0 0 13 0 1 20 15 0 0 8 5 0 19 0 15 0 7 17 18 0 0 10 3 17 0 1 20 18 19 11 1 Hot Pages Non-resident Cold Pages
  • 40. Clock-Pro Implementation in Kernels q The Linux kernel for our implementation is 2.4.21. q The VM management is well documented. (a Prentice Hall book in 04, Mel Gorman) q We are able to adjust the memory size available to the system and to the user in our experiment environment. q All pages are placed in a single clock list in CLOCK-PRO implementation with three hands. q SPEC 2000 and memory intensive software tools are used as benchmarks to test the CLOCK-Pro. q Compare the modified kernel with the original.
  • 43. What is the Current Status of Clock-Pro? q Linux community is actively implementing it for its inclusion in the Kernel. q Clock-Pro-Approximation. q In Linux VM: q Mhot == active list q Mcold == inactive list q Mtest == recently evicted pages

Editor's Notes

  • #4: Then LRU is approximated by the CLOCK replacement in VM. In CLOCK, All the resident pages are placed around the a circular list, like a clock. There is a clock hand turning in the clockwise direction to search victim pages. Each page is associated with a reference bit, indicating if the page has been accessed. On a hit access, the bit is set automatically by hardware, there are no algorithm operations.
  • #5: On a miss access, CLOCK t urns the clock hand, evict the first “0” page; CLOCK inserts the missed page at the head, initialize its reference bit to 0. If the ref-bit of page pointed by the hand is “1”, CLOCK gives it a second chance without replacing it, And reset its “1” to “0” and continue to look for a page with its bit of “0” CLOCK simulates LRU replacement very well, and its hit ratios are very close to LRU.
  • #6: The CLOCK replacement has a long history. It dates back to 1968, F. Corbato describes the CLOCK in his report on Multics system: … Corbato later won Turing Award in 1990.
  • #7: CLOCK or its variants have been widely used in major OS and described in textbooks. It still plays a dominant role in today’s systems, even with its performance concerns with certain access patterns.
  • #8: Now let’s see the prior research work on LRU and CLOCK. Because the importance of replacement algorithms and the well-known LRU performance problems, there are a large number of new algorithms proposed for better performance, but almost all of them target at LRU. See the long list over the decades. However, the list for CLOCK is much shorter. See, from 1968 to 1998, it is a really a long time for a person! Only GCLOCK and several CLOCK variants are proposed during the long time. The very stringent low cost requirement poses a big challenge on inventing new VM replacement. Recently there is a VM replacement algorithm called CAR proposed by the researchers at IBM. And we proposed the CLOCK-Pr n pljn.o.
  • #9: FCLOCK introduce …
  • #10: Linux and FreeBSD use age-based CLOCK replacements. … However, GCLOCK and age-based CLCOK cannot provide consistent performance improvements. Their performance can be either better or worse than CLOCK. Another problem is that they will consume too many CPU cycles and adjust to changes in the access patterns slowly.
  • #11: CAR is a recently proposed VM replacement algorithm. In CAR, ….
  • #12: However, in CAR, …. So some undesirable situation can occur. E.g. … So CAR also can not consistently improve CLOCK performance.
  • #13: Now let’s see CLOCK-Pro, which uses the same principle as that of LIRS …
  • #14: I would like to use the figure to illustrate CLOCK-Pro. There are several kinds of pages on the clock. …. I associate a test period to a cold page to test its reuse distance.