Support --bufferedio=[0,1] from db_bench. If bufferedio = 0, then the read code path clears the OS page cache after the IO is completed. The default remains as bufferedio=1

Summary:
Task ID: #

Blame Rev:

Test Plan: Revert Plan:

Differential Revision: https://reviews.facebook.net/D3429
This commit is contained in:
Dhruba Borthakur
2012-05-24 15:54:02 -07:00
parent 33a3c6ff6c
commit 8f293b68a9
2 changed files with 15 additions and 5 deletions

View File

@@ -25,6 +25,8 @@
#include "util/logging.h"
#include "util/posix_logger.h"
bool useOsBuffer = 1; // cache data in OS buffers
namespace leveldb {
namespace {
@@ -86,6 +88,9 @@ class PosixRandomAccessFile: public RandomAccessFile {
// An error: return a non-ok status
s = IOError(filename_, errno);
}
if (!useOsBuffer) {
posix_fadvise(fd_, offset, n, POSIX_FADV_DONTNEED); // free OS pages
}
return s;
}
};
@@ -329,7 +334,7 @@ class PosixEnv : public Env {
int fd = open(fname.c_str(), O_RDONLY);
if (fd < 0) {
s = IOError(fname, errno);
} else if (sizeof(void*) >= 8) {
} else if (useOsBuffer && sizeof(void*) >= 8) {
// Use mmap when virtual address-space is plentiful.
uint64_t size;
s = GetFileSize(fname, &size);