4. Buffer Management Flashcards

1
Q

Buffer manager main responsibility

A

The buffer manager is responsible for managing pages in memory and processing page requests from the file and index manager.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When the buffer manager should communicate with the disk space manager?

A

When pages are evicted from memory or new pages are read into memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are frames? How they are tracked?

A

Memory is converted into a buffer pool by partitioning the space into frames that pages can be placed in. A buffer frame can hold the same amount of data as a page can (so a page fits perfectly into a frame).

To efficiently track frames, the buffer manager allocates additional space in memory for a metadata table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Buffer manager metadata table - describe

A
  1. Frame ID that is uniquely associated with a memory address
  2. Page ID for determining which page a frame currently contains
  3. Dirty Bit for verifying whether or not a page has been modified
  4. Pin Count for tracking the number of requestors currently using a page
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe how page requests are handled by the buffer manager

A

When pages are requested from the buffer manager and the page already exists within memory, the page’s pin count is incremented and the page’s memory address is returned.

If the page does not exist in the buffer pool and there is still space, the next empty frame is found and the page is read into that frame. The page’s pin count is set to 1 and the page’s memory address is returned. In the case where the page does not exist and there are no empty frames left, a replacement policy must be used to determine which page to evict.

Additionally, if the evicted page has the dirty bit set, the page is written to disk to ensure that updates are persisted. The dirty bit is set to 1 if and when a page is written to with updates in memory. The dirty bit is set to 0 once the page is written back to disk.

Once the requestor completes its workload, it is responsible for telling the buffer manager to decrement the pin count associated with pages that it previously used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Page hit, Page miss, hit rate - def

A

A page hit is when a requested page can be found in memory without having to go to disk. Each page miss incurs an additional IO cost.

The hit rate for an access pattern is defined as # of page hits / (# of page hits + # of page misses) or more simply, # of page hits / # of page accesses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

LRU replacement policy - describe,

main drawback

A

When new pages need to be read into a full buffer pool, the least recently used unpinned page (pin count = 0) is evicted. To track page usage, a last used column is added to the metadata table and measures the latest time at which a page’s pin count is decremented.

Implementing LRU normally can be costly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Clock replacement policy - describe

A

Every page access - set ref to 1.

Eviction:

  • Iterate through frames within the table, skipping pinned pages and wrapping around to frame 0 upon reaching the end, until the first unpinned frame with ref bit = 0 is found.
  • During each iteration, if the current frame’s ref bit = 1, set the ref bit to 0 and move the clock hand to the next frame (this gives the second chance to frequently used pages).
  • Upon reaching a frame with ref bit = 0, evict the existing page (and write it to disk if the dirty bit is set; then set the dirty bit to 0), read in the new page, set the frame’s ref bit to 1, and move the clock hand to the next frame.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When LRU behaves in a bad way?

A

Pages S, where |S| > buffer pool size, are accessed multiple times repeatedly.

Consider a 3 frame buffer pool using LRU and having the access pattern:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

MRU replacement - describe

A

MRU (Most Recently Used). Instead of evicting the least recently used unpinned page, evict the most recently used unpinned page measured by when the page’s pin count was last decremented.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly