Recursively evicts cached data for specified files or directories. It is designed for cold-cache benchmarks and does not require root privileges on Linux, macOS, or BSD.
0
stars
2
commits
Go
primary language
Aug 22, 2026
updated
drop_file_cache recursively evicts cached data for specified files or
directories. It is designed for cold-cache benchmarks and does not require root
privileges on Linux, macOS, or BSD.
It is a path-scoped alternative to the following Linux command:
sync
echo 3 > /proc/sys/vm/drop_caches
It is not identical: drop_caches clears caches system-wide, while this tool
only handles regular files under the supplied paths. Directory metadata,
filesystem metadata, and device caches are unaffected.
-v reports cache residency before and after.Download the binaries on the release page.
For Go developers:
go install github.com/shenwei356/drop_file_cache@latest
drop_file_cache v0.1.1
Recursively evict regular-file page-cache data for the supplied paths.
Symbolic links to files and directories are followed.
Directory cycles are detected and skipped.
Usage: drop_file_cache [options] PATH [PATH ...]
Options:
-allow-global
allow a system-wide cache flush when per-file eviction is unavailable (Windows)
-sync
flush dirty file data before asking the OS to evict it (default true)
-v show per-file cache residency as SIZE/PAGES before and after eviction
-version
print version and exit
Home: https://github.com/shenwei356/drop_file_cache
Drop cached data for two files:
drop_file_cache -v \
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna \
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna.gz
-------------------------------------------------------------------------------
FILE SIZE BEFORE AFTER
-------------------------------------------------------------------------------
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna 1.1 GB 1.1 GB/270K 0 B/0
GCA_009914755.4_T2T...v2.0_genomic.fna.gz 932.7 MB 932.7 MB/228K 0 B/0
-------------------------------------------------------------------------------
TOTAL (2 files) 2.0 GB 2.0 GB/498K 0 B/0
-------------------------------------------------------------------------------
Byte sizes use decimal units (B, KB, MB, GB, TB, and so on).
Residency is shown as size/pages; large page counts are rounded and abbreviated
with decimal suffixes such as K, M, or G.
Recursively process a directory:
drop_file_cache /path/to/dataset
Prepare each run of a benchmark:
hyperfine --prepare 'drop_file_cache /path/to/dataset' \
'./program /path/to/dataset'
| Platform | Method and limitations |
|---|---|
| Linux | fsync + posix_fadvise(POSIX_FADV_DONTNEED). This is the primary supported mode. |
| macOS | fsync + msync(MS_INVALIDATE) + F_NOCACHE; best-effort. |
| FreeBSD, NetBSD, OpenBSD, DragonFly BSD | fsync + msync(MS_INVALIDATE); best-effort. |
| Windows | System-wide fallback only. Requires -allow-global and usually an elevated shell. |
Linux 6.5 and later use cachestat(2) for -v; older Linux kernels and BSD
use mincore(2). OpenBSD residency reporting is available on amd64 and arm64.
Windows does not provide per-file residency counts.
2 commits
Go
95.8%
Shell
3.4%
Recursively evicts cached data for specified files or directories. It is designed for cold-cache benchmarks and does not require root privileges on Linux, macOS, or BSD.
0
stars
2
commits
Go
primary language
Aug 22, 2026
updated
drop_file_cache recursively evicts cached data for specified files or
directories. It is designed for cold-cache benchmarks and does not require root
privileges on Linux, macOS, or BSD.
It is a path-scoped alternative to the following Linux command:
sync
echo 3 > /proc/sys/vm/drop_caches
It is not identical: drop_caches clears caches system-wide, while this tool
only handles regular files under the supplied paths. Directory metadata,
filesystem metadata, and device caches are unaffected.
-v reports cache residency before and after.Download the binaries on the release page.
For Go developers:
go install github.com/shenwei356/drop_file_cache@latest
drop_file_cache v0.1.1
Recursively evict regular-file page-cache data for the supplied paths.
Symbolic links to files and directories are followed.
Directory cycles are detected and skipped.
Usage: drop_file_cache [options] PATH [PATH ...]
Options:
-allow-global
allow a system-wide cache flush when per-file eviction is unavailable (Windows)
-sync
flush dirty file data before asking the OS to evict it (default true)
-v show per-file cache residency as SIZE/PAGES before and after eviction
-version
print version and exit
Home: https://github.com/shenwei356/drop_file_cache
Drop cached data for two files:
drop_file_cache -v \
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna \
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna.gz
-------------------------------------------------------------------------------
FILE SIZE BEFORE AFTER
-------------------------------------------------------------------------------
GCA_009914755.4_T2T-CHM13v2.0_genomic.fna 1.1 GB 1.1 GB/270K 0 B/0
GCA_009914755.4_T2T...v2.0_genomic.fna.gz 932.7 MB 932.7 MB/228K 0 B/0
-------------------------------------------------------------------------------
TOTAL (2 files) 2.0 GB 2.0 GB/498K 0 B/0
-------------------------------------------------------------------------------
Byte sizes use decimal units (B, KB, MB, GB, TB, and so on).
Residency is shown as size/pages; large page counts are rounded and abbreviated
with decimal suffixes such as K, M, or G.
Recursively process a directory:
drop_file_cache /path/to/dataset
Prepare each run of a benchmark:
hyperfine --prepare 'drop_file_cache /path/to/dataset' \
'./program /path/to/dataset'
| Platform | Method and limitations |
|---|---|
| Linux | fsync + posix_fadvise(POSIX_FADV_DONTNEED). This is the primary supported mode. |
| macOS | fsync + msync(MS_INVALIDATE) + F_NOCACHE; best-effort. |
| FreeBSD, NetBSD, OpenBSD, DragonFly BSD | fsync + msync(MS_INVALIDATE); best-effort. |
| Windows | System-wide fallback only. Requires -allow-global and usually an elevated shell. |
Linux 6.5 and later use cachestat(2) for -v; older Linux kernels and BSD
use mincore(2). OpenBSD residency reporting is available on amd64 and arm64.
Windows does not provide per-file residency counts.
2 commits
Go
95.8%
Shell
3.4%