Download
buffer management n.
Skip this Video
Loading SlideShow in 5 Seconds..
Buffer Management PowerPoint Presentation
Download Presentation
Buffer Management

Buffer Management

241 Vues Download Presentation
Télécharger la présentation

Buffer Management

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Buffer Management Storage Technology: Topic 2

  2. Effective Use of Main Memory • Memory is used as a cache for data on disk • Issue: Granularity? • Issue: Updates? • Issue: Replacement? • Issue: Efficient lookup? • Issue: Concurrency?

  3. Buffer Management in a DBMS Page Requests from Higher Levels • Data must be in RAM for DBMS to operate on it! • Table of <frame#, pageid> pairs is maintained. BUFFER POOL disk page free frame MAIN MEMORY DISK choice of frame dictated by replacement policy DB

  4. When a Page is Requested ... • If the page is in the BP, go to 4 • Why would this happen? can it be encouraged? • Choose a frame to read into. • How does one do this? • Read page into chosen frame. • Pin the page and return to caller. • To avoid thrashing • The caller eventually unpins the page • Has the page been modified?

  5. Picking a Frame • If there is a free frame, use it • Use the page replacement policy to find a victim frame. • If victim frame is dirty, write it to disk (look at the next slide -- Update policy)

  6. Buffer Manager Details • Granularity : disk page size (4K, 8K) • Updates : “write-back” not “write-through” • Efficient lookup : hash table mapping pages to frames (hash function applied to what?) • Concurrency : what if several pages are requested at the same time? • What if the same page is requested multiply?

  7. Buffer Replacement Policy • Optimal policy needs to know future accesses. • At each stage, the victim should be the page used furthest into the future. • Practical repl. policies use a crystal ball. • Driven by knowledge of application behavior. • Least-recently-used (LRU), Clock, MRU, etc. • Pre-fetch, delayed-write, and other smarts.

  8. DBMS vs. OS File System OS does disk space & buffer mgmt: why not let OS manage these tasks? • Differences in OS support: portability issues • Some limitations, e.g., files can’t span disks. • Buffer management in DBMS requires: • pinning a page in buffer pool, forcing a page to disk (important for implementing CC & recovery) • adjust replacement policy and pre-fetch pages based on access patterns in typical DB operations

  9. Summary • Buffer manager brings pages into RAM. • Page stays in RAM until released by requestor. • Written to disk when frame chosen for replacement (which is sometime after requestor releases the page). • Choice of frame to replace based on replacement policy. • Tries to pre-fetch several pages at a time. • DBMS vs. OS File Support • DBMS needs features not found in many OS’s,