Commits

falcon committed 7f06f6f

Added AgentPositionSnaps data to ViewerStats to measure frequency and scale of interpolation failures.

  • Participants
  • Parent commits 5490270

Comments (0)

Files changed (4)

indra/newview/llagent.cpp

 	}
 	else if(mTeleportState == TELEPORT_ARRIVING)
 	{
+		// First two position updates after a teleport tend to be weird
+		LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2;
+
 		// Let the interested parties know we've teleported.
 		LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal());
 	}

indra/newview/llviewerobject.cpp

 #include "llviewerparceloverlay.h"
 #include "llviewerpartsource.h"
 #include "llviewerregion.h"
+#include "llviewerstats.h"
 #include "llviewertextureanim.h"
 #include "llviewerwindow.h" // For getSpinAxis
 #include "llvoavatar.h"
 
 			avatar->clampAttachmentPositions();
 		}
+		
+		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
+		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
+		{
+			LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
+		}
 	}
 
 	if (new_rot != mLastRot

indra/newview/llviewerstats.cpp

 	{
 		mStats[ST_HAS_BAD_TIMER] = 1.0;
 	}	
+	
+	mAgentPositionSnaps.reset();
 }
 
 LLViewerStats::~LLViewerStats()
 	LLViewerStats::getInstance()->mPacketsOutStat.reset();
 	LLViewerStats::getInstance()->mFPSStat.reset();
 	LLViewerStats::getInstance()->mTexturePacketsStat.reset();
+	
+	LLViewerStats::getInstance()->mAgentPositionSnaps.reset();
 }
 
 
 					<< llendl;
 		}
 	}
+	
+	body["AgentPositionSnaps"] = mAgentPositionSnaps.getData();
+	llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() 
+			<< "; Count = " << mAgentPositionSnaps.getCount() << llendl;
 }
 
 // static

indra/newview/llviewerstats.h

 	
 	void addToMessage(LLSD &body) const;
 
+	struct  StatsAccumulator
+	{
+		S32 mCount;
+		F32 mSum;
+		F32 mSumOfSquares;
+		U32 mCountOfNextUpdatesToIgnore;
+
+		inline void push( F32 val )
+		{
+			if ( mCountOfNextUpdatesToIgnore > 0 )
+			{
+				mCountOfNextUpdatesToIgnore--;
+				return;
+			}
+			
+			mCount++;
+			mSum += val;
+			mSumOfSquares += val * val;
+		}
+		
+		inline F32 getMean() const
+		{
+			return (mCount == 0) ? 0.f : ((F32)mSum)/mCount;
+		}
+		
+		inline F32 getStdDev() const
+		{
+			const F32 mean = getMean();
+			return (mCount == 0) ? 0.f : sqrt( mSumOfSquares/mCount - (mean * mean) );
+		}
+		
+		inline U32 getCount() const
+		{
+			return mCount;
+		}
+
+		inline void reset()
+		{
+			mCount = mSum = mSumOfSquares = 0;
+			mCountOfNextUpdatesToIgnore = 0;
+		}
+		
+		inline LLSD getData() const
+		{
+			LLSD data;
+			data["mean"] = getMean();
+			data["std_dev"] = getStdDev();
+			data["count"] = (S32)mCount;
+			return data;
+		}
+	};
+
+	StatsAccumulator mAgentPositionSnaps;
+	
 private:
 	F64	mStats[ST_COUNT];