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
This commit is contained in:
Dhruba Borthakur 2012-09-13 10:10:51 -07:00
parent 7ecc5d4ad5
commit 4028ae7d31

View File

@ -94,7 +94,9 @@ class PosixRandomAccessFile: public RandomAccessFile {
s = IOError(filename_, errno); s = IOError(filename_, errno);
} }
if (!useOsBuffer) { 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; return s;
} }