Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cachelib/cachebench/cache/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ DEFINE_bool(report_api_latency,
false,
"Enable reporting cache API latency tracking");

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

namespace facebook {
namespace cachelib {
Expand Down
2 changes: 1 addition & 1 deletion cachelib/cachebench/cache/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "cachelib/cachebench/util/CacheConfig.h"

DECLARE_bool(report_api_latency);
DECLARE_bool(report_memory_usage_stats);
DECLARE_string(report_memory_usage_stats);

namespace facebook {
namespace cachelib {
Expand Down
10 changes: 7 additions & 3 deletions cachelib/cachebench/cache/CacheStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "cachelib/common/PercentileStats.h"

DECLARE_bool(report_api_latency);
DECLARE_bool(report_memory_usage_stats);
DECLARE_string(report_memory_usage_stats);

namespace facebook {
namespace cachelib {
Expand Down Expand Up @@ -120,12 +120,16 @@ struct Stats {
<< std::endl;
out << folly::sformat("RAM Evictions : {:,}", numEvictions) << std::endl;

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

auto formatMemory = [](size_t bytes) -> std::tuple<std::string, double> {
auto formatMemory = [&](size_t bytes) -> std::tuple<std::string, double> {
if (FLAGS_report_memory_usage_stats == "raw") {
return {"B", bytes};
}

constexpr double KB = 1024.0;
constexpr double MB = 1024.0 * 1024;
constexpr double GB = 1024.0 * 1024 * 1024;
Expand Down