Buffer Management PowerPoint PPT Presentation

presentation player overlay
1 / 9
About This Presentation
Transcript and Presenter's Notes

Title: Buffer Management


1
Buffer Management
  • The buffer manager reads disk pages into a
  • main memory page as needed. The general
  • idea is to minimize the amount of disk I/O by
  • keeping likely-to-be-requested pages in
  • memory.

2
Overview
Requests
Buffer Manager
memory
Disk Files
disk
  • The collection of main memory pages used by the
  • buffer manager to store needed data is called
    the
  • buffer pool.

3
When a Page is Requested...
  • If the requested page is not in the pool
  • Choose a buffer block for replacement
  • If it has been modified, write it back to the
    disk
  • Read the requested page into the buffer block
  • Pin the page and return its address
  • A pin_count is used since a page can be requested
    multiple times.

4
When a Page is Released...
  • Requestor of page must unpin it after using, and
    indicate if the page has been modified.
  • Set the dirty flag accordingly
  • Decrement the pin_count
  • A page is a candidate for replacement iff its
    pin_count 0

5
Buffer Replacement Strategies(1)
  • Least-Recently Used (LRU)
  • Choose the block that has not been accessed for
    the longest time
  • Intuitively, buffers that have not been used for
    a long time are less likely to be accessed sooner
    than those that have been accessed recently
  • Maintain information after each access operation

6
Buffer Replacement Strategies(2)
  • Most-Recently Used (MRU)
  • Opposite to LRU
  • First-In-First-Out (FIFO)
  • Choose the block that has been occupied by the
    same page for the longest time
  • Require less maintenance than LRU, but it can
    make more mistakes. A block used repeatedly will
    eventually become the oldest block in the pool.
    It will be written back only to be reread shortly
    thereafter into another block

7
Buffer Replacement Strategies(3)
  • Clock
  • Efficient approximation to LRU
  • Think of the buffer blocks as arranged in a
    circle, each associated with a flag, which is
    either 0 or 1. Blocks with a 0 flag are
    vulnerable to be replaced, while with a 1 flag
    are not. When the block is accessed, its flag is
    set to 1

8
Buffer Replacement Strategies(4)
  • The buffer manager maintain a hand pointing to
    one of the blocks. When choosing a block for
    replacement, it looks for the first 0 it can
    find, rotating clockwise, and sets all 1s it
    passed to 0

9
More on Buffer Management
  • Replacement strategy can have big impact on the
    amount of disk I/O, which depends on the access
    pattern
  • When buffer blocks (LRUrepeated sequential scans) means each page
    request causes an I/O, while MRU is much better
    in this situation.
  • Adjust replacement policy and pre-fetch pages
    based on access patterns
Write a Comment
User Comments (0)
About PowerShow.com