aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/upstreamcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/upstream/upstreamcache.cpp')
-rw-r--r--zenserver/upstream/upstreamcache.cpp49
1 files changed, 21 insertions, 28 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp
index 38179f490..520833a3c 100644
--- a/zenserver/upstream/upstreamcache.cpp
+++ b/zenserver/upstream/upstreamcache.cpp
@@ -48,7 +48,7 @@ namespace detail {
virtual ~JupiterUpstreamEndpoint() = default;
- virtual const UpstreamEndpointInfo& GetEndpointInfo() const { return m_Info; }
+ virtual const UpstreamEndpointInfo& GetEndpointInfo() const override { return m_Info; }
virtual UpstreamEndpointHealth Initialize() override { return CheckHealth(); }
@@ -270,8 +270,6 @@ namespace detail {
{
ZEN_TRACE_CPU("Upstream::Horde::PutCacheRecord");
- using namespace fmt::literals;
-
ZEN_ASSERT(CacheRecord.PayloadIds.size() == Payloads.size());
const int32_t MaxAttempts = 3;
@@ -313,7 +311,7 @@ namespace detail {
if (It == std::end(CacheRecord.PayloadIds))
{
- OutReason = "payload '{}' MISSING from local cache"_format(PayloadId);
+ OutReason = fmt::format("payload '{}' MISSING from local cache", PayloadId);
return false;
}
@@ -329,7 +327,7 @@ namespace detail {
if (!BlobResult.Success)
{
- OutReason = "upload payload '{}' FAILED, reason '{}'"_format(PayloadId, BlobResult.Reason);
+ OutReason = fmt::format("upload payload '{}' FAILED, reason '{}'", PayloadId, BlobResult.Reason);
return false;
}
@@ -350,7 +348,7 @@ namespace detail {
if (!RefResult.Success)
{
- return {.Reason = "upload cache record '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket,
+ return {.Reason = fmt::format("upload cache record '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket,
CacheRecord.Key.Hash,
RefResult.Reason),
.Success = false};
@@ -371,7 +369,7 @@ namespace detail {
if (!FinalizeResult.Success)
{
- return {.Reason = "finalize cache record '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket,
+ return {.Reason = fmt::format("finalize cache record '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket,
CacheRecord.Key.Hash,
FinalizeResult.Reason),
.Success = false};
@@ -389,7 +387,7 @@ namespace detail {
if (!FinalizeResult.Success)
{
- return {.Reason = "finalize '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket,
+ return {.Reason = fmt::format("finalize '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket,
CacheRecord.Key.Hash,
FinalizeResult.Reason),
.Success = false};
@@ -403,7 +401,7 @@ namespace detail {
Sb << MissingHash.ToHexString() << ",";
}
- return {.Reason = "finalize '{}/{}' FAILED, still needs payload(s) '{}'"_format(CacheRecord.Key.Bucket,
+ return {.Reason = fmt::format("finalize '{}/{}' FAILED, still needs payload(s) '{}'", CacheRecord.Key.Bucket,
CacheRecord.Key.Hash,
Sb.ToString()),
.Success = false};
@@ -476,12 +474,10 @@ namespace detail {
~ZenUpstreamEndpoint() = default;
- virtual const UpstreamEndpointInfo& GetEndpointInfo() const { return m_Info; }
+ virtual const UpstreamEndpointInfo& GetEndpointInfo() const override { return m_Info; }
virtual UpstreamEndpointHealth Initialize() override
{
- using namespace fmt::literals;
-
const ZenEndpoint& Ep = GetEndpoint();
if (Ep.Ok)
{
@@ -500,8 +496,6 @@ namespace detail {
virtual UpstreamEndpointHealth CheckHealth() override
{
- using namespace fmt::literals;
-
try
{
if (m_Client.IsNull())
@@ -919,8 +913,8 @@ struct UpstreamStats
else if (Result.Success)
{
Stats.HitCount++;
- Stats.DownBytes.fetch_add(double(Result.Bytes) / 1024.0 / 1024.0);
- Stats.SecondsDown.fetch_add(Result.ElapsedSeconds);
+ Stats.DownBytes.fetch_add(Result.Bytes);
+ Stats.TimeDownMs.fetch_add(uint64_t(Result.ElapsedSeconds * 1000.0));
}
else
{
@@ -942,8 +936,8 @@ struct UpstreamStats
if (Result.Success)
{
Stats.UpCount++;
- Stats.UpBytes.fetch_add(double(Result.Bytes) / 1024.0 / 1024.0);
- Stats.SecondsUp.fetch_add(Result.ElapsedSeconds);
+ Stats.UpBytes.fetch_add(Result.Bytes);
+ Stats.TimeUpMs.fetch_add(uint64_t(Result.ElapsedSeconds * 1000.0));
}
else
{
@@ -961,26 +955,25 @@ struct UpstreamStats
for (auto& Ep : Endpoints)
{
// These stats will not be totally correct as the numbers are not captured atomically
-
UpstreamEndpointStats& Stats = Ep->Stats();
const uint64_t HitCount = Stats.HitCount;
const uint64_t MissCount = Stats.MissCount;
- const double DownBytes = Stats.DownBytes;
- const double SecondsDown = Stats.SecondsDown;
- const double UpBytes = Stats.UpBytes;
- const double SecondsUp = Stats.SecondsUp;
+ const double DownMBytes = double(Stats.DownBytes) / 1024.0 / 1024.0;
+ const double SecondsDown = double(Stats.TimeDownMs) / 1000.0;
+ const double UpMBytes = double(Stats.UpBytes) / 1024.0 / 1024.0;
+ const double SecondsUp = double(Stats.TimeUpMs) / 1000.0;
- const double UpSpeed = UpBytes > 0 ? UpBytes / SecondsUp : 0.0;
- const double DownSpeed = DownBytes > 0 ? DownBytes / SecondsDown : 0.0;
+ const double UpSpeed = UpMBytes > 0 ? UpMBytes / SecondsUp : 0.0;
+ const double DownSpeed = DownMBytes > 0 ? DownMBytes / SecondsDown : 0.0;
const uint64_t TotalCount = HitCount + MissCount;
const double HitRate = TotalCount > 0 ? (double(HitCount) / double(TotalCount)) : 0.0;
Logger.debug("STATS - '{}', Hit rate: {:.2f}%, DOWN: '{:.2f} MiB {:.2f} MiB/s', UP: '{:.2f} MiB {:.2f} MiB/s'",
Ep->GetEndpointInfo().Name,
HitRate,
- DownBytes,
+ DownMBytes,
DownSpeed,
- UpBytes,
+ UpMBytes,
UpSpeed);
}
}
@@ -1241,7 +1234,7 @@ public:
const double HitRate = TotalCount > 0 ? (double(HitCount) / double(TotalCount)) : 0.0;
Status << "hit_ratio" << HitRate;
- Status << "downloaded_mb" << Stats.DownBytes;
+ Status << "downloaded_mb" << (double(Stats.DownBytes) / 1024.0 / 1024.0);
Status << "uploaded_mb" << Stats.UpBytes;
Status << "error_count" << Stats.ErrorCount;