Jan 19/22 buffer management

2018-01-20  本文已影响0人  aureole420

Memory management in DBs.

Typically on startup.
What are these pages used for?
Question: should buffer cache and scratch pool be seperate?

In homework, we are going to put them together. Our System has no separation to get RAM, can call:

Key thing: DB working set often large than all available ram.

The question: how to handle this?

  • page data in and out. (write out some data to disk to free some space)
  • should be transparent to user! (the low level system should be automatically deal with this.)

So, what do we do when we "page data"?

  1. We choose an existing (used) page to evict (move out of the dbms).
  2. If the page is dirty (data havs been changed, but not written back to disk). write its contents to disk.
  3. (fill contents of page (if necessary) first) -- Give a handle to the page back to requester

What are common eviction policies?

You have to index the pages in RAM via (several ways):

  1. TS- timestampe (you don't want to scan all pages) --- really bad considering updating (inserting/deleting) the data structure (priority queue for example)
  2. By file, pagenum
  3. via a "super fast" pointer or handle. --- if some one called getHandle, they want ram which they can get easy access to.
Clock algorithm

Jan 22 Monday

LRU:
good: temporal locality, its "optimal"
bad:

clock
good: approximate LRU, less cost
bad: eviction may require full sweep of arm (but is it bad? you are not going to pay this cost unless you make eviction)

homework related:

smart-pointer: nowadays good coding styles, use smart pointers instead of raw pointer. For homework, will need the raw pointers e.g for page.;

上一篇下一篇

猜你喜欢

热点阅读