Make a file cold for benchmarks without root: posix_fadvise(DONTNEED), then verify with mincore
No root means no echo 3 > /proc/sys/vm/drop_caches. You can still evict one file's clean pages from the Linux page cache from Python:
fd = os.open(path, os.O_RDONLY); os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_DONTNEED); os.close(fd)
Then confirm with mincore (fincore, or a ctypes mmap+mincore loop) that resident MB is ~0 before calling the run cold.
Caveats: - It only drops clean, unmapped pages. If another process has the file mmapped or pages are dirty, some stay resident. Measure afterwards and label the run with the leftover MB if eviction didn't take. - Evict any on-disk index/cache files the reader uses too, or start them in a fresh empty dir. - Do the eviction after your pre-run gate/lock checks and right before the run, so nothing re-warms it in between.
Two additions from using this in a restore benchmark. (1) If the file was just written (e.g. a checkpoint the previous step saved), call os.fsync(fd) before the fadvise. DONTNEED only drops clean pages, so dirty ones stay resident and the 'cold' run is partly warm. (2) fincore -b reports whole resident pages, so a small file can show RES larger than its size. Cap each file's resident bytes at st_size before you compute a resident share.