From f3e407ae3f05e897de0b0d7daea4d31f09e73048 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Mon, 11 Feb 2013 13:50:26 -0500
Subject: SH-3852 WIP - removed avatar metrics from ViewerAssetMetrics

---
 indra/newview/llappviewer.cpp                   |  1 -
 indra/newview/llappviewerwin32.cpp              |  2 +-
 indra/newview/llviewerassetstats.cpp            | 42 +---------------------
 indra/newview/llviewerassetstats.h              | 10 ------
 indra/newview/llviewerstats.cpp                 | 25 -------------
 indra/newview/llviewerstats.h                   |  3 --
 indra/newview/llvoavatar.cpp                    |  4 +--
 indra/newview/llvoavatarself.cpp                | 22 ++++++++----
 indra/newview/tests/llviewerassetstats_test.cpp | 47 ++++++-------------------
 9 files changed, 29 insertions(+), 127 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2ee325a09e..9a5010c781 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4410,7 +4410,6 @@ void LLAppViewer::idle()
 			// The 5-second interval is nice for this purpose.  If the object debug
 			// bit moves or is disabled, please give this a suitable home.
 			LLViewerAssetStatsFF::record_fps_main(gFPSClamped);
-			LLViewerAssetStatsFF::record_avatar_stats();
 		}
 	}
 
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 8326be433e..82b93b52a2 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -92,7 +92,7 @@ void nvapi_error(NvAPI_Status status)
 	llwarns << szDesc << llendl;
 
 	//should always trigger when asserts are enabled
-	llassert(status == NVAPI_OK);
+	//llassert(status == NVAPI_OK);
 }
 
 // Create app mutex creates a unique global windows object. 
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 4c59fd0371..ed768eb093 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -30,7 +30,6 @@
 #include "llregionhandle.h"
 
 #include "stdtypes.h"
