summaryrefslogtreecommitdiff
path: root/indra/llcommon/llfasttimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llfasttimer.cpp')
-rwxr-xr-xindra/llcommon/llfasttimer.cpp103
1 files changed, 60 insertions, 43 deletions
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index dfc72bd2ce..becfa9c288 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -118,7 +118,7 @@ struct SortTimerByName
TimeBlock& TimeBlock::getRootTimeBlock()
{
- static TimeBlock root_timer("root", true, NULL);
+ static TimeBlock root_timer("root", NULL);
return root_timer;
}
@@ -146,8 +146,8 @@ U64 TimeBlock::countsPerSecond()
{
#if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS
//getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
- static LLUnit<LLUnits::Hertz, U64> sCPUClockFrequency = LLProcessorInfo().getCPUFrequency();
-
+ static LLUnit<U64, LLUnits::Hertz> sCPUClockFrequency = LLProcessorInfo().getCPUFrequency();
+ return sCPUClockFrequency.value();
#else
// If we're not using RDTSC, each fasttimer tick is just a performance counter tick.
// Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency())
@@ -159,16 +159,14 @@ U64 TimeBlock::countsPerSecond()
QueryPerformanceFrequency((LARGE_INTEGER*)&sCPUClockFrequency);
firstcall = false;
}
-#endif
return sCPUClockFrequency.value();
+#endif
}
#endif
-TimeBlock::TimeBlock(const char* name, bool open, TimeBlock* parent)
-: TraceType<TimeBlockAccumulator>(name),
- mCollapsed(true)
+TimeBlock::TimeBlock(const char* name, TimeBlock* parent)
+: TraceType<TimeBlockAccumulator>(name)
{
- setCollapsed(!open);
}
TimeBlockTreeNode& TimeBlock::getTreeNode() const
@@ -178,43 +176,38 @@ TimeBlockTreeNode& TimeBlock::getTreeNode() const
return *nodep;
}
-static LLFastTimer::DeclareTimer FTM_PROCESS_TIMES("Process FastTimer Times");
-// not thread safe, so only call on main thread
-//static
-void TimeBlock::processTimes()
+void TimeBlock::bootstrapTimerTree()
{
- LLFastTimer _(FTM_PROCESS_TIMES);
- get_clock_count(); // good place to calculate clock frequency
- U64 cur_time = getCPUClockCount64();
-
- // set up initial tree
for (LLInstanceTracker<TimeBlock>::instance_iter begin_it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(), it = begin_it;
it != end_it;
++it)
{
TimeBlock& timer = *it;
if (&timer == &TimeBlock::getRootTimeBlock()) continue;
-
+
// bootstrap tree construction by attaching to last timer to be on stack
// when this timer was called
if (timer.getParent() == &TimeBlock::getRootTimeBlock())
{
TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator();
-
+
if (accumulator->mLastCaller)
{
timer.setParent(accumulator->mLastCaller);
accumulator->mParent = accumulator->mLastCaller;
}
- // 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;
}
}
+}
- // bump timers up tree if they have been flagged as being in the wrong place
- // do this in a bottom up order to promote descendants first before promoting ancestors
- // this preserves partial order derived from current frame's observations
+// bump timers up tree if they have been flagged as being in the wrong place
+// do this in a bottom up order to promote descendants first before promoting ancestors
+// this preserves partial order derived from current frame's observations
+void TimeBlock::incrementalUpdateTimerTree()
+{
for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimeBlock());
it != end_timer_tree_bottom_up();
++it)
@@ -240,27 +233,35 @@ void TimeBlock::processTimes()
LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() <<
" to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL;
timerp->setParent(timerp->getParent()->getParent());
- accumulator->mParent = timerp->getParent();
- accumulator->mMoveUpTree = false;
+ accumulator->mParent = timerp->getParent();
+ accumulator->mMoveUpTree = false;
// don't bubble up any ancestors until descendants are done bubbling up
- // as ancestors may call this timer only on certain paths, so we want to resolve
- // child-most block locations before their parents
+ // as ancestors may call this timer only on certain paths, so we want to resolve
+ // child-most block locations before their parents
it.skipAncestors();
}
}
}
+}
+
+
+void TimeBlock::updateTimes()
+{
+ U64 cur_time = getCPUClockCount64();
// walk up stack of active timers and accumulate current time while leaving timing structures active
- BlockTimerStackRecord* stack_record = ThreadTimerStack::getInstance();
- BlockTimer* cur_timer = stack_record->mActiveTimer;
- TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
+ BlockTimerStackRecord* stack_record = ThreadTimerStack::getInstance();
+ BlockTimer* cur_timer = stack_record->mActiveTimer;
+ TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
while(cur_timer
&& cur_timer->mParentTimerData.mActiveTimer != cur_timer) // root defined by parent pointing to self
{
U64 cumulative_time_delta = cur_time - cur_timer->mStartTime;
- accumulator->mTotalTimeCounter += cumulative_time_delta - (accumulator->mTotalTimeCounter - cur_timer->mBlockStartTotalTimeCounter);
+ accumulator->mTotalTimeCounter += cumulative_time_delta
+ - (accumulator->mTotalTimeCounter
+ - cur_timer->mBlockStartTotalTimeCounter);
accumulator->mSelfTimeCounter += cumulative_time_delta - stack_record->mChildTime;
stack_record->mChildTime = 0;
@@ -268,11 +269,28 @@ void TimeBlock::processTimes()
cur_timer->mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter;
stack_record = &cur_timer->mParentTimerData;
- accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
- cur_timer = stack_record->mActiveTimer;
+ accumulator = stack_record->mTimeBlock->getPrimaryAccumulator();
+ cur_timer = stack_record->mActiveTimer;
stack_record->mChildTime += cumulative_time_delta;
}
+}
+
+static LLFastTimer::DeclareTimer FTM_PROCESS_TIMES("Process FastTimer Times");
+
+// not thread safe, so only call on main thread
+//static
+void TimeBlock::processTimes()
+{
+ LLFastTimer _(FTM_PROCESS_TIMES);
+ get_clock_count(); // good place to calculate clock frequency
+
+ // set up initial tree
+ bootstrapTimerTree();
+
+ incrementalUpdateTimerTree();
+
+ updateTimes();
// reset for next frame
for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(),
@@ -288,14 +306,13 @@ void TimeBlock::processTimes()
}
}
-
std::vector<TimeBlock*>::iterator TimeBlock::beginChildren()
- {
+{
return getTreeNode().mChildren.begin();
- }
+}
std::vector<TimeBlock*>::iterator TimeBlock::endChildren()
- {
+{
return getTreeNode().mChildren.end();
}
@@ -318,11 +335,11 @@ void TimeBlock::logStats()
LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL;
LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL;
LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL;
- LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL;
+ LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<F64, LLUnits::Hertz>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL;
}
call_count++;
- LLUnit<LLUnits::Seconds, F64> total_time(0);
+ LLUnit<F64, LLUnits::Seconds> total_time(0);
LLSD sd;
{
@@ -365,11 +382,11 @@ void TimeBlock::dumpCurTimes()
++it)
{
TimeBlock* timerp = (*it);
- LLUnit<LLUnits::Seconds, F64> total_time_ms = last_frame_recording.getSum(*timerp);
+ LLUnit<F64, LLUnits::Seconds> total_time = last_frame_recording.getSum(*timerp);
U32 num_calls = last_frame_recording.getSum(timerp->callCount());
// Don't bother with really brief times, keep output concise
- if (total_time_ms < 0.1) continue;
+ if (total_time < LLUnit<F32, LLUnits::Milliseconds>(0.1)) continue;
std::ostringstream out_str;
TimeBlock* parent_timerp = timerp;
@@ -380,7 +397,7 @@ void TimeBlock::dumpCurTimes()
}
out_str << timerp->getName() << " "
- << std::setprecision(3) << total_time_ms.as<LLUnits::Milliseconds>().value() << " ms, "
+ << std::setprecision(3) << total_time.getAs<LLUnits::Milliseconds>() << " ms, "
<< num_calls << " calls";
llinfos << out_str.str() << llendl;
@@ -449,7 +466,7 @@ void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other )
}
}
-LLUnit<LLUnits::Seconds, F64> BlockTimer::getElapsedTime()
+LLUnit<F64, LLUnits::Seconds> BlockTimer::getElapsedTime()
{
U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime;