From c4f2ad1bc2ba08437de19fd6129035b6cbc6e0e1 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Oct 2024 15:26:04 -0400 Subject: Add the latest viewer stats packet into Frame Profile dump file. --- indra/newview/llviewerdisplay.cpp | 4 ++++ indra/newview/llviewerstats.cpp | 15 ++++++++++++++- indra/newview/llviewerstats.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1f4502323c..e8c9b569ee 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -79,6 +79,7 @@ #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "llviewershadermgr.h" +#include "llviewerstats.h" #include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llvoavatarself.h" @@ -1085,6 +1086,9 @@ void getProfileStatsContext(boost::json::object& stats) context.emplace("parcelid", parcel->getLocalID()); } context.emplace("time", LLDate::now().toHTTPDateString("%Y-%m-%dT%H:%M:%S")); + + // supplement with stats packet + stats.emplace("stats", LlsdToJson(get_viewer_stats())); } std::string getProfileStatsFilename() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 9d4c072909..2392973449 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -314,6 +314,11 @@ F32Milliseconds gAvgSimPing(0.f); // rely on default initialization U32Bytes gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY]; +// send_viewer_stats() does enough work that we cache the most recently +// created stats packet for interested observers, instead of rebuilding it on +// demand. +LLSD latest_stats_packet; + extern U32 gVisCompared; extern U32 gVisTested; @@ -488,6 +493,11 @@ void update_statistics() } } +LLSD get_viewer_stats() +{ + return latest_stats_packet; +} + /* * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats. * @@ -510,7 +520,10 @@ void send_viewer_stats(bool include_preferences) return; } - LLSD body; + // Instead of building the stats packet locally within this function, + // build it in the cached value. Clear it first, though. + LLSD& body = latest_stats_packet; + body.clear(); std::string url = gAgent.getRegion()->getCapability("ViewerStats"); if (url.empty()) { diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 8aed1c537e..f558a5d909 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -281,6 +281,7 @@ static const F32 SEND_STATS_PERIOD = 300.0f; // The following are from (older?) statistics code found in appviewer. void update_statistics(); +LLSD get_viewer_stats(); void send_viewer_stats(bool include_preferences); void update_texture_time(); -- cgit v1.2.3 From 5a24ddd305aeb561ccfadb37a96a26cca1131ae7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 21 Oct 2024 10:31:57 -0400 Subject: Regenerate viewer stats for frame profile dump file instead of reporting the most recent previous viewer stats blob. --- indra/newview/llviewerdisplay.cpp | 2 +- indra/newview/llviewerstats.cpp | 32 +++++++++++++------------------- indra/newview/llviewerstats.h | 2 +- 3 files changed, 15 insertions(+), 21 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index e8c9b569ee..cb741e4af9 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1088,7 +1088,7 @@ void getProfileStatsContext(boost::json::object& stats) context.emplace("time", LLDate::now().toHTTPDateString("%Y-%m-%dT%H:%M:%S")); // supplement with stats packet - stats.emplace("stats", LlsdToJson(get_viewer_stats())); + stats.emplace("stats", LlsdToJson(capture_viewer_stats(true))); } std::string getProfileStatsFilename() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 2392973449..a4b06b1e1a 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -67,6 +67,7 @@ #include "lluiusage.h" #include "lltranslate.h" #include "llluamanager.h" +#include "scope_exit.h" // "Minimal Vulkan" to get max API Version @@ -314,11 +315,6 @@ F32Milliseconds gAvgSimPing(0.f); // rely on default initialization U32Bytes gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY]; -// send_viewer_stats() does enough work that we cache the most recently -// created stats packet for interested observers, instead of rebuilding it on -// demand. -LLSD latest_stats_packet; - extern U32 gVisCompared; extern U32 gVisTested; @@ -493,11 +489,6 @@ void update_statistics() } } -LLSD get_viewer_stats() -{ - return latest_stats_packet; -} - /* * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats. * @@ -520,10 +511,6 @@ void send_viewer_stats(bool include_preferences) return; } - // Instead of building the stats packet locally within this function, - // build it in the cached value. Clear it first, though. - LLSD& body = latest_stats_packet; - body.clear(); std::string url = gAgent.getRegion()->getCapability("ViewerStats"); if (url.empty()) { @@ -531,8 +518,18 @@ void send_viewer_stats(bool include_preferences) return; } - LLViewerStats::instance().getRecording().pause(); + LLSD body = capture_viewer_stats(include_preferences); + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, + "Statistics posted to sim", "Failed to post statistics to sim"); +} + +LLSD capture_viewer_stats(bool include_preferences) +{ + LLViewerStats& vstats{ LLViewerStats::instance() }; + vstats.getRecording().pause(); + LL::scope_exit cleanup([&vstats]{ vstats.getRecording().resume(); }); + LLSD body; LLSD &agent = body["agent"]; time_t ltime; @@ -804,10 +801,7 @@ void send_viewer_stats(bool include_preferences) body["session_id"] = gAgentSessionID; LLViewerStats::getInstance()->addToMessage(body); - - LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, - "Statistics posted to sim", "Failed to post statistics to sim"); - LLViewerStats::instance().getRecording().resume(); + return body; } LLTimer& LLViewerStats::PhaseMap::getPhaseTimer(const std::string& phase_name) diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index f558a5d909..dd66fee436 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -281,7 +281,7 @@ static const F32 SEND_STATS_PERIOD = 300.0f; // The following are from (older?) statistics code found in appviewer. void update_statistics(); -LLSD get_viewer_stats(); +LLSD capture_viewer_stats(bool include_preferences); void send_viewer_stats(bool include_preferences); void update_texture_time(); -- cgit v1.2.3