Skip to content

Commit

Permalink
XrdApps::JCache: polish printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Joachim Peters committed Jun 11, 2024
1 parent f69de35 commit 0d9ba69
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/XrdApps/XrdClJCachePlugin/file/Art.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace JCache {
}
normalizedDataPoints.push_back(normalizedValue);
}

// Draw the curve
for (size_t i = 0; i < normalizedDataPoints.size(); ++i) {
int y = plotHeight - 1 - normalizedDataPoints[i];
Expand All @@ -72,16 +72,16 @@ namespace JCache {
for (int i = 0; i < plotHeight; ++i) {
double yValue = minValue + (maxValue - minValue) * (plotHeight - 1 - i) / (plotHeight - 1);
if (i==0) {
std::cerr << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " MB/s | ";
std::cerr << "# " << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " MB/s | ";
} else {
std::cerr << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " | ";
std::cerr << "# " << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " | ";
}
std::cerr << plot[i] << std::endl;
}

// Print the X axis
std::cerr << std::string(yLegendWidth + 7, ' ') << std::string(plotWidth, '-') << std::endl;
std::cerr << std::string(yLegendWidth + 7, ' ');
std::cerr << "# " << std::string(yLegendWidth + 7, ' ') << std::string(plotWidth, '-') << std::endl;
std::cerr << "# " << std::string(yLegendWidth + 7, ' ');
for (size_t i = 0 ; i < dataPoints.size()/4; ++i) {
std::cerr << std::fixed << std::setw(4) << std::left << (i*10);
}
Expand Down
32 changes: 22 additions & 10 deletions src/XrdApps/XrdClJCachePlugin/file/CacheStats.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ namespace JCache
std::vector<uint64_t> bins = XrdCl::JCacheFile::sStats.bench.GetBins(40);
JCache::Art art;
if (XrdCl::JCacheFile::sEnableSummary) {
art.drawCurve(bins, XrdCl::JCacheFile::sStats.bench.GetTimePerBin().count() / 1000000.0, realTime);
std::cerr << "# IO Timeprofile " << std::endl;
art.drawCurve(bins, XrdCl::JCacheFile::sStats.bench.GetTimePerBin().count() / 1000000.0, realTime);
std::cerr << "# ----------------------------------------------------------------------- #" << std::endl;
}
}
}
Expand All @@ -105,7 +107,14 @@ namespace JCache
oss << std::fixed << std::setprecision(2) << val << " " << suffixes[exp];
return oss.str();
}

uint64_t ReadOpBytes() {
return this->bytesCached.load()+this->bytesRead.load();
}

uint64_t ReadVOpBytes() {
return this->bytesCachedV.load()+this->bytesReadV.load();
}
double HitRate() {
auto n = this->bytesCached.load()+this->bytesRead.load();
if (!n) return 100.0;
Expand Down Expand Up @@ -225,31 +234,34 @@ namespace JCache

static std::string GlobalStats(CacheStats& sStats) {
std::ostringstream oss;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : 2024 CERN.EOS - Andreas-Joachim Peters #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;

oss << "# JCache : cache combined hit rate : " << std::fixed << std::setprecision(2) << sStats.CombinedHitRate() << " %" << std::endl;
oss << "# JCache : cache read hit rate : " << std::fixed << std::setprecision(2) << sStats.HitRate() << " %" << std::endl;
oss << "# JCache : cache readv hit rate : " << std::fixed << std::setprecision(2) << sStats.HitRateV() << " %" << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# JCache : cache read hit rate : " << std::fixed << std::setprecision(2) << (!sStats.ReadOpBytes()?"\033[9m":"") << sStats.HitRate() << " %" << (!sStats.ReadOpBytes()?"\033[0m":"") << std::endl;
oss << "# JCache : cache readv hit rate : " << std::fixed << std::setprecision(2) << (!sStats.ReadVOpBytes()?"\033[9m":"") <<sStats.HitRateV() << " %" << (!sStats.ReadOpBytes()?"\033[0m":"") << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : total bytes read : " << sStats.bytesRead.load()+sStats.bytesCached.load() << std::endl;
oss << "# JCache : total bytes readv : " << sStats.bytesReadV.load()+sStats.bytesCachedV.load() << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : total iops read : " << sStats.readOps.load() << std::endl;
oss << "# JCache : total iops readv : " << sStats.readVOps.load() << std::endl;
oss << "# JCache : total iops readvread : " << sStats.readVreadOps.load() << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : open files read : " << sStats.nreadfiles.load() << std::endl;
oss << "# JCache : open unique f. read : " << sStats.UniqueUrls() << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : total unique files bytes : " << sStats.totaldatasize << std::endl;
oss << "# JCache : total unique files size : " << sStats.bytesToHumanReadable((double)sStats.totaldatasize) << std::endl;
oss << "# JCache : percentage dataset read : " << std::fixed << std::setprecision(2) << sStats.Used() << " %" << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;
oss << "# JCache : app user time : " << std::fixed << std::setprecision(2) << sStats.userTime << " s" << std::endl;
oss << "# JCache : app real time : " << std::fixed << std::setprecision(2) << sStats.realTime << " s" << std::endl;
oss << "# JCache : app sys time : " << std::fixed << std::setprecision(2) << sStats.sysTime << " s" << std::endl;
oss << "# JCache : app acceleration : " << std::fixed << std::setprecision(2) << sStats.userTime / sStats.realTime << "x" << std::endl;
oss << "# JCache : app readrate : " << std::fixed << std::setprecision(2) << sStats.bytesToHumanReadable((sStats.ReadBytes()/sStats.realTime)) << "/s" << " [ peak (1s) " << sStats.bytesToHumanReadable(sStats.peakrate) << "/s ]" << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;
oss << "# ----------------------------------------------------------------------- #" << std::endl;

return oss.str();
}
Expand Down

0 comments on commit 0d9ba69

Please sign in to comment.