1 / 43

Clock-Pro: An Effective Replacement in OS Kernel

Clock-Pro: An Effective Replacement in OS Kernel. Xiaodong Zhang College of William and Mary. How to Make LIRS Work in OS Kernels?. Most system kernels use the CLOCK algorithm, an approximation of LRU. We have made efforts to directly implement LIRS in Linux kernels, but …

portia
Télécharger la présentation

Clock-Pro: An Effective Replacement in OS Kernel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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? • Most system kernels use the CLOCK algorithm, an approximation of LRU. • We have made efforts to directly implement LIRS in Linux kernels, but … • Our experience tells us that we must build on existing strength. • CLOCK is the base for LIRS.

  3. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 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. CLOCK hand On a HIT Set Reference bit to 1 (no algorithm operations)

  4. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 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” On a sequence of two MISSes CLOCK hand

  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 • UNIX/AIX/Linux/BSD • VAX/VMS • DB2 • Windows/Oracle/Solaris • Tanebaum & Woodhull • Silberschatz & Galvin • Stallings (for undergraduate)

  7. 2003 1968 Prior Work on LRU versus CLOCK LRU related work CLOCK related work • FBR (1990, SIGMETRICS) • LRU-2 (1993, SIGMOD) • 2Q (1994, VLDB) • SEQ (1997, SIGMETRICS) • LRFU (1999, OSDI) • EELRU (1999, SIGMETRICS) • MQ (2001, USENIX) • LIRS (2002, SIGMETRICS) • ARC (2003, FAST) • GCLOCK (1978, ACM TDBS) • CAR (2004, 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 memorywithout 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 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 16 CLOCK-Pro Structure Cold resident Hot 1 24 2 Cold non-resident 23 Hand-hot: find a hot page to be demoted into a cold page. 3 22 4 21 5 hand-hot 20 • Two reasons for a resident cold page: • A fresh replacement: a first access. • It is demoted from a hot page. All hands move in the clockwise direction. 6 19 hand-cold Hand-cold is used to find a page for replacement. 7 hand-test 18 8 17 Hand-test: (1) to determine if a cold page is promoted to be hot; (2) remove non-resident cold pages out of the clock. 9 10 15 11 14 12 13

  14. 1 24 2 23 3 22 2 24 4 9 23 21 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 5 22 13 20 6 15 21 19 17 20 18 7 18 19 8 1 17 5 9 0 0 0 0 0 0 0 0 7 6 4 3 10 15 8 16 11 14 12 13 16 14 10 11 12 Accessing Sequence: ….27, 7, 26, 25, 4, 23 Resident Cold Pages hand-hot hand-cold Clock hand-test Hot Pages Non-resident Cold Pages

  15. 1 24 2 23 3 22 2 24 4 9 23 21 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 5 22 13 20 6 15 21 19 17 20 18 7 18 19 8 1 17 5 9 0 0 0 0 0 0 0 0 7 6 4 3 10 15 8 16 11 14 12 13 16 14 10 11 12 Current accessing: Page 23 Hit! Set reference bit of Page 23 to 1. No other operation Resident Cold Pages hand-hot hand-cold Clock hand-test Hot Pages Non-resident Cold Pages

  16. 1 24 2 23 3 22 2 24 4 9 23 21 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 5 22 13 20 6 15 21 19 17 20 18 7 18 19 8 1 17 5 1 1 9 0 0 0 0 0 0 0 0 7 6 4 3 10 15 8 16 11 14 12 13 16 14 10 11 12 Current accessing: Page 4 Hit! Set reference bit of Page 4 to 1. No other operation Resident Cold Pages hand-hot hand-cold Clock hand-test Hot Pages Non-resident Cold Pages

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

  18. 1 24 2 23 3 22 2 24 4 9 23 21 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 22 13 20 6 15 21 19 hand-cold 17 20 18 7 5 18 19 8 1 17 9 1 0 0 0 0 1 7 6 4 3 10 15 8 16 11 14 12 13 16 14 10 11 12 Current accessing: Page 25 (3) Leave non-resident cold page 5 in the original position of clock list Resident Cold Pages hand-hot (4) Add page 5 into non-resident cold page list (5) run hand-test to find a position for page 5 Clock hand-test Non-resident colde page list is full! Hot Pages Non-resident Cold Pages

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

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

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

  22. 1 25 25 2 24 3 Page 4 has reference bit 1, it should upgrade to a hot page. 23 2 24 4 9 23 22 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 22 13 21 6 15 21 20 hand-cold 17 20 19 7 5 18 19 8 1 18 5 9 17 1 0 0 0 0 0 0 1 0 7 6 4 3 10 15 8 11 14 12 13 14 10 11 12 Current accessing: Page 26 hand-hot Resident Cold Pages 1. Remove it from resident cold page list Clock hand-test Hot Pages Non-resident Cold Pages

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

  24. 1 25 25 2 24 3 23 2 24 9 23 22 0 0 0 0 0 0 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 22 13 21 hand-cold 6 15 21 20 17 20 19 7 4 5 18 19 8 1 18 5 9 17 0 0 0 0 0 0 0 7 6 3 10 15 8 11 14 12 13 14 10 11 12 Current accessing: Page 26 run hand-hot: degrade the first met hot page with reference bit 0 to a cold resident page hand-hot Resident Cold Pages Clock hand-test Hot Pages Non-resident Cold Pages

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

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

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

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

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

  30. 1 25 24 25 2 3 2 26 24 9 26 23 0 1 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 6 22 13 23 7 15 21 22 17 20 21 8 4 4 5 18 19 9 1 20 5 3 10 19 0 0 0 0 0 0 0 0 0 7 6 11 18 8 12 17 13 15 10 11 12 Current accessing: Page 26 Add page 26 into resident cold page list and clock list Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  31. 1 25 24 25 2 3 2 26 24 9 26 23 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 6 22 13 23 7 15 21 22 17 20 21 8 4 4 5 18 19 9 1 20 5 3 10 19 0 0 0 0 0 0 0 0 0 7 6 11 18 8 12 17 13 15 10 11 12 Current accessing: Page 7 Miss! (1) run hand-cold: reclaim the first met resident cold page (page 1) Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  32. 24 25 1 25 2 3 2 26 24 9 26 23 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 6 22 13 23 7 15 21 22 17 20 21 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 7 6 11 18 8 12 17 13 15 10 11 12 Current accessing: Page 7 1.Leave page 1 in the old position in clock list. Resident Cold Pages 2. run hand-test: to find a position for page 1 hand-cold hand-hot Clock hand-test Non-resident cold page list is full! Hot Pages Non-resident Cold Pages

  33. 24 25 1 25 2 3 2 26 24 9 26 23 1 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 6 22 13 23 7 15 21 22 17 20 21 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 7 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 3.Add page 1 into non-resident cold page list. Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  34. 24 25 1 25 2 3 2 26 24 9 26 23 1 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 6 22 13 23 7 15 21 22 17 20 21 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 7 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 Now we have one empty slot in memory (1) check non-resident cold page list and find it---we need to upgrade it to hot page Resident Cold Pages hand-cold hand-hot (2) run hand-hot: degrade the first met hot page with reference bit 0 to cold page Clock hand-test Hot page list is full! Hot Pages Non-resident Cold Pages

  35. 25 24 1 25 2 3 2 26 24 9 26 23 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 6 22 13 23 15 21 22 17 20 21 7 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 Page 23 has reference bit 1---reset it to 0 Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  36. 25 24 1 25 2 3 2 26 24 9 26 23 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 6 22 13 23 15 21 22 17 20 21 7 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 Page 22 has reference bit 1---reset it to 0 Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  37. 24 25 1 25 2 3 2 26 24 9 26 23 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 6 22 13 23 15 21 22 17 20 21 7 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 Page 21 has reference bit 0---degrade it Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  38. 25 24 1 25 2 3 2 26 24 9 26 23 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 6 22 13 23 15 22 17 20 21 7 8 4 4 5 18 19 9 20 5 3 10 19 0 0 0 0 0 0 0 0 6 11 18 8 17 13 15 10 11 1 Current accessing: Page 7 (3) Degrade page 21 to resident cold page Reorganize clock list Resident Cold Pages hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  39. 25 24 1 21 0 2 3 2 26 24 9 26 23 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 6 22 13 23 8 15 22 17 20 21 9 4 4 5 18 19 10 7 5 3 11 20 0 0 0 0 0 0 0 0 6 13 20 8 15 19 17 18 7 10 11 1 Current accessing: Page 7 25 (4) insert page 21 to resident cold page and clock list Resident Cold Pages (5) insert page 7 to hot page and clock list hand-cold hand-hot Clock hand-test Hot Pages Non-resident Cold Pages

  40. Clock-Pro Implementation in Kernels • The Linux kernel for our implementation is 2.4.21. • The VM management is well documented. (a Prentice Hall book in 04, Mel Gorman) • We are able to adjust the memory size available to the system and to the user in our experiment environment. • All pages are placed in a single clock list in CLOCK-PRO implementation with three hands. • SPEC 2000 and memory intensive software tools are used as benchmarks to test the CLOCK-Pro. • Compare the modified kernel with the original.

  41. What is the Current Status of Clock-Pro? • Linux community is actively implementing it for its inclusion in the Kernel. • Clock-Pro-Approximation. • In Linux VM: • Mhot == active list • Mcold == inactive list • Mtest == recently evicted pages

More Related