diff options
| author | Monty Brandenberg <monty@lindenlab.com> | 2013-05-02 21:59:53 +0000 | 
|---|---|---|
| committer | Monty Brandenberg <monty@lindenlab.com> | 2013-05-02 21:59:53 +0000 | 
| commit | 11cca95187f01f594172ca950315dcd8d99dc2c3 (patch) | |
| tree | 06656459742465e6cb77cb914d27c637fb07a96f | |
| parent | b833f574bc20d4371b78f9c6b02bafe460a2e359 (diff) | |
SH-4161 Integrate cpu metrics into LLDeadmanTimer and then metrics viewer
Integrated as a ctor-time option to LLDeadmanTimer and have mesh
use this mode for the stats I'm gathering.
| -rw-r--r-- | indra/llcommon/lldeadmantimer.cpp | 36 | ||||
| -rw-r--r-- | indra/llcommon/lldeadmantimer.h | 38 | ||||
| -rw-r--r-- | indra/llcommon/tests/lldeadmantimer_test.cpp | 701 | ||||
| -rwxr-xr-x | indra/newview/llmeshrepository.cpp | 2 | 
4 files changed, 562 insertions, 215 deletions
| diff --git a/indra/llcommon/lldeadmantimer.cpp b/indra/llcommon/lldeadmantimer.cpp index 2a356d857a..2ba757d2af 100644 --- a/indra/llcommon/lldeadmantimer.cpp +++ b/indra/llcommon/lldeadmantimer.cpp @@ -42,14 +42,19 @@  //   false    true   Timer finished, result can be read once  //    true    true   Not allowed  // -LLDeadmanTimer::LLDeadmanTimer(F64 horizon) +LLDeadmanTimer::LLDeadmanTimer(F64 horizon, bool inc_cpu)  	: mHorizon(time_type(llmax(horizon, F64(0.0)) * gClockFrequency)),  	  mActive(false),			// If true, a timer is running.  	  mDone(false),				// If true, timer has completed and can be read (once)  	  mStarted(U64L(0)),  	  mExpires(U64L(0)),  	  mStopped(U64L(0)), -	  mCount(U64L(0)) +	  mCount(U64L(0)), +	  mIncCPU(inc_cpu), +	  mUStartCPU(LLProcInfo::time_type(U64L(0))), +	  mUEndCPU(LLProcInfo::time_type(U64L(0))), +	  mSStartCPU(LLProcInfo::time_type(U64L(0))), +	  mSEndCPU(LLProcInfo::time_type(U64L(0)))  {} @@ -76,6 +81,10 @@ void LLDeadmanTimer::start(time_type now)  	mExpires = now + mHorizon;  	mStopped = now;  	mCount = U64L(0); +	if (mIncCPU) +	{ +		LLProcInfo::getCPUUsage(mUStartCPU, mSStartCPU); +	}  } @@ -93,9 +102,26 @@ void LLDeadmanTimer::stop(time_type now)  	mStopped = now;  	mActive = false;  	mDone = true; +	if (mIncCPU) +	{ +		LLProcInfo::getCPUUsage(mUEndCPU, mSEndCPU); +	}  } +bool LLDeadmanTimer::isExpired(time_type now, F64 & started, F64 & stopped, U64 & count, +							   LLProcInfo::time_type & user_cpu, LLProcInfo::time_type & sys_cpu) +{ +	const bool status(isExpired(now, started, stopped, count)); +	if (status) +	{ +		user_cpu = mUEndCPU - mUStartCPU; +		sys_cpu = mSEndCPU - mSStartCPU; +	} +	return status; +} + +		  bool LLDeadmanTimer::isExpired(time_type now, F64 & started, F64 & stopped, U64 & count)  {  	if (mActive && ! mDone) @@ -141,14 +167,20 @@ void LLDeadmanTimer::ringBell(time_type now, unsigned int count)  	if (now >= mExpires)  	{ +		// Timer has expired, this event will be dropped  		mActive = false;  		mDone = true;  	}  	else  	{ +		// Timer renewed, keep going  		mStopped = now;  		mExpires = now + mHorizon;  		mCount += count; +		if (mIncCPU) +		{ +			LLProcInfo::getCPUUsage(mUEndCPU, mSEndCPU); +		}  	}  	return; diff --git a/indra/llcommon/lldeadmantimer.h b/indra/llcommon/lldeadmantimer.h index 8643b8cad8..a6022852b9 100644 --- a/indra/llcommon/lldeadmantimer.h +++ b/indra/llcommon/lldeadmantimer.h @@ -32,6 +32,7 @@  #include "linden_common.h"  #include "lltimer.h" +#include "llprocinfo.h"  /// @file lldeadmantimer.h @@ -93,7 +94,11 @@ public:  	///                 call at which point the timer will consider itself  	///					expired.  	/// -	LLDeadmanTimer(F64 horizon); +	/// @param inc_cpu	If true, gather system and user cpu stats while +	///					running the timer.  This does require more syscalls +	///					during updates.  If false, cpu usage data isn't +	///					collected and will be zero if queried. +	LLDeadmanTimer(F64 horizon, bool inc_cpu);  	~LLDeadmanTimer()   		{} @@ -173,21 +178,38 @@ public:  	/// @param count	If expired, the number of ringBell() calls  	///					made prior to expiration.  	/// +	/// @param user_cpu	Amount of CPU spent in user mode by the process +	///					during the event.  Value in microseconds and will +	///					read zero if not enabled by the constructor. +	/// +	/// @param sys_cpu	Amount of CPU spent in system mode by the process. +	///  	/// @return			true if the timer has expired, false otherwise.  	///					If true, it also returns the started,  	///					stopped and count values otherwise these are  	///					left unchanged.  	/// +	bool isExpired(time_type now, F64 & started, F64 & stopped, U64 & count, +				   LLProcInfo::time_type & user_cpu, LLProcInfo::time_type & sys_cpu); + +	/// Identical to the six-arugment form except is does without the +	/// CPU time return if the caller isn't interested in it.  	bool isExpired(time_type now, F64 & started, F64 & stopped, U64 & count);  protected: -	time_type	mHorizon; -	bool		mActive; -	bool		mDone; -	time_type	mStarted; -	time_type	mExpires; -	time_type	mStopped; -	time_type	mCount; +	time_type					mHorizon; +	bool						mActive; +	bool						mDone; +	time_type					mStarted; +	time_type					mExpires; +	time_type					mStopped; +	time_type					mCount; + +	const bool					mIncCPU;		// Include CPU metrics in timer +	LLProcInfo::time_type		mUStartCPU; +	LLProcInfo::time_type		mUEndCPU; +	LLProcInfo::time_type		mSStartCPU; +	LLProcInfo::time_type		mSEndCPU;  }; diff --git a/indra/llcommon/tests/lldeadmantimer_test.cpp b/indra/llcommon/tests/lldeadmantimer_test.cpp index 63cab29e04..a4ec76a016 100644 --- a/indra/llcommon/tests/lldeadmantimer_test.cpp +++ b/indra/llcommon/tests/lldeadmantimer_test.cpp @@ -28,6 +28,7 @@  #include "../lldeadmantimer.h"  #include "../llsd.h" +#include "../lltimer.h"  #include "../test/lltut.h" @@ -65,14 +66,32 @@ tut::deadmantimer_group_t deadmantimer_instance("LLDeadmanTimer");  template<> template<>  void deadmantimer_object_t::test<1>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(10.0); - -	ensure_equals("isExpired() returns false after ctor()", timer.isExpired(0, started, stopped, count), false); -	ensure_approximately_equals("t1 - isExpired() does not modify started", started, F64(42.0), 2); -	ensure_approximately_equals("t1 - isExpired() does not modify stopped", stopped, F64(97.0), 2); -	ensure_equals("t1 - isExpired() does not modify count", count, U64L(8)); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, false); + +		ensure_equals("WOCM isExpired() returns false after ctor()", timer.isExpired(0, started, stopped, count), false); +		ensure_approximately_equals("WOCM t1 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WOCM t1 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WOCM t1 - isExpired() does not modify count", count, U64L(8)); +	} + +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(10.0, true); + +		ensure_equals("WCM isExpired() returns false after ctor()", timer.isExpired(0, started, stopped, count, user_cpu, sys_cpu), false); +		ensure_approximately_equals("WCM t1 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WCM t1 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WCM t1 - isExpired() does not modify count", count, U64L(8)); +		ensure_equals("WCM t1 - isExpired() does not modify user_cpu", user_cpu, LLProcInfo::time_type(29000)); +		ensure_equals("WCM t1 - isExpired() does not modify sys_cpu", sys_cpu, LLProcInfo::time_type(57000)); +	}  } @@ -80,12 +99,26 @@ void deadmantimer_object_t::test<1>()  template<> template<>  void deadmantimer_object_t::test<2>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(0.0);			// Zero is pre-expired - -	ensure_equals("isExpired() still returns false with 0.0 time ctor()", -				  timer.isExpired(0, started, stopped, count), false); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(0.0, false);			// Zero is pre-expired +		 +		ensure_equals("WOCM isExpired() still returns false with 0.0 time ctor()", +					  timer.isExpired(0, started, stopped, count), false); +	} + +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(0.0, true);			// Zero is pre-expired +		 +		ensure_equals("WCM isExpired() still returns false with 0.0 time ctor()", +					  timer.isExpired(0, started, stopped, count, user_cpu, sys_cpu), false); +	}  } @@ -94,14 +127,29 @@ void deadmantimer_object_t::test<2>()  template<> template<>  void deadmantimer_object_t::test<3>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(0.0); - -	timer.start(0); -	ensure_equals("isExpired() returns true with 0.0 horizon time", -				  timer.isExpired(0, started, stopped, count), true); -	ensure_approximately_equals("expired timer with no bell ringing has stopped == started", started, stopped, 8); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(0.0, false); + +		timer.start(0); +		ensure_equals("WOCM isExpired() returns true with 0.0 horizon time", +					  timer.isExpired(0, started, stopped, count), true); + 		ensure_approximately_equals("WOCM expired timer with no bell ringing has stopped == started", started, stopped, 8); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(0.0, true); + +		timer.start(0); +		ensure_equals("WCM isExpired() returns true with 0.0 horizon time", +					  timer.isExpired(0, started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WCM expired timer with no bell ringing has stopped == started", started, stopped, 8); +	}  } @@ -109,15 +157,31 @@ void deadmantimer_object_t::test<3>()  template<> template<>  void deadmantimer_object_t::test<4>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(0.0); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(0.0, false); +	 +		timer.start(0); +		timer.ringBell(LLDeadmanTimer::getNow() + float_time_to_u64(1000.0), 1); +		ensure_equals("WOCM isExpired() returns true with 0.0 horizon time after bell ring", +					  timer.isExpired(0, started, stopped, count), true); +		ensure_approximately_equals("WOCM ringBell has no impact on expired timer leaving stopped == started", started, stopped, 8); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(0.0, true); -	timer.start(0); -	timer.ringBell(LLDeadmanTimer::getNow() + float_time_to_u64(1000.0), 1); -	ensure_equals("isExpired() returns true with 0.0 horizon time after bell ring", -				  timer.isExpired(0, started, stopped, count), true); -	ensure_approximately_equals("ringBell has no impact on expired timer leaving stopped == started", started, stopped, 8); +		timer.start(0); +		timer.ringBell(LLDeadmanTimer::getNow() + float_time_to_u64(1000.0), 1); +		ensure_equals("WCM isExpired() returns true with 0.0 horizon time after bell ring", +					  timer.isExpired(0, started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WCM ringBell has no impact on expired timer leaving stopped == started", started, stopped, 8); +	}  } @@ -125,16 +189,35 @@ void deadmantimer_object_t::test<4>()  template<> template<>  void deadmantimer_object_t::test<5>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(10.0); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, false); +	 +		timer.start(0); +		ensure_equals("WOCM isExpired() returns false after starting with 10.0 horizon time", +					  timer.isExpired(0, started, stopped, count), false); +		ensure_approximately_equals("WOCM t5 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WOCM t5 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WOCM t5 - isExpired() does not modify count", count, U64L(8)); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(10.0, true); -	timer.start(0); -	ensure_equals("isExpired() returns false after starting with 10.0 horizon time", -				  timer.isExpired(0, started, stopped, count), false); -	ensure_approximately_equals("t5 - isExpired() does not modify started", started, F64(42.0), 2); -	ensure_approximately_equals("t5 - isExpired() does not modify stopped", stopped, F64(97.0), 2); -	ensure_equals("t5 - isExpired() does not modify count", count, U64L(8)); +		timer.start(0); +		ensure_equals("WCM isExpired() returns false after starting with 10.0 horizon time", +					  timer.isExpired(0, started, stopped, count, user_cpu, sys_cpu), false); +		ensure_approximately_equals("WCM t5 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WCM t5 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WCM t5 - isExpired() does not modify count", count, U64L(8)); +		ensure_equals("WCM t5 - isExpired() does not modify user_cpu", user_cpu, LLProcInfo::time_type(29000)); +		ensure_equals("WCM t5 - isExpired() does not modify sys_cpu", sys_cpu, LLProcInfo::time_type(57000)); +	}  } @@ -142,22 +225,47 @@ void deadmantimer_object_t::test<5>()  template<> template<>  void deadmantimer_object_t::test<6>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(10.0); - -	// Would like to do subtraction on current time but can't because -	// the implementation on Windows is zero-based.  We wrap around -	// the backside resulting in a large U64 number. +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, false); + +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. +	 +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(5.0)); +		timer.start(the_past); +		ensure_equals("WOCM t6 - isExpired() returns false with 10.0 horizon time starting 5.0 in past", +					  timer.isExpired(now, started, stopped, count), false); +		ensure_approximately_equals("WOCM t6 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WOCM t6 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WOCM t6 - isExpired() does not modify count", count, U64L(8)); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		LLDeadmanTimer timer(10.0, true); + +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. -	LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); -	LLDeadmanTimer::time_type now(the_past + float_time_to_u64(5.0)); -	timer.start(the_past); -	ensure_equals("isExpired() returns false with 10.0 horizon time starting 5.0 in past", -				  timer.isExpired(now, started, stopped, count), false); -	ensure_approximately_equals("t6 - isExpired() does not modify started", started, F64(42.0), 2); -	ensure_approximately_equals("t6 - isExpired() does not modify stopped", stopped, F64(97.0), 2); -	ensure_equals("t6 - isExpired() does not modify count", count, U64L(8)); +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(5.0)); +		timer.start(the_past); +		ensure_equals("WCM t6 - isExpired() returns false with 10.0 horizon time starting 5.0 in past", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +		ensure_approximately_equals("WCM t6 - isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WCM t6 - isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("t6 - isExpired() does not modify count", count, U64L(8)); +		ensure_equals("WCM t6 - isExpired() does not modify user_cpu", user_cpu, LLProcInfo::time_type(29000)); +		ensure_equals("WCM t6 - isExpired() does not modify sys_cpu", sys_cpu, LLProcInfo::time_type(57000)); +	}  } @@ -165,20 +273,41 @@ void deadmantimer_object_t::test<6>()  template<> template<>  void deadmantimer_object_t::test<7>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(10.0); - -	// Would like to do subtraction on current time but can't because -	// the implementation on Windows is zero-based.  We wrap around -	// the backside resulting in a large U64 number. +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, false); +		 +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. +	 +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); +		timer.start(the_past); +		ensure_equals("WOCM t7 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", +					  timer.isExpired(now,started, stopped, count), true); +		ensure_approximately_equals("WOCM t7 - starting before horizon still gives equal started / stopped", started, stopped, 8); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, true); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); +		 +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. -	LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); -	LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); -	timer.start(the_past); -	ensure_equals("isExpired() returns true with 10.0 horizon time starting 20.0 in past", -				  timer.isExpired(now,started, stopped, count), true); -	ensure_approximately_equals("starting before horizon still gives equal started / stopped", started, stopped, 8); +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); +		timer.start(the_past); +		ensure_equals("WCM t7 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", +					  timer.isExpired(now,started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WOCM t7 - starting before horizon still gives equal started / stopped", started, stopped, 8); +	}  } @@ -186,28 +315,61 @@ void deadmantimer_object_t::test<7>()  template<> template<>  void deadmantimer_object_t::test<8>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(10.0); - -	// Would like to do subtraction on current time but can't because -	// the implementation on Windows is zero-based.  We wrap around -	// the backside resulting in a large U64 number. +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, false); + +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. -	LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); -	LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); -	timer.start(the_past); -	ensure_equals("t8 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", -				  timer.isExpired(now, started, stopped, count), true); - -	started = 42.0; -	stopped = 97.0; -	count = U64L(8); -	ensure_equals("t8 - second isExpired() returns false after true", -				  timer.isExpired(now, started, stopped, count), false); -	ensure_approximately_equals("t8 - 2nd isExpired() does not modify started", started, F64(42.0), 2); -	ensure_approximately_equals("t8 - 2nd isExpired() does not modify stopped", stopped, F64(97.0), 2); -	ensure_equals("t8 - 2nd isExpired() does not modify count", count, U64L(8)); +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); +		timer.start(the_past); +		ensure_equals("WOCM t8 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", +					  timer.isExpired(now, started, stopped, count), true); +		 +		started = 42.0; +		stopped = 97.0; +		count = U64L(8); +		ensure_equals("WOCM t8 - second isExpired() returns false after true", +					  timer.isExpired(now, started, stopped, count), false); +		ensure_approximately_equals("WOCM t8 - 2nd isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WOCM t8 - 2nd isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WOCM t8 - 2nd isExpired() does not modify count", count, U64L(8)); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(10.0, true); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); + +		// Would like to do subtraction on current time but can't because +		// the implementation on Windows is zero-based.  We wrap around +		// the backside resulting in a large U64 number. +	 +		LLDeadmanTimer::time_type the_past(LLDeadmanTimer::getNow()); +		LLDeadmanTimer::time_type now(the_past + float_time_to_u64(20.0)); +		timer.start(the_past); +		ensure_equals("WCM t8 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), true); +		 +		started = 42.0; +		stopped = 97.0; +		count = U64L(8); +		user_cpu = 29000; +		sys_cpu = 57000; +		ensure_equals("WCM t8 - second isExpired() returns false after true", +					  timer.isExpired(now, started, stopped, count), false); +		ensure_approximately_equals("WCM t8 - 2nd isExpired() does not modify started", started, F64(42.0), 2); +		ensure_approximately_equals("WCM t8 - 2nd isExpired() does not modify stopped", stopped, F64(97.0), 2); +		ensure_equals("WCM t8 - 2nd isExpired() does not modify count", count, U64L(8)); +		ensure_equals("WCM t8 - 2nd isExpired() does not modify user_cpu", user_cpu, LLProcInfo::time_type(29000)); +		ensure_equals("WCM t8 - 2nd isExpired() does not modify sys_cpu", sys_cpu, LLProcInfo::time_type(57000)); +	}  } @@ -215,46 +377,93 @@ void deadmantimer_object_t::test<8>()  template<> template<>  void deadmantimer_object_t::test<9>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(5.0); - -	LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); -	F64 real_start(u64_time_to_float(now)); -	timer.start(0); - -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	ensure_equals("t9 - 5.0 horizon timer has not timed out after 10 1-second bell rings", -				  timer.isExpired(now, started, stopped, count), false); -	F64 last_good_ring(u64_time_to_float(now)); - -	// Jump forward and expire -	now += float_time_to_u64(10.0); -	ensure_equals("t9 - 5.0 horizon timer expires on 10-second jump", -				  timer.isExpired(now, started, stopped, count), true); -	ensure_approximately_equals("t9 - started matches start() time", started, real_start, 4); -	ensure_approximately_equals("t9 - stopped matches last ringBell() time", stopped, last_good_ring, 4); -	ensure_equals("t9 - 10 good ringBell()s", count, U64L(10)); -	ensure_equals("t9 - single read only", timer.isExpired(now, started, stopped, count), false); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(5.0, false); + +		LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); +		F64 real_start(u64_time_to_float(now)); +		timer.start(0); + +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WOCM t9 - 5.0 horizon timer has not timed out after 10 1-second bell rings", +					  timer.isExpired(now, started, stopped, count), false); +		F64 last_good_ring(u64_time_to_float(now)); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WOCM t9 - 5.0 horizon timer expires on 10-second jump", +					  timer.isExpired(now, started, stopped, count), true); +		ensure_approximately_equals("WOCM t9 - started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WOCM t9 - stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WOCM t9 - 10 good ringBell()s", count, U64L(10)); +		ensure_equals("WOCM t9 - single read only", timer.isExpired(now, started, stopped, count), false); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(5.0, true); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); + +		LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); +		F64 real_start(u64_time_to_float(now)); +		timer.start(0); + +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WCM t9 - 5.0 horizon timer has not timed out after 10 1-second bell rings", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +		F64 last_good_ring(u64_time_to_float(now)); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WCM t9 - 5.0 horizon timer expires on 10-second jump", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WCM t9 - started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WCM t9 - stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WCM t9 - 10 good ringBell()s", count, U64L(10)); +		ensure_equals("WCM t9 - single read only", timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +	}  } @@ -262,83 +471,167 @@ void deadmantimer_object_t::test<9>()  template<> template<>  void deadmantimer_object_t::test<10>()  { -	F64 started(42.0), stopped(97.0); -	U64 count(U64L(8)); -	LLDeadmanTimer timer(5.0); - -	LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); -	F64 real_start(u64_time_to_float(now)); -	timer.start(0); - -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	ensure_equals("t10 - 5.0 horizon timer has not timed out after 10 1-second bell rings", -				  timer.isExpired(now, started, stopped, count), false); -	F64 last_good_ring(u64_time_to_float(now)); - -	// Jump forward and expire -	now += float_time_to_u64(10.0); -	ensure_equals("t10 - 5.0 horizon timer expires on 10-second jump", -				  timer.isExpired(now, started, stopped, count), true); -	ensure_approximately_equals("t10 - started matches start() time", started, real_start, 4); -	ensure_approximately_equals("t10 - stopped matches last ringBell() time", stopped, last_good_ring, 4); -	ensure_equals("t10 - 10 good ringBell()s", count, U64L(10)); -	ensure_equals("t10 - single read only", timer.isExpired(now, started, stopped, count), false); - -	// Jump forward and restart -	now += float_time_to_u64(1.0); -	real_start = u64_time_to_float(now); -	timer.start(now); - -	// Run a modified bell ring sequence -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	now += float_time_to_u64(1.0); -	timer.ringBell(now, 1); -	ensure_equals("t10 - 5.0 horizon timer has not timed out after 8 1-second bell rings", -				  timer.isExpired(now, started, stopped, count), false); -	last_good_ring = u64_time_to_float(now); - -	// Jump forward and expire -	now += float_time_to_u64(10.0); -	ensure_equals("t10 - 5.0 horizon timer expires on 8-second jump", -				  timer.isExpired(now, started, stopped, count), true); -	ensure_approximately_equals("t10 - 2nd started matches start() time", started, real_start, 4); -	ensure_approximately_equals("t10 - 2nd stopped matches last ringBell() time", stopped, last_good_ring, 4); -	ensure_equals("t10 - 8 good ringBell()s", count, U64L(8)); -	ensure_equals("t10 - single read only - 2nd start", -				  timer.isExpired(now, started, stopped, count), false); +	{ +		// Without cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(5.0, false); + +		LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); +		F64 real_start(u64_time_to_float(now)); +		timer.start(0); + +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WOCM t10 - 5.0 horizon timer has not timed out after 10 1-second bell rings", +					  timer.isExpired(now, started, stopped, count), false); +		F64 last_good_ring(u64_time_to_float(now)); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WOCM t10 - 5.0 horizon timer expires on 10-second jump", +					  timer.isExpired(now, started, stopped, count), true); +		ensure_approximately_equals("WOCM t10 - started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WOCM t10 - stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WOCM t10 - 10 good ringBell()s", count, U64L(10)); +		ensure_equals("WOCM t10 - single read only", timer.isExpired(now, started, stopped, count), false); +		 +		// Jump forward and restart +		now += float_time_to_u64(1.0); +		real_start = u64_time_to_float(now); +		timer.start(now); +		 +		// Run a modified bell ring sequence +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WOCM t10 - 5.0 horizon timer has not timed out after 8 1-second bell rings", +					  timer.isExpired(now, started, stopped, count), false); +		last_good_ring = u64_time_to_float(now); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WOCM t10 - 5.0 horizon timer expires on 8-second jump", +					  timer.isExpired(now, started, stopped, count), true); +		ensure_approximately_equals("WOCM t10 - 2nd started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WOCM t10 - 2nd stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WOCM t10 - 8 good ringBell()s", count, U64L(8)); +		ensure_equals("WOCM t10 - single read only - 2nd start", +					  timer.isExpired(now, started, stopped, count), false); +	} +	{ +		// With cpu metrics +		F64 started(42.0), stopped(97.0); +		U64 count(U64L(8)); +		LLDeadmanTimer timer(5.0, true); +		LLProcInfo::time_type user_cpu(29000), sys_cpu(57000); + +		LLDeadmanTimer::time_type now(LLDeadmanTimer::getNow()); +		F64 real_start(u64_time_to_float(now)); +		timer.start(0); + +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WCM t10 - 5.0 horizon timer has not timed out after 10 1-second bell rings", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +		F64 last_good_ring(u64_time_to_float(now)); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WCM t10 - 5.0 horizon timer expires on 10-second jump", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WCM t10 - started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WCM t10 - stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WCM t10 - 10 good ringBell()s", count, U64L(10)); +		ensure_equals("WCM t10 - single read only", timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +		 +		// Jump forward and restart +		now += float_time_to_u64(1.0); +		real_start = u64_time_to_float(now); +		timer.start(now); +		 +		// Run a modified bell ring sequence +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		now += float_time_to_u64(1.0); +		timer.ringBell(now, 1); +		ensure_equals("WCM t10 - 5.0 horizon timer has not timed out after 8 1-second bell rings", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +		last_good_ring = u64_time_to_float(now); + +		// Jump forward and expire +		now += float_time_to_u64(10.0); +		ensure_equals("WCM t10 - 5.0 horizon timer expires on 8-second jump", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), true); +		ensure_approximately_equals("WCM t10 - 2nd started matches start() time", started, real_start, 4); +		ensure_approximately_equals("WCM t10 - 2nd stopped matches last ringBell() time", stopped, last_good_ring, 4); +		ensure_equals("WCM t10 - 8 good ringBell()s", count, U64L(8)); +		ensure_equals("WCM t10 - single read only - 2nd start", +					  timer.isExpired(now, started, stopped, count, user_cpu, sys_cpu), false); +	}  } +  } // end namespace tut diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 0f33128057..2a863a3103 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -96,7 +96,7 @@ U32 LLMeshRepository::sLODPending = 0;  U32 LLMeshRepository::sCacheBytesRead = 0;  U32 LLMeshRepository::sCacheBytesWritten = 0;  U32 LLMeshRepository::sPeakKbps = 0; -LLDeadmanTimer LLMeshRepository::sQuiescentTimer(15.0); +LLDeadmanTimer LLMeshRepository::sQuiescentTimer(15.0, true);  const U32 MAX_TEXTURE_UPLOAD_RETRIES = 5; | 
