This project enhances PostgreSQL 16.4 by introducing a FIFO (First-In-First-Out) buffer replacement strategy alongside the existing LRU Clock-Sweep algorithm.
The FIFO strategy manages buffers in strict queue order, replacing the oldest buffer first when needed.
This work was developed as part of CSCI-550 (Advanced Database Systems) at USC.
src/backend/storage/buffer/freelist.c
- Implemented a FIFO queue (FifoQueue) to track buffers in insertion order.
- Added functions to enqueue (enqueueBuffer) and dequeue (dequeueBuffer) buffers from the queue.
- Modified buffer selection logic (
GetNewBufferandGetVictimBuffer) to integrate FIFO. - Introduced a toggle flag (
enable_fifo) inBufferStrategyControlto switch between FIFO and LRU Clock-Sweep. - Updated
StrategyGetBufferto dynamically select the appropriate replacement strategy.
- Set the
enable_fifoflag:enable_fifo = true→ Buffers are allocated/replaced using FIFO.enable_fifo = false→ PostgreSQL’s default LRU Clock-Sweep strategy is used.
- With FIFO enabled, buffer replacement follows strict insertion order.
- With LRU Clock-Sweep, PostgreSQL’s adaptive buffer strategy is preserved.
This project builds on the official PostgreSQL 16.4 source code.
The modifications here are for educational purposes only and represent enhancements implemented by our group.