mirror of https://github.com/facebook/rocksdb.git
Make RecordIn/RecordOut human readable
Summary: I had hard time understanding these big numbers. Here's how the output looks like now: https://gist.github.com/igorcanadi/4c39c17685049584a992 Test Plan: db_bench Reviewers: sdong, MarkCallaghan Reviewed By: MarkCallaghan Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D35073
This commit is contained in:
parent
c8da670325
commit
c6967a1a5e
|
@ -33,9 +33,9 @@ void PrintLevelStatsHeader(char* buf, size_t len, const std::string& cf_name) {
|
|||
"Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) "
|
||||
"Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) "
|
||||
"Comp(sec) Comp(cnt) Avg(sec) "
|
||||
"Stall(cnt) RecordIn RecordDrop\n"
|
||||
"--------------------------------------------------------------------"
|
||||
"Stall(cnt) KeyIn KeyDrop\n"
|
||||
"--------------------------------------------------------------------"
|
||||
"-----------------------------------------------------------"
|
||||
"--------------------------------------\n",
|
||||
cf_name.c_str());
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
|
|||
uint64_t bytes_read = stats.bytes_readn + stats.bytes_readnp1;
|
||||
int64_t bytes_new = stats.bytes_written - stats.bytes_readnp1;
|
||||
double elapsed = (stats.micros + 1) / 1000000.0;
|
||||
std::string num_input_records = NumberToHumanString(stats.num_input_records);
|
||||
std::string num_dropped_records =
|
||||
NumberToHumanString(stats.num_dropped_records);
|
||||
|
||||
snprintf(buf, len,
|
||||
"%4s %5d/%-3d %8.0f %5.1f " /* Level, Files, Size(MB), Score */
|
||||
|
@ -59,27 +62,24 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
|
|||
"%5.1f " /* W-Amp */
|
||||
"%8.1f " /* Rd(MB/s) */
|
||||
"%8.1f " /* Wr(MB/s) */
|
||||
"%9.0f " /* Comp(sec) */
|
||||
"%9.0f " /* Comp(sec) */
|
||||
"%9d " /* Comp(cnt) */
|
||||
"%8.3f " /* Avg(sec) */
|
||||
"%10" PRIu64
|
||||
" " /* Stall(cnt) */
|
||||
"%12" PRIu64
|
||||
" " /* input entries */
|
||||
"%12" PRIu64 "\n" /* number of records reduced */,
|
||||
"%7s " /* KeyIn */
|
||||
"%6s\n", /* KeyDrop */
|
||||
name.c_str(), num_files, being_compacted, total_file_size / kMB,
|
||||
score, bytes_read / kGB, stats.bytes_readn / kGB,
|
||||
stats.bytes_readnp1 / kGB, stats.bytes_written / kGB,
|
||||
bytes_new / kGB, stats.bytes_moved / kGB,
|
||||
w_amp, bytes_read / kMB / elapsed,
|
||||
stats.bytes_written / kMB / elapsed,
|
||||
stats.micros / 1000000.0, stats.count,
|
||||
stats.bytes_written / kMB / elapsed, stats.micros / 1000000.0,
|
||||
stats.count,
|
||||
stats.count == 0 ? 0 : stats.micros / 1000000.0 / stats.count,
|
||||
stalls,
|
||||
stats.num_input_records, stats.num_dropped_records);
|
||||
num_input_records.c_str(), num_dropped_records.c_str());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DBPropertyType GetPropertyType(const Slice& property, bool* is_int_property,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -95,6 +96,21 @@ std::string NumberToString(uint64_t num) {
|
|||
return r;
|
||||
}
|
||||
|
||||
std::string NumberToHumanString(int64_t num) {
|
||||
char buf[16];
|
||||
int64_t absnum = num < 0 ? -num : num;
|
||||
if (absnum < 10000) {
|
||||
snprintf(buf, sizeof(buf), "%" PRIi64, num);
|
||||
} else if (absnum < 10000000) {
|
||||
snprintf(buf, sizeof(buf), "%" PRIi64 "K", num / 1000);
|
||||
} else if (absnum < 10000000000LL) {
|
||||
snprintf(buf, sizeof(buf), "%" PRIi64 "M", num / 1000000);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%" PRIi64 "G", num / 1000000000);
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
std::string EscapeString(const Slice& value) {
|
||||
std::string r;
|
||||
AppendEscapedStringTo(&r, value);
|
||||
|
|
|
@ -33,9 +33,15 @@ extern void AppendNumberTo(std::string* str, uint64_t num);
|
|||
// Escapes any non-printable characters found in "value".
|
||||
extern void AppendEscapedStringTo(std::string* str, const Slice& value);
|
||||
|
||||
// Return a human-readable printout of "num"
|
||||
// Return a string printout of "num"
|
||||
extern std::string NumberToString(uint64_t num);
|
||||
|
||||
// Return a human-readable version of num.
|
||||
// for num >= 10.000, prints "xxK"
|
||||
// for num >= 10.000.000, prints "xxM"
|
||||
// for num >= 10.000.000.000, prints "xxG"
|
||||
extern std::string NumberToHumanString(int64_t num);
|
||||
|
||||
// Return a human-readable version of "value".
|
||||
// Escapes any non-printable characters found in "value".
|
||||
extern std::string EscapeString(const Slice& value);
|
||||
|
|
Loading…
Reference in New Issue