In an implementation of a database buffer pool (memory pool), I have a buffer which consists of pages in memory.
The pages have different sizes (all integer multiple of 512kb).
Say my eviction policy is LRU (least recently used) but the page I am trying to evict has less size than what I need to replace, If I want to follow LRU as well, I should evict as many LRU pages as necessary to fit in my new page.
Assume I need n
recently used pages to be evicted. Yet, these pages are not necessarily consecutive in the buffer/memory pool.
A simple approach I thought about is to coalesce these n
pages which means I need to reorder the buffer pool appropriately.
The simplest approach is to copy the whole buffer and overwrite the permanent buffer and update the data types appropriately. Yet this assumes that we have enough RAM to copy the whole buffer for this operation. Is there a clever approach where I don't have to copy the whole buffer?
Thanks