Skip to content
Snippets Groups Projects
Commit e975ae35 authored by Richard Linden's avatar Richard Linden
Browse files

SH-3406 WIP convert fast timers to lltrace system

fixed crash on startup
parent d290112d
No related branches found
No related tags found
No related merge requests found
...@@ -198,12 +198,10 @@ void TimeBlock::processTimes() ...@@ -198,12 +198,10 @@ void TimeBlock::processTimes()
{ {
TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator();
if (accumulator->mLastAccumulator) if (accumulator->mLastCaller)
{ {
TimeBlock* parent = accumulator->mLastAccumulator->mBlock; timer.setParent(accumulator->mLastCaller);
llassert(parent); accumulator->mParent = accumulator->mLastCaller;
timer.setParent(parent);
accumulator->mParent = parent;
} }
// no need to push up tree on first use, flag can be set spuriously // no need to push up tree on first use, flag can be set spuriously
accumulator->mMoveUpTree = false; accumulator->mMoveUpTree = false;
...@@ -252,10 +250,8 @@ void TimeBlock::processTimes() ...@@ -252,10 +250,8 @@ void TimeBlock::processTimes()
// walk up stack of active timers and accumulate current time while leaving timing structures active // walk up stack of active timers and accumulate current time while leaving timing structures active
BlockTimerStackRecord* stack_record = ThreadTimerStack::getInstance(); BlockTimerStackRecord* stack_record = ThreadTimerStack::getInstance();
BlockTimer* cur_timer = stack_record->mActiveTimer; BlockTimer* cur_timer = stack_record->mActiveTimer;
TimeBlockAccumulator* accumulator = stack_record->mAccumulator; TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
llassert(accumulator);
// root defined by parent pointing to self // root defined by parent pointing to self
while(cur_timer && cur_timer->mParentTimerData.mActiveTimer != cur_timer) while(cur_timer && cur_timer->mParentTimerData.mActiveTimer != cur_timer)
{ {
...@@ -268,7 +264,7 @@ void TimeBlock::processTimes() ...@@ -268,7 +264,7 @@ void TimeBlock::processTimes()
cur_timer->mStartTime = cur_time; cur_timer->mStartTime = cur_time;
stack_record = &cur_timer->mParentTimerData; stack_record = &cur_timer->mParentTimerData;
accumulator = stack_record->mAccumulator; accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
cur_timer = stack_record->mActiveTimer; cur_timer = stack_record->mActiveTimer;
stack_record->mChildTime += cumulative_time_delta; stack_record->mChildTime += cumulative_time_delta;
...@@ -284,7 +280,7 @@ void TimeBlock::processTimes() ...@@ -284,7 +280,7 @@ void TimeBlock::processTimes()
TimeBlock& timer = *it; TimeBlock& timer = *it;
TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator();
accumulator->mLastAccumulator = NULL; accumulator->mLastCaller = NULL;
accumulator->mMoveUpTree = false; accumulator->mMoveUpTree = false;
} }
...@@ -422,11 +418,10 @@ TimeBlockAccumulator::TimeBlockAccumulator() ...@@ -422,11 +418,10 @@ TimeBlockAccumulator::TimeBlockAccumulator()
: mChildTimeCounter(0), : mChildTimeCounter(0),
mTotalTimeCounter(0), mTotalTimeCounter(0),
mCalls(0), mCalls(0),
mLastAccumulator(NULL), mLastCaller(NULL),
mActiveCount(0), mActiveCount(0),
mMoveUpTree(false), mMoveUpTree(false),
mParent(NULL), mParent(NULL)
mBlock(NULL)
{} {}
void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other ) void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other )
...@@ -434,11 +429,10 @@ void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other ) ...@@ -434,11 +429,10 @@ void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other )
mChildTimeCounter += other.mChildTimeCounter; mChildTimeCounter += other.mChildTimeCounter;
mTotalTimeCounter += other.mTotalTimeCounter; mTotalTimeCounter += other.mTotalTimeCounter;
mCalls += other.mCalls; mCalls += other.mCalls;
mLastAccumulator = other.mLastAccumulator; mLastCaller = other.mLastCaller;
mActiveCount = other.mActiveCount; mActiveCount = other.mActiveCount;
mMoveUpTree = other.mMoveUpTree; mMoveUpTree = other.mMoveUpTree;
mParent = other.mParent; mParent = other.mParent;
mBlock = other.mBlock;
} }
void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other ) void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other )
......
...@@ -40,9 +40,9 @@ namespace LLTrace ...@@ -40,9 +40,9 @@ namespace LLTrace
struct BlockTimerStackRecord struct BlockTimerStackRecord
{ {
class BlockTimer* mActiveTimer; class BlockTimer* mActiveTimer;
class TimeBlockAccumulator* mAccumulator; class TimeBlock* mTimeBlock;
U64 mChildTime; U64 mChildTime;
}; };
class ThreadTimerStack class ThreadTimerStack
...@@ -73,7 +73,7 @@ class BlockTimer ...@@ -73,7 +73,7 @@ class BlockTimer
private: private:
U64 mStartTime; U64 mStartTime;
BlockTimerStackRecord mParentTimerData; BlockTimerStackRecord mParentTimerData;
}; };
...@@ -280,14 +280,13 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) ...@@ -280,14 +280,13 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer)
TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator();
accumulator->mActiveCount++; accumulator->mActiveCount++;
// keep current parent as long as it is active when we are // keep current parent as long as it is active when we are
llassert(accumulator->mParent);
accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0);
// store top of stack // store top of stack
mParentTimerData = *cur_timer_data; mParentTimerData = *cur_timer_data;
// push new information // push new information
cur_timer_data->mActiveTimer = this; cur_timer_data->mActiveTimer = this;
cur_timer_data->mAccumulator = accumulator; cur_timer_data->mTimeBlock = &timer;
cur_timer_data->mChildTime = 0; cur_timer_data->mChildTime = 0;
#endif #endif
} }
...@@ -297,7 +296,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() ...@@ -297,7 +296,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer()
#if FAST_TIMER_ON #if FAST_TIMER_ON
U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime;
BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists();
TimeBlockAccumulator* accumulator = cur_timer_data->mAccumulator; TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator();
accumulator->mCalls++; accumulator->mCalls++;
accumulator->mChildTimeCounter += cur_timer_data->mChildTime; accumulator->mChildTimeCounter += cur_timer_data->mChildTime;
...@@ -306,7 +305,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() ...@@ -306,7 +305,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer()
// store last caller to bootstrap tree creation // store last caller to bootstrap tree creation
// do this in the destructor in case of recursion to get topmost caller // do this in the destructor in case of recursion to get topmost caller
accumulator->mLastAccumulator = mParentTimerData.mAccumulator; accumulator->mLastCaller = mParentTimerData.mTimeBlock;
// we are only tracking self time, so subtract our total time delta from parents // we are only tracking self time, so subtract our total time delta from parents
mParentTimerData.mChildTime += total_time; mParentTimerData.mChildTime += total_time;
......
...@@ -449,9 +449,8 @@ namespace LLTrace ...@@ -449,9 +449,8 @@ namespace LLTrace
U64 mChildTimeCounter, U64 mChildTimeCounter,
mTotalTimeCounter; mTotalTimeCounter;
U32 mCalls; U32 mCalls;
class TimeBlock* mBlock; // block associated with this accumulator
class TimeBlock* mParent; // last acknowledged parent of this time block class TimeBlock* mParent; // last acknowledged parent of this time block
TimeBlockAccumulator* mLastAccumulator; // used to bootstrap tree construction class TimeBlock* mLastCaller; // used to bootstrap tree construction
U16 mActiveCount; // number of timers with this ID active on stack 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 bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame
......
...@@ -43,16 +43,14 @@ ThreadRecorder::ThreadRecorder() ...@@ -43,16 +43,14 @@ ThreadRecorder::ThreadRecorder()
TimeBlock& root_time_block = TimeBlock::getRootTimeBlock(); TimeBlock& root_time_block = TimeBlock::getRootTimeBlock();
ThreadTimerStack* timer_stack = ThreadTimerStack::getInstance(); ThreadTimerStack* timer_stack = ThreadTimerStack::getInstance();
timer_stack->mTimeBlock = &root_time_block;
timer_stack->mActiveTimer = NULL;
mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size(); mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size();
mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes]; mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes];
mThreadRecording.start(); mThreadRecording.start();
timer_stack->mAccumulator = root_time_block.getPrimaryAccumulator();
timer_stack->mActiveTimer = NULL;
// initialize time block parent pointers // initialize time block parent pointers
for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances();
it != end_it; it != end_it;
...@@ -63,9 +61,7 @@ ThreadRecorder::ThreadRecorder() ...@@ -63,9 +61,7 @@ ThreadRecorder::ThreadRecorder()
tree_node.mBlock = &time_block; tree_node.mBlock = &time_block;
tree_node.mParent = &root_time_block; tree_node.mParent = &root_time_block;
TimeBlockAccumulator* accumulator = it->getPrimaryAccumulator(); it->getPrimaryAccumulator()->mParent = &root_time_block;
accumulator->mParent = &root_time_block;
accumulator->mBlock = &time_block;
} }
mRootTimer = new BlockTimer(root_time_block); mRootTimer = new BlockTimer(root_time_block);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment