Add read_nanos to IOStatsContext.

Summary: MyRocks need a mechanism to track read outliers. We need to expose this
stat.

Test Plan: None

Reviewers: sdong

CC: leveldb

Task ID: #7152512

Blame Rev:
main
krad 9 years ago
parent 7160f5d80c
commit 7015fd81c4
  1. 2
      include/rocksdb/iostats_context.h
  2. 12
      util/env_posix.cc
  3. 2
      util/iostats_context.cc

@ -34,6 +34,8 @@ struct IOStatsContext {
uint64_t allocate_nanos;
// time spent in write() and pwrite().
uint64_t write_nanos;
// time spent in read() and pread()
uint64_t read_nanos;
// time spent in sync_file_range().
uint64_t range_sync_nanos;

@ -256,7 +256,11 @@ class PosixRandomAccessFile: public RandomAccessFile {
size_t left = n;
char* ptr = scratch;
while (left > 0) {
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
{
IOSTATS_TIMER_GUARD(read_nanos);
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
}
if (r <= 0) {
if (errno == EINTR) {
continue;
@ -975,7 +979,11 @@ class PosixRandomRWFile : public RandomRWFile {
size_t left = n;
char* ptr = scratch;
while (left > 0) {
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
{
IOSTATS_TIMER_GUARD(read_nanos);
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
}
if (r <= 0) {
if (errno == EINTR) {
continue;

@ -20,6 +20,7 @@ void IOStatsContext::Reset() {
open_nanos = 0;
allocate_nanos = 0;
write_nanos = 0;
read_nanos = 0;
range_sync_nanos = 0;
logger_nanos = 0;
}
@ -34,6 +35,7 @@ std::string IOStatsContext::ToString() const {
<< OUTPUT(open_nanos)
<< OUTPUT(allocate_nanos)
<< OUTPUT(write_nanos)
<< OUTPUT(read_nanos)
<< OUTPUT(range_sync_nanos)
<< OUTPUT(logger_nanos);

Loading…
Cancel
Save