diff options
| author | Richard Linden <none@none> | 2013-01-17 20:04:39 -0800 | 
|---|---|---|
| committer | Richard Linden <none@none> | 2013-01-17 20:04:39 -0800 | 
| commit | 0825eb0207a51e0f747fc04e7c9b6bd6a76e86fe (patch) | |
| tree | c87749c8e9c98c695aa6daae9a6660582580ae4e /indra/llcommon | |
| parent | a0413bdef71d804bbf008cf319f54a5a47efb29c (diff) | |
| parent | 670d03ceb83b92c9bb98d10bb37fba6f75971a2f (diff) | |
merge
Diffstat (limited to 'indra/llcommon')
| -rw-r--r-- | indra/llcommon/llfasttimer.cpp | 28 | ||||
| -rw-r--r-- | indra/llcommon/llfasttimer.h | 19 | ||||
| -rw-r--r-- | indra/llcommon/lltrace.h | 5 | ||||
| -rw-r--r-- | indra/llcommon/lltracerecording.cpp | 46 | ||||
| -rw-r--r-- | indra/llcommon/lltracerecording.h | 21 | ||||
| -rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 6 | 
6 files changed, 68 insertions, 57 deletions
| diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index e6233a094e..37332da31c 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -199,10 +199,11 @@ void TimeBlock::processTimes()  		{  			TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); -			if (accumulator->mLastCaller) +			if (accumulator->mLastAccumulator)  			{ -				timer.setParent(accumulator->mLastCaller); -				accumulator->mParent = accumulator->mLastCaller; +				TimeBlock* parent = accumulator->mLastAccumulator->mBlock; +				timer.setParent(parent); +				accumulator->mParent = parent;  			}  			// no need to push up tree on first use, flag can be set spuriously  			accumulator->mMoveUpTree = false; @@ -250,23 +251,22 @@ void TimeBlock::processTimes()  	// walk up stack of active timers and accumulate current time while leaving timing structures active  	BlockTimer* cur_timer = stack_record->mActiveTimer; -	TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); +	TimeBlockAccumulator* accumulator = stack_record->mAccumulator;  	// root defined by parent pointing to self  	while(cur_timer && cur_timer->mLastTimerData.mActiveTimer != cur_timer)  	{  		U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; -		U64 self_time_delta = cumulative_time_delta - stack_record->mChildTime; +		accumulator->mChildTimeCounter += stack_record->mChildTime;  		stack_record->mChildTime = 0; -		accumulator->mSelfTimeCounter += self_time_delta;  		accumulator->mTotalTimeCounter += cumulative_time_delta;  		cur_timer->mStartTime = cur_time;  		stack_record = &cur_timer->mLastTimerData;  		stack_record->mChildTime += cumulative_time_delta; -		if (stack_record->mTimeBlock) +		if (stack_record->mAccumulator)  		{ -			accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); +			accumulator = stack_record->mAccumulator;  		}  		cur_timer = cur_timer->mLastTimerData.mActiveTimer; @@ -282,7 +282,7 @@ void TimeBlock::processTimes()  		TimeBlock& timer = *it;  		TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); -		accumulator->mLastCaller = NULL; +		accumulator->mLastAccumulator = NULL;  		accumulator->mMoveUpTree = false;  	} @@ -417,10 +417,10 @@ void TimeBlock::writeLog(std::ostream& os)  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////  TimeBlockAccumulator::TimeBlockAccumulator()  -:	mSelfTimeCounter(0), +:	mChildTimeCounter(0),  	mTotalTimeCounter(0),  	mCalls(0), -	mLastCaller(NULL), +	mLastAccumulator(NULL),  	mActiveCount(0),  	mMoveUpTree(false),  	mParent(NULL) @@ -428,10 +428,10 @@ TimeBlockAccumulator::TimeBlockAccumulator()  void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other )  { -	mSelfTimeCounter += other.mSelfTimeCounter; +	mChildTimeCounter += other.mChildTimeCounter;  	mTotalTimeCounter += other.mTotalTimeCounter;  	mCalls += other.mCalls; -	mLastCaller = other.mLastCaller; +	mLastAccumulator = other.mLastAccumulator;  	mActiveCount = other.mActiveCount;  	mMoveUpTree = other.mMoveUpTree;  	mParent = other.mParent; @@ -440,7 +440,7 @@ void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other )  void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other )  {  	mTotalTimeCounter = 0; -	mSelfTimeCounter = 0; +	mChildTimeCounter = 0;  	mCalls = 0;  } diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index fb2868ff98..2d87629561 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -40,9 +40,9 @@ namespace LLTrace  struct BlockTimerStackRecord  { -	class BlockTimer*	mActiveTimer; -	class TimeBlock*	mTimeBlock; -	U64					mChildTime; +	class BlockTimer*			mActiveTimer; +	class TimeBlockAccumulator*	mAccumulator; +	U64							mChildTime;  };  class ThreadTimerStack  @@ -277,7 +277,7 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer)  	mStartTime = TimeBlock::getCPUClockCount64();  	BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); -	TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); +	TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator();  	accumulator->mActiveCount++;  	// keep current parent as long as it is active when we are  	accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -286,7 +286,7 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer)  	mLastTimerData = *cur_timer_data;  	// push new information  	cur_timer_data->mActiveTimer = this; -	cur_timer_data->mTimeBlock = &timer; +	cur_timer_data->mAccumulator = accumulator;  	cur_timer_data->mChildTime = 0;  #endif  } @@ -296,21 +296,22 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer()  #if FAST_TIMER_ON  	U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime;  	BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); -	TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); +	TimeBlockAccumulator* accumulator = cur_timer_data->mAccumulator;  	accumulator->mCalls++; -	accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; +	accumulator->mChildTimeCounter += cur_timer_data->mChildTime;  	accumulator->mTotalTimeCounter += total_time;  	accumulator->mActiveCount--;  	// store last caller to bootstrap tree creation  	// do this in the destructor in case of recursion to get topmost caller -	accumulator->mLastCaller = mLastTimerData.mTimeBlock; +	accumulator->mLastAccumulator = mLastTimerData.mAccumulator;  	// we are only tracking self time, so subtract our total time delta from parents  	mLastTimerData.mChildTime += total_time; -	*ThreadTimerStack::getIfExists() = mLastTimerData; +	//pop stack +	*cur_timer_data = mLastTimerData;  #endif  } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index ab4ad59e3d..1d3c376a58 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -446,11 +446,12 @@ namespace LLTrace  		//  		// members  		// -		U64							mSelfTimeCounter, +		U64							mChildTimeCounter,  									mTotalTimeCounter;  		U32							mCalls; +		class TimeBlock*			mBlock;			// block associated with this accumulator  		class TimeBlock*			mParent;		// last acknowledged parent of this time block -		class TimeBlock*			mLastCaller;	// used to bootstrap tree construction +		TimeBlockAccumulator*		mLastAccumulator;	// used to bootstrap tree construction  		U16							mActiveCount;	// number of timers with this ID active on stack  		bool						mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c110e64380..f45226eb9a 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -60,7 +60,7 @@ Recording::Recording( const Recording& other )  	mStackTimers       = other.mStackTimers;  	mMemStats		   = other.mMemStats; -	LLStopWatchControlsMixin<Recording>::initTo(other.getPlayState()); +	LLStopWatchControlsMixin<Recording>::setPlayState(other.getPlayState());  } @@ -179,7 +179,7 @@ LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumul  LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const  { -	return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); +	return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond();  } @@ -195,7 +195,7 @@ LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccu  LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const  { -	return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); +	return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds);  }  F32 Recording::getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const @@ -345,14 +345,14 @@ U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& st  // PeriodicRecording  /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state)  +PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state)   :	mNumPeriods(num_periods),  	mCurPeriod(0),  	mTotalValid(false),  	mRecordingPeriods( new Recording[num_periods])  {  	llassert(mNumPeriods > 0); -	initTo(state); +	setPlayState(state);  }  PeriodicRecording::PeriodicRecording(PeriodicRecording& other) @@ -377,7 +377,7 @@ PeriodicRecording::~PeriodicRecording()  void PeriodicRecording::nextPeriod()  { -	EStopWatchState play_state = getPlayState(); +	EPlayState play_state = getPlayState();  	Recording& old_recording = getCurRecordingPeriod();  	mCurPeriod = (mCurPeriod + 1) % mNumPeriods;  	old_recording.splitTo(getCurRecordingPeriod()); @@ -458,8 +458,14 @@ void PeriodicRecording::splitFrom(PeriodicRecording& other)  void ExtendableRecording::extend()  { +	// stop recording to get latest data +	mPotentialRecording.stop(); +	// push the data back to accepted recording  	mAcceptedRecording.appendRecording(mPotentialRecording); +	// flush data, so we can start from scratch  	mPotentialRecording.reset(); +	// go back to play state we were in initially +	mPotentialRecording.setPlayState(getPlayState());  }  void ExtendableRecording::start() @@ -514,7 +520,7 @@ PeriodicRecording& get_frame_recording()  void LLStopWatchControlsMixinCommon::start()  { -	switch (mState) +	switch (mPlayState)  	{  	case STOPPED:  		handleReset(); @@ -530,12 +536,12 @@ void LLStopWatchControlsMixinCommon::start()  		llassert(false);  		break;  	} -	mState = STARTED; +	mPlayState = STARTED;  }  void LLStopWatchControlsMixinCommon::stop()  { -	switch (mState) +	switch (mPlayState)  	{  	case STOPPED:  		break; @@ -549,12 +555,12 @@ void LLStopWatchControlsMixinCommon::stop()  		llassert(false);  		break;  	} -	mState = STOPPED; +	mPlayState = STOPPED;  }  void LLStopWatchControlsMixinCommon::pause()  { -	switch (mState) +	switch (mPlayState)  	{  	case STOPPED:  		break; @@ -567,12 +573,12 @@ void LLStopWatchControlsMixinCommon::pause()  		llassert(false);  		break;  	} -	mState = PAUSED; +	mPlayState = PAUSED;  }  void LLStopWatchControlsMixinCommon::resume()  { -	switch (mState) +	switch (mPlayState)  	{  	case STOPPED:  		handleStart(); @@ -586,12 +592,12 @@ void LLStopWatchControlsMixinCommon::resume()  		llassert(false);  		break;  	} -	mState = STARTED; +	mPlayState = STARTED;  }  void LLStopWatchControlsMixinCommon::restart()  { -	switch (mState) +	switch (mPlayState)  	{  	case STOPPED:  		handleReset(); @@ -608,7 +614,7 @@ void LLStopWatchControlsMixinCommon::restart()  		llassert(false);  		break;  	} -	mState = STARTED; +	mPlayState = STARTED;  }  void LLStopWatchControlsMixinCommon::reset() @@ -616,21 +622,23 @@ void LLStopWatchControlsMixinCommon::reset()  	handleReset();  } -void LLStopWatchControlsMixinCommon::initTo( EStopWatchState state ) +void LLStopWatchControlsMixinCommon::setPlayState( EPlayState state )  {  	switch(state)  	{  	case STOPPED: +		stop();  		break;  	case PAUSED: +		pause();  		break;  	case STARTED: -		handleStart(); +		start();  		break;  	default:  		llassert(false);  		break;  	} -	mState = state; +	mPlayState = state;  } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index aa3200e5ad..e6b5e85f90 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -39,7 +39,7 @@ class LLStopWatchControlsMixinCommon  public:  	virtual ~LLStopWatchControlsMixinCommon() {} -	enum EStopWatchState +	enum EPlayState  	{  		STOPPED,  		PAUSED, @@ -53,19 +53,18 @@ public:  	virtual void restart();  	virtual void reset(); -	bool isStarted() const { return mState == STARTED; } -	bool isPaused() const  { return mState == PAUSED; } -	bool isStopped() const { return mState == STOPPED; } -	EStopWatchState getPlayState() const { return mState; } +	bool isStarted() const { return mPlayState == STARTED; } +	bool isPaused() const  { return mPlayState == PAUSED; } +	bool isStopped() const { return mPlayState == STOPPED; } +	EPlayState getPlayState() const { return mPlayState; } +	// force play state to specific value by calling appropriate handle* methods +	void setPlayState(EPlayState state);  protected:  	LLStopWatchControlsMixinCommon() -	:	mState(STOPPED) +	:	mPlayState(STOPPED)  	{} -	// derived classes can call this from their copy constructor in order -	// to duplicate play state of source -	void initTo(EStopWatchState state);  private:  	// trigger active behavior (without reset)  	virtual void handleStart(){}; @@ -74,7 +73,7 @@ private:  	// clear accumulated state, can be called while started  	virtual void handleReset(){}; -	EStopWatchState mState; +	EPlayState mPlayState;  };  template<typename DERIVED> @@ -245,7 +244,7 @@ namespace LLTrace  	:	public LLStopWatchControlsMixin<PeriodicRecording>  	{  	public: -		PeriodicRecording(S32 num_periods, EStopWatchState state = STOPPED); +		PeriodicRecording(S32 num_periods, EPlayState state = STOPPED);  		PeriodicRecording(PeriodicRecording& recording);  		~PeriodicRecording(); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 7b493a651e..bc1d19e72c 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -43,7 +43,7 @@ ThreadRecorder::ThreadRecorder()  	TimeBlock& root_time_block = TimeBlock::getRootTimeBlock();  	ThreadTimerStack* timer_stack = ThreadTimerStack::getInstance(); -	timer_stack->mTimeBlock = &root_time_block; +	timer_stack->mAccumulator = root_time_block.getPrimaryAccumulator();  	timer_stack->mActiveTimer = NULL;  	mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size(); @@ -61,7 +61,9 @@ ThreadRecorder::ThreadRecorder()  		tree_node.mBlock = &time_block;  		tree_node.mParent = &root_time_block; -		it->getPrimaryAccumulator()->mParent = &root_time_block; +		TimeBlockAccumulator* accumulator = it->getPrimaryAccumulator(); +		accumulator->mParent = &root_time_block; +		accumulator->mBlock = &time_block;  	}  	mRootTimer = new BlockTimer(root_time_block); | 
