mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 13:25:45 +02:00
bees: readahead() in the kernel is posix_fadvise(..., POSIX_FADV_WILLNEED)
In theory, we don't need the pread() loop, because the kernel will do a better job with readahead(). In practice, we might still need the pread() code, as the readahead will occur at idle IO priority, which could adversely affect bees performance. More testing is required. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
a9cd19a5fe
commit
97d70ef4c5
10
src/bees.cc
10
src/bees.cc
@ -231,11 +231,12 @@ bees_readahead(int const fd, off_t offset, size_t size)
|
||||
Timer readahead_timer;
|
||||
BEESNOTE("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||
BEESTOOLONG("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||
// This might not do anything?
|
||||
// In the kernel, readahead() is identical to posix_fadvise(..., POSIX_FADV_DONTNEED)
|
||||
DIE_IF_NON_ZERO(readahead(fd, offset, size));
|
||||
// Make sure this data is in page cache
|
||||
// Note spelling: readahead vs read ahead
|
||||
BEESNOTE("read ahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||
#if 0
|
||||
// Make sure this data is in page cache by brute force
|
||||
// This isn't necessary and it might even be slower
|
||||
BEESNOTE("emulating readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||
while (size) {
|
||||
static uint8_t dummy[BEES_READAHEAD_SIZE];
|
||||
size_t this_read_size = min(size, sizeof(dummy));
|
||||
@ -247,6 +248,7 @@ bees_readahead(int const fd, off_t offset, size_t size)
|
||||
offset += this_read_size;
|
||||
size -= this_read_size;
|
||||
}
|
||||
#endif
|
||||
BEESCOUNTADD(readahead_ms, readahead_timer.age() * 1000);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user