|
|
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "rocksdb/perf_level.h"
|
|
|
|
|
|
|
|
// A thread local context for gathering io-stats efficiently and transparently.
|
|
|
|
// Use SetPerfLevel(PerfLevel::kEnableTime) to enable time stats.
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
struct IOStatsContext {
|
|
|
|
// reset all io-stats counter to zero
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
// the thread pool id
|
|
|
|
uint64_t thread_pool_id;
|
|
|
|
|
|
|
|
// number of bytes that has been written.
|
|
|
|
uint64_t bytes_written;
|
|
|
|
// number of bytes that has been read.
|
|
|
|
uint64_t bytes_read;
|
|
|
|
|
|
|
|
// time spent in open() and fopen().
|
|
|
|
uint64_t open_nanos;
|
|
|
|
// time spent in fallocate().
|
|
|
|
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;
|
Add options.compaction_measure_io_stats to print write I/O stats in compactions
Summary:
Add options.compaction_measure_io_stats to print out / pass to listener accumulated time spent on write calls. Example outputs in info logs:
2015/08/12-16:27:59.463944 7fd428bff700 (Original Log Time 2015/08/12-16:27:59.463922) EVENT_LOG_v1 {"time_micros": 1439422079463897, "job": 6, "event": "compaction_finished", "output_level": 1, "num_output_files": 4, "total_output_size": 6900525, "num_input_records": 111483, "num_output_records": 106877, "file_write_nanos": 15663206, "file_range_sync_nanos": 649588, "file_fsync_nanos": 349614797, "file_prepare_write_nanos": 1505812, "lsm_state": [2, 4, 0, 0, 0, 0, 0]}
Add two more counters in iostats_context.
Also add a parameter of db_bench.
Test Plan: Add a unit test. Also manually verify LOG outputs in db_bench
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D44115
9 years ago
|
|
|
// time spent in fsync
|
|
|
|
uint64_t fsync_nanos;
|
|
|
|
// time spent in preparing write (fallocate etc).
|
|
|
|
uint64_t prepare_write_nanos;
|
|
|
|
// time spent in Logger::Logv().
|
|
|
|
uint64_t logger_nanos;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef IOS_CROSS_COMPILE
|
|
|
|
# ifdef _WIN32
|
|
|
|
extern __declspec(thread) IOStatsContext iostats_context;
|
|
|
|
# else
|
|
|
|
extern __thread IOStatsContext iostats_context;
|
|
|
|
# endif
|
|
|
|
#endif // IOS_CROSS_COMPILE
|
|
|
|
|
|
|
|
} // namespace rocksdb
|