-#include "llvoavatar.h"
 
 /*
  * Classes and utility functions for per-thread and per-region
@@ -127,8 +126,6 @@ LLViewerAssetStats::PerRegionStats::merge(const LLViewerAssetStats::PerRegionSta
 		mFPS.merge(src.mFPS);
 	}
 
-	// Avatar stats - data all comes from main thread, so leave alone.
-
 	// Requests
 	for (int i = 0; i < LL_ARRAY_SIZE(mRequests); ++i)
 	{
@@ -160,9 +157,7 @@ LLViewerAssetStats::LLViewerAssetStats()
 
 LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 	: mRegionHandle(src.mRegionHandle),
-	  mResetTimestamp(src.mResetTimestamp),
-	  mPhaseStats(src.mPhaseStats),
-	  mAvatarRezStates(src.mAvatarRezStates)
+	  mResetTimestamp(src.mResetTimestamp)
 {
 	const PerRegionContainer::const_iterator it_end(src.mRegionStats.end());
 	for (PerRegionContainer::const_iterator it(src.mRegionStats.begin()); it_end != it; ++it)
@@ -258,17 +253,6 @@ LLViewerAssetStats::recordFPS(F32 fps)
 	mCurRegionStats->mFPS.record(fps);
 }
 
-void
-LLViewerAssetStats::recordAvatarStats()
-{
-	std::vector<S32> rez_counts;
-	LLVOAvatar::getNearbyRezzedStats(rez_counts);
-	mAvatarRezStates = rez_counts;
-	mPhaseStats.clear();
-	mPhaseStats["cloud"] = LLViewerStats::PhaseMap::getPhaseStats("cloud");
-	mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray");
-}
-
 LLSD
 LLViewerAssetStats::asLLSD(bool compact_output)
 {
@@ -299,11 +283,6 @@ LLViewerAssetStats::asLLSD(bool compact_output)
 	static const LLSD::String max_tag("max");
 	static const LLSD::String mean_tag("mean");
 
-	// Avatar sub-tags
-	static const LLSD::String avatar_tag("avatar");
-	static const LLSD::String avatar_nearby_tag("nearby");
-	static const LLSD::String avatar_phase_stats_tag("phase_stats");
-	
 	const duration_t now = LLViewerAssetStatsFF::get_timestamp();
 	mCurRegionStats->accumulateTime(now);
 
@@ -362,16 +341,6 @@ LLViewerAssetStats::asLLSD(bool compact_output)
 	LLSD ret = LLSD::emptyMap();
 	ret["regions"] = regions;
 	ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6);
-	LLSD avatar_info;
-	avatar_info[avatar_nearby_tag] = LLSD::emptyArray();
-	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
-	{
-		std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat);
-		avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat];
-	}
-	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].getData();
-	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].getData();
-	ret[avatar_tag] = avatar_info;
 	
 	return ret;
 }
@@ -470,15 +439,6 @@ record_fps_main(F32 fps)
 	gViewerAssetStatsMain->recordFPS(fps);
 }
 
-void
-record_avatar_stats()
-{
-	if (! gViewerAssetStatsMain)
-		return;
-
-	gViewerAssetStatsMain->recordAvatarStats();
-}
-
 // 'thread1' - should be for TextureFetch thread
 
 void
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 8319752230..3381c01ed5 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -36,7 +36,6 @@
 #include "llviewerassetstorage.h"
 #include "llsimplestat.h"
 #include "llsd.h"
-#include "llvoavatar.h"
 
 /**
  * @class LLViewerAssetStats
@@ -182,9 +181,6 @@ public:
 	// Frames-Per-Second Samples
 	void recordFPS(F32 fps);
 
-	// Avatar-related statistics
-	void recordAvatarStats();
-
 	// Merge a source instance into a destination instance.  This is
 	// conceptually an 'operator+=()' method:
 	// - counts are added
@@ -256,10 +252,6 @@ protected:
 
 	// Time of last reset
 	duration_t mResetTimestamp;
-
-	// Nearby avatar stats
-	std::vector<S32> mAvatarRezStates;
-	LLViewerStats::phase_stats_t mPhaseStats;
 };
 
 
@@ -318,8 +310,6 @@ void record_response_main(LLViewerAssetType::EType at, bool with_http, bool is_t
 
 void record_fps_main(F32 fps);
 
-void record_avatar_stats();
-
 /**
  * Region context, event and duration loggers for Thread 1.
  */
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 28c6b59391..65cae9b338 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -764,7 +764,6 @@ void LLViewerStats::PhaseMap::stopPhase(const std::string& phase_name)
 		if (iter->second.getStarted())
 		{
 			// Going from started to paused state - record stats.
-			recordPhaseStat(phase_name,iter->second.getElapsedTimeF32());
 			iter->second.stop();
 		}
 	}
@@ -803,27 +802,3 @@ LLSD LLViewerStats::PhaseMap::dumpPhases()
 	}
 	return result;
 }
