mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
readahead: clean up the code, update docs
Remove dubious comments and #if 0 section. Document new event counters, and add one for read failures. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
48b7fbda9c
commit
30cd375d03
@ -281,11 +281,14 @@ The `progress` event group consists of events related to progress estimation.
|
|||||||
readahead
|
readahead
|
||||||
---------
|
---------
|
||||||
|
|
||||||
The `readahead` event group consists of events related to calls to `posix_fadvise`.
|
The `readahead` event group consists of events related to data prefetching (formerly calls to `posix_fadvise` or `readahead`, but now emulated in userspace).
|
||||||
|
|
||||||
|
* `readahead_bytes`: Number of bytes prefetched.
|
||||||
|
* `readahead_count`: Number of read calls.
|
||||||
* `readahead_clear`: Number of times the duplicate read cache was cleared.
|
* `readahead_clear`: Number of times the duplicate read cache was cleared.
|
||||||
* `readahead_skip`: Number of times a duplicate read was identified in the cache and skipped.
|
* `readahead_fail`: Number of read errors during prefetch.
|
||||||
* `readahead_ms`: Total time spent emulating readahead in user-space (kernel readahead is not measured).
|
* `readahead_ms`: Total time spent emulating readahead in user-space (kernel readahead is not measured).
|
||||||
|
* `readahead_skip`: Number of times a duplicate read was identified in the cache and skipped.
|
||||||
* `readahead_unread_ms`: Total time spent running `posix_fadvise(..., POSIX_FADV_DONTNEED)`.
|
* `readahead_unread_ms`: Total time spent running `posix_fadvise(..., POSIX_FADV_DONTNEED)`.
|
||||||
|
|
||||||
replacedst
|
replacedst
|
||||||
|
15
src/bees.cc
15
src/bees.cc
@ -246,10 +246,6 @@ bees_readahead_nolock(int const fd, const off_t offset, const size_t size)
|
|||||||
Timer readahead_timer;
|
Timer readahead_timer;
|
||||||
BEESNOTE("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
BEESNOTE("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||||
BEESTOOLONG("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
BEESTOOLONG("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||||
#if 0
|
|
||||||
// In the kernel, readahead() is identical to posix_fadvise(..., POSIX_FADV_DONTNEED)
|
|
||||||
DIE_IF_NON_ZERO(readahead(fd, offset, size));
|
|
||||||
#else
|
|
||||||
// Make sure this data is in page cache by brute force
|
// Make sure this data is in page cache by brute force
|
||||||
// The btrfs kernel code does readahead with lower ioprio
|
// The btrfs kernel code does readahead with lower ioprio
|
||||||
// and might discard the readahead request entirely.
|
// and might discard the readahead request entirely.
|
||||||
@ -263,13 +259,16 @@ bees_readahead_nolock(int const fd, const off_t offset, const size_t size)
|
|||||||
// Ignore errors and short reads. It turns out our size
|
// Ignore errors and short reads. It turns out our size
|
||||||
// parameter isn't all that accurate, so we can't use
|
// parameter isn't all that accurate, so we can't use
|
||||||
// the pread_or_die template.
|
// the pread_or_die template.
|
||||||
(void)!pread(fd, dummy, this_read_size, working_offset);
|
const auto pr_rv = pread(fd, dummy, this_read_size, working_offset);
|
||||||
BEESCOUNT(readahead_count);
|
if (pr_rv >= 0) {
|
||||||
BEESCOUNTADD(readahead_bytes, this_read_size);
|
BEESCOUNT(readahead_count);
|
||||||
|
BEESCOUNTADD(readahead_bytes, pr_rv);
|
||||||
|
} else {
|
||||||
|
BEESCOUNT(readahead_fail);
|
||||||
|
}
|
||||||
working_offset += this_read_size;
|
working_offset += this_read_size;
|
||||||
working_size -= this_read_size;
|
working_size -= this_read_size;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
BEESCOUNTADD(readahead_ms, readahead_timer.age() * 1000);
|
BEESCOUNTADD(readahead_ms, readahead_timer.age() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user