diff options
| author | Per Larsson <[email protected]> | 2022-01-11 10:31:34 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-11 10:31:34 +0100 |
| commit | fa40b11e35f9791bd6ca472ef7bfc246eecbd696 (patch) | |
| tree | 058c1dcef54eb3c15eedc12b29f24d72db239d52 /zenserver/upstream | |
| parent | Added option to disable Sentry crash handler. (diff) | |
| parent | Not all toolchains support C++20's atomic<double>::fetch_add() (diff) | |
| download | zen-fa40b11e35f9791bd6ca472ef7bfc246eecbd696.tar.xz zen-fa40b11e35f9791bd6ca472ef7bfc246eecbd696.zip | |
Merged main.
Diffstat (limited to 'zenserver/upstream')
| -rw-r--r-- | zenserver/upstream/jupiter.cpp | 1 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamapply.cpp | 17 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 49 | ||||
| -rw-r--r-- | zenserver/upstream/upstreamcache.h | 8 |
4 files changed, 31 insertions, 44 deletions
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index ffb9b1cbf..c952d8e10 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -25,7 +25,6 @@ ZEN_THIRD_PARTY_INCLUDES_END #include <json11.hpp> using namespace std::literals; -using namespace fmt::literals; namespace zen { diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index f8a8c3e62..fe7f7d9c8 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -53,10 +53,9 @@ namespace detail { , m_CasStore(CasStore) , m_CidStore(CidStore) { - using namespace fmt::literals; - m_DisplayName = "Horde - '{}'"_format(Options.ServiceUrl); + m_DisplayName = fmt::format("Horde - '{}'", Options.ServiceUrl); m_Client = new CloudCacheClient(Options); - m_ChannelId = "zen-{}"_format(zen::GetSessionIdString()); + m_ChannelId = fmt::format("zen-{}", zen::GetSessionIdString()); } virtual ~HordeUpstreamApplyEndpoint() = default; @@ -442,14 +441,13 @@ namespace detail { if (Outcome != ComputeTaskOutcome::Success) { - using namespace fmt::literals; const std::string_view Detail = TaskStatus["d"sv].AsString(); if (!Detail.empty()) { return {.Error{.ErrorCode = -1, - .Reason = "Task {}: {}"_format(ComputeTaskOutcomeToString(Outcome), std::string(Detail))}}; + .Reason = fmt::format("Task {}: {}", ComputeTaskOutcomeToString(Outcome), std::string(Detail))}}; } - return {.Error{.ErrorCode = -1, .Reason = "Task {}"_format(ComputeTaskOutcomeToString(Outcome))}}; + return {.Error{.ErrorCode = -1, .Reason = fmt::format("Task {}", ComputeTaskOutcomeToString(Outcome))}}; } const IoHash TaskId = TaskStatus["h"sv].AsObjectAttachment(); @@ -713,8 +711,6 @@ namespace detail { [[nodiscard]] bool ProcessApplyKey(const UpstreamApplyRecord& ApplyRecord, UpstreamData& Data) { - using namespace fmt::literals; - std::string ExecutablePath; std::map<std::string, std::string> Environment; std::set<std::filesystem::path> InputFiles; @@ -749,7 +745,7 @@ namespace detail { for (auto& It : ApplyRecord.WorkerDescriptor["dirs"sv]) { std::string_view Directory = It.AsString(); - std::string DummyFile = "{}/.zen_empty_file"_format(Directory); + std::string DummyFile = fmt::format("{}/.zen_empty_file", Directory); InputFiles.insert(DummyFile); Data.Blobs[EmptyBufferId] = EmptyBuffer; InputFileHashes[DummyFile] = EmptyBufferId; @@ -816,7 +812,6 @@ namespace detail { Data.Objects[SandboxHash] = std::move(Sandbox); { - using namespace fmt::literals; std::string_view HostPlatform = ApplyRecord.WorkerDescriptor["host"sv].AsString(); if (HostPlatform.empty()) { @@ -829,7 +824,7 @@ namespace detail { bool Exclusive = ApplyRecord.WorkerDescriptor["exclusive"sv].AsBool(); // TODO: Remove override when Horde accepts the UE style Host Platforms (Win64, Linux, Mac) - std::string Condition = "Platform == '{}'"_format(HostPlatform); + std::string Condition = fmt::format("Platform == '{}'", HostPlatform); if (HostPlatform == "Win64") { Condition += " && Pool == 'Win-RemoteExec'"; 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; diff --git a/zenserver/upstream/upstreamcache.h b/zenserver/upstream/upstreamcache.h index c463c4996..20c89a574 100644 --- a/zenserver/upstream/upstreamcache.h +++ b/zenserver/upstream/upstreamcache.h @@ -75,10 +75,10 @@ struct UpstreamEndpointStats std::atomic_uint64_t MissCount{}; std::atomic_uint64_t UpCount{}; std::atomic_uint64_t ErrorCount{}; - std::atomic<double> UpBytes{}; - std::atomic<double> DownBytes{}; - std::atomic<double> SecondsUp{}; - std::atomic<double> SecondsDown{}; + std::atomic_uint64_t UpBytes{}; + std::atomic_uint64_t DownBytes{}; + std::atomic_uint64_t TimeUpMs{}; + std::atomic_uint64_t TimeDownMs{}; }; struct CacheRecordGetCompleteParams |