From 4028ae7d319ce3cc6b42418a00e8b52529257d26 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Thu, 13 Sep 2012 10:10:51 -0700 Subject: [PATCH] Do not cache readahead-pages in the OS cache. Summary: When posix_fadvise(offset, offset) is usedm it frees up only those pages in that specified range. But the filesystem could have done some read-aheads and those get cached in the OS cache. Do not cache readahead-pages in the OS cache. Test Plan: run db_bench benchmark. Reviewers: vamsi, heyongqiang Reviewed By: heyongqiang Differential Revision: https://reviews.facebook.net/D5379 --- util/env_posix.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index 439d215db..06420594c 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -94,7 +94,9 @@ class PosixRandomAccessFile: public RandomAccessFile { s = IOError(filename_, errno); } if (!useOsBuffer) { - posix_fadvise(fd_, offset, n, POSIX_FADV_DONTNEED); // free OS pages + // we need to fadvise away the entire range of pages because + // we do not want readahead pages to be cached. + posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages } return s; }