From 461c512b974e27b7b86b2117ea64ad6f730fb0f0 Mon Sep 17 00:00:00 2001 From: Beq Date: Tue, 16 Aug 2022 18:05:22 +0100 Subject: [PATCH] FIRE-31942 - Crash in 360 photo with perfstats running Sigh...even the simplest things in LL land are non-thread safe it seems. --- indra/newview/fsperfstats.cpp | 4 +++- indra/newview/fsperfstats.h | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/indra/newview/fsperfstats.cpp b/indra/newview/fsperfstats.cpp index e53bdc19f2..eeb95d80c1 100644 --- a/indra/newview/fsperfstats.cpp +++ b/indra/newview/fsperfstats.cpp @@ -53,6 +53,8 @@ namespace FSPerfStats U32 lastGlobalPrefChange{0}; std::mutex bufferToggleLock{}; + F64 cpu_hertz{0.0}; + Tunables tunables; std::atomic StatsRecorder::writeBuffer{0}; @@ -342,7 +344,7 @@ namespace FSPerfStats } // The frametime budget we have based on the target FPS selected - auto target_frame_time_raw = (U64)llround((F64)LLTrace::BlockTimer::countsPerSecond()/(tunables.userTargetFPS==0?1:tunables.userTargetFPS)); + auto target_frame_time_raw = (U64)llround(FSPerfStats::cpu_hertz/(tunables.userTargetFPS==0?1:tunables.userTargetFPS)); // LL_INFOS() << "Effective FPS(raw):" << tot_frame_time_raw << " Target:" << target_frame_time_raw << LL_ENDL; auto inferredFPS{1000/(U32)std::max(raw_to_ms(tot_frame_time_raw),1.0)}; U32 settingsChangeFrequency{inferredFPS > 25?inferredFPS:25}; diff --git a/indra/newview/fsperfstats.h b/indra/newview/fsperfstats.h index d690e0bcf2..18533f406d 100644 --- a/indra/newview/fsperfstats.h +++ b/indra/newview/fsperfstats.h @@ -76,6 +76,8 @@ namespace FSPerfStats static constexpr U32 TUNE_AVATARS_ONLY{0}; static constexpr U32 TUNE_SCENE_AND_AVATARS{1}; + extern F64 cpu_hertz; + extern std::atomic tunedAvatars; extern std::atomic renderAvatarMaxART_ns; extern bool belowTargetFPS; @@ -183,6 +185,7 @@ namespace FSPerfStats static inline StatsRecorder& getInstance() { static StatsRecorder instance; + FSPerfStats::cpu_hertz = (F64)LLTrace::BlockTimer::countsPerSecond(); return instance; } static inline void setFocusAv(const LLUUID& avID){focusAv = avID;}; @@ -491,9 +494,9 @@ namespace FSPerfStats }; - inline double raw_to_ns(U64 raw) { return (static_cast(raw) * 1000000000.0) / (F64)LLTrace::BlockTimer::countsPerSecond(); }; - inline double raw_to_us(U64 raw) { return (static_cast(raw) * 1000000.0) / (F64)LLTrace::BlockTimer::countsPerSecond(); }; - inline double raw_to_ms(U64 raw) { return (static_cast(raw) * 1000.0) / (F64)LLTrace::BlockTimer::countsPerSecond(); }; + inline double raw_to_ns(U64 raw) { return (static_cast(raw) * 1000000000.0) / FSPerfStats::cpu_hertz; }; + inline double raw_to_us(U64 raw) { return (static_cast(raw) * 1000000.0) / FSPerfStats::cpu_hertz; }; + inline double raw_to_ms(U64 raw) { return (static_cast(raw) * 1000.0) / FSPerfStats::cpu_hertz; }; using RecordSceneTime = RecordTime; using RecordAvatarTime = RecordTime;