-
-// static initializer
-//static
-LLViewerStats::phase_stats_t LLViewerStats::PhaseMap::sStats;
-
-// static
-LLViewerStats::StatsAccumulator& LLViewerStats::PhaseMap::getPhaseStats(const std::string& phase_name)
-{
-	phase_stats_t::iterator it = sStats.find(phase_name);
-	if (it == sStats.end())
-	{
-		LLViewerStats::StatsAccumulator new_stats;
-		sStats[phase_name] = new_stats;
-	}
-	return sStats[phase_name];
-}
-
-// static
-void LLViewerStats::PhaseMap::recordPhaseStat(const std::string& phase_name, F32 value)
-{
-	LLViewerStats::StatsAccumulator& stats = getPhaseStats(phase_name);
-	stats.push(value);
-}
-
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 084f5ae7d1..e74fb36e97 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -285,7 +285,6 @@ public:
 	{
 	private:
 		phase_map_t mPhaseMap;
-		static phase_stats_t sStats;
 	public:
 		PhaseMap();
 		LLTimer&	 	getPhaseTimer(const std::string& phase_name);
@@ -294,8 +293,6 @@ public:
 		void			stopPhase(const std::string& phase_name);
 		void			clearPhases();
 		LLSD			dumpPhases();
-		static StatsAccumulator& getPhaseStats(const std::string& phase_name);
-		static void recordPhaseStat(const std::string& phase_name, F32 value);
 		phase_map_t::iterator begin() { return mPhaseMap.begin(); }
 		phase_map_t::iterator end() { return mPhaseMap.end(); }
 	};
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index e911e01420..e298ccdb9c 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5971,12 +5971,12 @@ void LLVOAvatar::logMetricsTimerRecord(const std::string& phase_name, F32 elapse
 	U32 grid_x(0), grid_y(0);
 	if (getRegion())
 	{
-		record["central_bake_version"] = getRegion()->getCentralBakeVersion();
+		record["central_bake_version"] = LLSD::Integer(getRegion()->getCentralBakeVersion());
 		grid_from_region_handle(getRegion()->getHandle(), &grid_x, &grid_y);
 	}
 	record["grid_x"] = LLSD::Integer(grid_x);
 	record["grid_y"] = LLSD::Integer(grid_y);
-	record["is_using_server_bake"] = isUsingServerBakes();
+	record["is_using_server_bakes"] = ((bool) isUsingServerBakes());
 	record["is_self"] = isSelf();
 	
 
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 4461ba32c5..55e927652e 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2236,7 +2236,12 @@ private:
 
 bool LLVOAvatarSelf::updateAvatarRezMetrics(bool force_send)
 {
-	F32 send_period = 30.0;
+	const F32 AV_METRICS_INTERVAL_QA = 30.0;
+	F32 send_period = 300.0;
+	if (gSavedSettings.getBOOL("QAModeMetrics"))
+	{
+		send_period = AV_METRICS_INTERVAL_QA;
+	}
 
 	if (force_send || mTimeSinceLastRezMessage.getElapsedTimeF32() > send_period)
 	{
@@ -2260,7 +2265,10 @@ bool operator<(const LLSD& a, const LLSD& b)
 	std::ostringstream aout, bout;
 	aout << LLSDNotationStreamer(a);
 	bout << LLSDNotationStreamer(b);
-	return aout.str() < bout.str();
+	std::string astring = aout.str();
+	std::string bstring = bout.str();
+
+	return astring < bstring;
 
 }
 
@@ -2281,10 +2289,10 @@ LLSD summarize_by_buckets(std::vector<LLSD> in_records,
 		{
 			const std::string& field = *field_iter;
 			key[field] = record[field];
-			LLViewerStats::StatsAccumulator& stats = accum[key];
-			F32 value = record[val_field].asReal();
-			stats.push(value);
 		}
+		LLViewerStats::StatsAccumulator& stats = accum[key];
+		F32 value = record[val_field].asReal();
+		stats.push(value);
 	}
 	for (std::map<LLSD,LLViewerStats::StatsAccumulator>::iterator accum_it = accum.begin();
 		 accum_it != accum.end(); ++accum_it)
@@ -2331,9 +2339,9 @@ void LLVOAvatarSelf::sendViewerAppearanceChangeMetrics()
 	by_fields.push_back("completed");
 	by_fields.push_back("grid_x");
 	by_fields.push_back("grid_y");
-	by_fields.push_back("is_using_server_bake");
+	by_fields.push_back("is_using_server_bakes");
 	by_fields.push_back("is_self");
-	by_fields.push_back("cbv");
+	by_fields.push_back("central_bake_version");
 	LLSD summary = summarize_by_buckets(mPendingTimerRecords, by_fields, std::string("elapsed"));
 	msg["timers"] = summary;
 
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index f8923b9868..b55b6c13d4 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -35,31 +35,6 @@
 #include "lluuid.h"
 #include "llsdutil.h"
 #include "llregionhandle.h"
-#include "../llvoavatar.h"
-
-void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
-{
-	counts.resize(3);
-	counts[0] = 0;
-	counts[1] = 0;
-	counts[2] = 1;
-}
-
-// static
-std::string LLVOAvatar::rezStatusToString(S32 rez_status)
-{
-	if (rez_status==0) return "cloud";
-	if (rez_status==1) return "gray";
-	if (rez_status==2) return "textured";
-	return "unknown";
-}
-
-// static
-LLViewerStats::StatsAccumulator& LLViewerStats::PhaseMap::getPhaseStats(const std::string& phase_name)
-{
-	static LLViewerStats::StatsAccumulator junk;
-	return junk;
-}
 
 static const char * all_keys[] = 
 {
@@ -117,7 +92,6 @@ static const U64 region2_handle(0x0000030000004200ULL);
 static const std::string region1_handle_str("0000040000003f00");
 static const std::string region2_handle_str("0000030000004200");
 
-#if 0
 static bool
 is_empty_map(const LLSD & sd)
 {
@@ -135,7 +109,6 @@ is_double_key_map(const LLSD & sd, const std::string & key1, const std::string &
 {
 	return sd.isMap() && 2 == sd.size() && sd.has(key1) && sd.has(key2);
 }
-#endif
 
 static bool
 is_triple_key_map(const LLSD & sd, const std::string & key1, const std::string & key2, const std::string& key3)
@@ -147,7 +120,7 @@ is_triple_key_map(const LLSD & sd, const std::string & key1, const std::string &
 static bool
 is_no_stats_map(const LLSD & sd)
 {
-	return is_triple_key_map(sd, "duration", "regions", "avatar");
+	return is_double_key_map(sd, "duration", "regions");
 }
 
 static bool
@@ -258,7 +231,7 @@ namespace tut
 		// Once the region is set, we will get a response even with no data collection
 		it->setRegion(region1_handle);
 		sd_full = it->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd_full, "duration", "regions", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd_full, "duration", "regions"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd_full["regions"], region1_handle));
 		
 		LLSD sd = sd_full["regions"][0];
@@ -299,7 +272,7 @@ namespace tut
 		it->setRegion(region1_handle);
 		
 		LLSD sd = it->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd[0];
 		
@@ -324,7 +297,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
 
 		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd["regions"][0];
 		
@@ -364,7 +337,7 @@ namespace tut
 		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
 		ensure("Other collector is empty", is_no_stats_map(sd));
 		sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd["regions"][0];
 		
@@ -414,7 +387,7 @@ namespace tut
 
 		// std::cout << sd << std::endl;
 		
-		ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
+		ensure("Correct double-key LLSD map root", is_double_key_map(sd, "duration", "regions"));
 		ensure("Correct double-slot LLSD array regions", is_double_slot_array(sd["regions"], region1_handle, region2_handle));
 		LLSD sd1 = get_region(sd, region1_handle);
 		LLSD sd2 = get_region(sd, region2_handle);
@@ -437,7 +410,7 @@ namespace tut
 		// Reset leaves current region in place
 		gViewerAssetStatsMain->reset();
 		sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = sd["regions"][0];
 		
@@ -486,7 +459,7 @@ namespace tut
 
 		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
 
-		ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
+		ensure("Correct double-key LLSD map root", is_double_key_map(sd, "duration", "regions"));
 		ensure("Correct double-slot LLSD array regions", is_double_slot_array(sd["regions"], region1_handle, region2_handle));
 		LLSD sd1 = get_region(sd, region1_handle);
 		LLSD sd2 = get_region(sd, region2_handle);
@@ -509,7 +482,7 @@ namespace tut
 		// Reset leaves current region in place
 		gViewerAssetStatsMain->reset();
 		sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "duration", "regions"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = get_region(sd, region2_handle);
 		ensure("Region2 is present in results", sd2.isMap());
@@ -555,7 +528,7 @@ namespace tut
 		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
 		ensure("Other collector is empty", is_no_stats_map(sd));
 		sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = get_region(sd, region1_handle);
 		ensure("Region1 is present in results", sd.isMap());
-- 
cgit v1.2.3