From 0d25562014aa8b470cba792109e7015fb79a8fd7 Mon Sep 17 00:00:00 2001 From: Beq Date: Mon, 19 May 2025 18:12:25 +0100 Subject: [PATCH] FIRE-34977 - Reduce Sim crossing overhead causing pauses The purge thread should be the only thread recalculating cache usage. This removes the directory scan from the critial path where it would occasionally trigger due to aligned timers (exacerbated by high rates of region crossing) --- indra/llfilesystem/lldiskcache.cpp | 14 ++++++++++++-- indra/llmessage/message.cpp | 5 ++++- indra/newview/bugsplatattributes.cpp | 1 + indra/newview/llappviewer.cpp | 3 +++ indra/newview/llappviewerwin32.cpp | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 725f04b1f2..2f96c1ded4 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -333,11 +333,21 @@ const std::string LLDiskCache::metaDataToFilepath(const LLUUID& id, LLAssetType: const std::string LLDiskCache::getCacheInfo() { + LL_PROFILE_ZONE_SCOPED; // add some instrumentation std::ostringstream cache_info; F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0f * 1024.0f); - F32 percent_used = ((F32)dirFileSize(sCacheDir) / (F32)mMaxSizeBytes) * 100.0f; - + // stall prevention. We still need to make sure this initialised when called at startup. + F32 percent_used; + if (mStoredCacheSize > 0) + { + percent_used = ((F32)mStoredCacheSize / (F32)mMaxSizeBytes) * 100.0f; + } + else + { + percent_used = ((F32)dirFileSize(sCacheDir) / (F32)mMaxSizeBytes) * 100.0f; + } + // cache_info << std::fixed; cache_info << std::setprecision(1); cache_info << "Max size " << max_in_mb << " MB "; diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 5c37fee62c..4843ed83f1 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -113,10 +113,11 @@ class LLMessageHandlerBridge : public LLHTTPNode void LLMessageHandlerBridge::post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; std::string name = context[CONTEXT_REQUEST][CONTEXT_WILDCARD]["message-name"]; char* namePtr = LLMessageStringTable::getInstance()->getString(name.c_str()); - LL_DEBUGS() << "Setting mLastSender " << input["sender"].asString() << LL_ENDL; + LL_DEBUGS("Messaging") << "Setting mLastSender " << input["sender"].asString() << LL_ENDL; gMessageSystem->mLastSender = LLHost(input["sender"].asString()); gMessageSystem->mPacketsIn += 1; gMessageSystem->mLLSDMessageReader->setMessage(namePtr, input["body"]); @@ -2050,6 +2051,7 @@ void LLMessageSystem::dispatch( const std::string& msg_name, const LLSD& message) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; LLPointer responsep = LLSimpleResponse::create(); dispatch(msg_name, message, responsep); } @@ -2060,6 +2062,7 @@ void LLMessageSystem::dispatch( const LLSD& message, LLHTTPNode::ResponsePtr responsep) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if ((gMessageSystem->mMessageTemplates.find (LLMessageStringTable::getInstance()->getString(msg_name.c_str())) == gMessageSystem->mMessageTemplates.end()) && diff --git a/indra/newview/bugsplatattributes.cpp b/indra/newview/bugsplatattributes.cpp index fdc8871a26..d0a8b32701 100644 --- a/indra/newview/bugsplatattributes.cpp +++ b/indra/newview/bugsplatattributes.cpp @@ -64,6 +64,7 @@ std::string BugSplatAttributes::to_xml_token(const std::string& input) bool BugSplatAttributes::writeToFile(const std::string& file_path) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; std::lock_guard lock(mMutex); // Write to a temporary file first diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 2727797286..190e02b769 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3795,6 +3795,7 @@ bool LLAppViewer::waitForUpdater() void LLAppViewer::writeDebugInfo(bool isStatic) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; // improve instrumentation #if LL_WINDOWS && LL_BUGSPLAT // Improve Bugsplat tracking by using attributes for certain static data items. const LLSD& info = getViewerInfo(); @@ -3823,6 +3824,7 @@ void LLAppViewer::writeDebugInfo(bool isStatic) LLSD LLAppViewer::getViewerInfo() const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; // improve instrumentation // The point of having one method build an LLSD info block and the other // construct the user-visible About string is to ensure that the same info // is available to a getInfo() caller as to the user opening @@ -4135,6 +4137,7 @@ LLSD LLAppViewer::getViewerInfo() const // info["DISK_CACHE_INFO"] = LLDiskCache::getInstance()->getCacheInfo(); if (auto cache = LLDiskCache::getInstance(); cache) { + LL_PROFILE_ZONE_NAMED("gvi-getCacheInfo"); // improve instrumentation info["DISK_CACHE_INFO"] = cache->getCacheInfo(); } // diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index fb20d6c7c0..d219cebf0e 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -644,11 +644,13 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // Use the Attributes API on Windows to enhance crash metadata void LLAppViewerWin32::bugsplatAddStaticAttributes(const LLSD& info) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; #ifdef LL_BUGSPLAT auto& bugSplatMap = BugSplatAttributes::instance(); static bool write_once_after_startup = false; if (!write_once_after_startup ) { + LL_PROFILE_ZONE_NAMED("bs-st-att-once") // Only write the attributes that are fixed once after we've started. // note we might update them more than once and some/many may be empty during startup as we want to catch early crashes // once we're started we can assume they don't change for this run.