How to flush caches (OS page cache and Postgres buffer pool)
For experiments, it is important to take into account the state of caches – Postgres buffer pool (size of which is
controlled by shared_buffers
) and OS page cache. If we decide to start each experiment run with cold caches, we need
to flush them.
Flushing Postgres buffer pool
To flush Postgres buffer pool, restart Postgres.
To analyze the current state of the buffer pool, use pg_buffercache.
Flushing OS page cache
To flush Linux page cache:
sync
echo 3 > /proc/sys/vm/drop_caches
To see the current state of RAM consumption (in MiB) in Linux:
free -m
On macOS, to flush the page cache:
sync
sudo purge
To see the current state of RAM on macOS:
vm_stat