Master the fundamental concepts of b-trees through this focused micro-challenge.
Every B-tree lookup touches one page per level. A page cache (buffer pool) keeps recently used pages in memory keyed by page id. PostgreSQL shared buffers and InnoDB buffer pool are industrial-scale versions of the LRU cache you will write.
On read, return cached page or load from disk, insert at MRU side. On eviction, drop LRU entry when capacity exceeded.
cLoading…
Keep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will implement an LRU page cache over fixed B-tree pages and report hits versus misses on a workload. This exercise asks you to show improved lookup time when the working set fits cache.
Write a C program that implements an LRU page cache for B-tree nodes.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github