Skip to content

Commit cab87d4

Browse files
authored
Merge pull request #93 from igchor/stats_no_gb
Add option to print memory stats in bytes only
2 parents 57a3d1c + 34f9f8e commit cab87d4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

cachelib/cachebench/cache/Cache.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ DEFINE_bool(report_api_latency,
2222
false,
2323
"Enable reporting cache API latency tracking");
2424

25-
DEFINE_bool(report_memory_usage_stats,
26-
false,
27-
"Enable reporting statistics for each allocation class");
25+
DEFINE_string(report_memory_usage_stats,
26+
"",
27+
"Enable reporting statistics for each allocation class. Set to"
28+
"'human_readable' to print KB/MB/GB or to 'raw' to print in bytes.");
2829

2930
namespace facebook {
3031
namespace cachelib {

cachelib/cachebench/cache/Cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "cachelib/cachebench/util/CacheConfig.h"
3434

3535
DECLARE_bool(report_api_latency);
36-
DECLARE_bool(report_memory_usage_stats);
36+
DECLARE_string(report_memory_usage_stats);
3737

3838
namespace facebook {
3939
namespace cachelib {

cachelib/cachebench/cache/CacheStats.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "cachelib/common/PercentileStats.h"
2222

2323
DECLARE_bool(report_api_latency);
24-
DECLARE_bool(report_memory_usage_stats);
24+
DECLARE_string(report_memory_usage_stats);
2525

2626
namespace facebook {
2727
namespace cachelib {
@@ -120,12 +120,16 @@ struct Stats {
120120
<< std::endl;
121121
out << folly::sformat("RAM Evictions : {:,}", numEvictions) << std::endl;
122122

123-
if (FLAGS_report_memory_usage_stats) {
123+
if (FLAGS_report_memory_usage_stats != "") {
124124
for (TierId tid = 0; tid < slabsApproxFreePercentages.size(); tid++) {
125125
out << folly::sformat("tid{:2} free slabs : {:.2f}%", tid, slabsApproxFreePercentages[tid]) << std::endl;
126126
}
127127

128-
auto formatMemory = [](size_t bytes) -> std::tuple<std::string, double> {
128+
auto formatMemory = [&](size_t bytes) -> std::tuple<std::string, double> {
129+
if (FLAGS_report_memory_usage_stats == "raw") {
130+
return {"B", bytes};
131+
}
132+
129133
constexpr double KB = 1024.0;
130134
constexpr double MB = 1024.0 * 1024;
131135
constexpr double GB = 1024.0 * 1024 * 1024;

0 commit comments

Comments
 (0)