diff options
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-x | indra/llcommon/lldate.cpp | 2 | ||||
-rwxr-xr-x | indra/llcommon/llfasttimer.cpp | 104 | ||||
-rwxr-xr-x | indra/llcommon/llfasttimer.h | 54 | ||||
-rwxr-xr-x | indra/llcommon/llmetricperformancetester.cpp | 4 | ||||
-rwxr-xr-x | indra/llcommon/llsdparam.cpp | 2 | ||||
-rwxr-xr-x | indra/llcommon/llsdparam.h | 2 | ||||
-rwxr-xr-x | indra/llcommon/llstring.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/lltrace.cpp | 6 | ||||
-rw-r--r-- | indra/llcommon/lltrace.h | 6 | ||||
-rw-r--r-- | indra/llcommon/lltraceaccumulators.h | 18 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.cpp | 44 | ||||
-rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 14 |
12 files changed, 146 insertions, 112 deletions
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index b32c3f6830..7a2a0869f4 100755 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -86,7 +86,7 @@ std::string LLDate::asRFC1123() const return toHTTPDateString (std::string ("%A, %d %b %Y %H:%M:%S GMT")); } -LLTrace::TimeBlock FT_DATE_FORMAT("Date Format"); +LLTrace::BlockTimerStatHandle FT_DATE_FORMAT("Date Format"); std::string LLDate::toHTTPDateString (std::string fmt) const { diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index c948e0ac85..361d800629 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -60,14 +60,14 @@ namespace LLTrace ////////////////////////////////////////////////////////////////////////////// // statics -bool TimeBlock::sLog = false; -std::string TimeBlock::sLogName = ""; -bool TimeBlock::sMetricLog = false; +bool BlockTimerStatHandle::sLog = false; +std::string BlockTimerStatHandle::sLogName = ""; +bool BlockTimerStatHandle::sMetricLog = false; #if LL_LINUX || LL_SOLARIS -U64 TimeBlock::sClockResolution = 1000000000; // Nanosecond resolution +U64 BlockTimerStatHandle::sClockResolution = 1000000000; // Nanosecond resolution #else -U64 TimeBlock::sClockResolution = 1000000; // Microsecond resolution +U64 BlockTimerStatHandle::sClockResolution = 1000000; // Microsecond resolution #endif static LLMutex* sLogLock = NULL; @@ -77,13 +77,13 @@ static std::queue<LLSD> sLogQueue; // FIXME: move these declarations to the relevant modules // helper functions -typedef LLTreeDFSPostIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_bottom_up_iterator_t; +typedef LLTreeDFSPostIter<BlockTimerStatHandle, BlockTimerStatHandle::child_const_iter> timer_tree_bottom_up_iterator_t; -static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(TimeBlock& id) +static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(BlockTimerStatHandle& id) { return timer_tree_bottom_up_iterator_t(&id, - boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), - boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); + boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), + boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1)); } static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() @@ -91,14 +91,14 @@ static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() return timer_tree_bottom_up_iterator_t(); } -typedef LLTreeDFSIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_dfs_iterator_t; +typedef LLTreeDFSIter<BlockTimerStatHandle, BlockTimerStatHandle::child_const_iter> timer_tree_dfs_iterator_t; -static timer_tree_dfs_iterator_t begin_timer_tree(TimeBlock& id) +static timer_tree_dfs_iterator_t begin_timer_tree(BlockTimerStatHandle& id) { return timer_tree_dfs_iterator_t(&id, - boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), - boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); + boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), + boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1)); } static timer_tree_dfs_iterator_t end_timer_tree() @@ -110,26 +110,26 @@ static timer_tree_dfs_iterator_t end_timer_tree() // sort child timers by name struct SortTimerByName { - bool operator()(const TimeBlock* i1, const TimeBlock* i2) + bool operator()(const BlockTimerStatHandle* i1, const BlockTimerStatHandle* i2) { return i1->getName() < i2->getName(); } }; -TimeBlock& TimeBlock::getRootTimeBlock() +BlockTimerStatHandle& BlockTimerStatHandle::getRootTimeBlock() { - static TimeBlock root_timer("root", NULL); + static BlockTimerStatHandle root_timer("root", NULL); return root_timer; } -void TimeBlock::pushLog(LLSD log) +void BlockTimerStatHandle::pushLog(LLSD log) { LLMutexLock lock(sLogLock); sLogQueue.push(log); } -void TimeBlock::setLogLock(LLMutex* lock) +void BlockTimerStatHandle::setLogLock(LLMutex* lock) { sLogLock = lock; } @@ -137,12 +137,12 @@ void TimeBlock::setLogLock(LLMutex* lock) //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 TimeBlock::countsPerSecond() +U64 BlockTimerStatHandle::countsPerSecond() { return sClockResolution; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 TimeBlock::countsPerSecond() +U64 BlockTimerStatHandle::countsPerSecond() { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz @@ -164,11 +164,11 @@ U64 TimeBlock::countsPerSecond() } #endif -TimeBlock::TimeBlock(const char* name, TimeBlock* parent) -: StatType<TimeBlockAccumulator>(name) +BlockTimerStatHandle::BlockTimerStatHandle(const char* name, const char* description) +: StatType<TimeBlockAccumulator>(name, description) {} -TimeBlockTreeNode& TimeBlock::getTreeNode() const +TimeBlockTreeNode& BlockTimerStatHandle::getTreeNode() const { TimeBlockTreeNode* nodep = LLTrace::get_thread_recorder()->getTimeBlockTreeNode(getIndex()); llassert(nodep); @@ -176,18 +176,18 @@ TimeBlockTreeNode& TimeBlock::getTreeNode() const } -void TimeBlock::bootstrapTimerTree() +void BlockTimerStatHandle::bootstrapTimerTree() { - for (LLInstanceTracker<TimeBlock>::instance_iter begin_it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(), it = begin_it; + for (BlockTimerStatHandle::instance_tracker_t::instance_iter begin_it = BlockTimerStatHandle::instance_tracker_t::beginInstances(), end_it = BlockTimerStatHandle::instance_tracker_t::endInstances(), it = begin_it; it != end_it; ++it) { - TimeBlock& timer = *it; - if (&timer == &TimeBlock::getRootTimeBlock()) continue; + BlockTimerStatHandle& timer = static_cast<BlockTimerStatHandle&>(*it); + if (&timer == &BlockTimerStatHandle::getRootTimeBlock()) continue; // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.getParent() == &TimeBlock::getRootTimeBlock()) + if (timer.getParent() == &BlockTimerStatHandle::getRootTimeBlock()) { TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); @@ -205,13 +205,13 @@ void TimeBlock::bootstrapTimerTree() // 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() +void BlockTimerStatHandle::incrementalUpdateTimerTree() { - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimeBlock()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimerStatHandle::getRootTimeBlock()); it != end_timer_tree_bottom_up(); ++it) { - TimeBlock* timerp = *it; + BlockTimerStatHandle* timerp = *it; // sort timers by time last called, so call graph makes sense TimeBlockTreeNode& tree_node = timerp->getTreeNode(); @@ -221,7 +221,7 @@ void TimeBlock::incrementalUpdateTimerTree() } // skip root timer - if (timerp != &TimeBlock::getRootTimeBlock()) + if (timerp != &BlockTimerStatHandle::getRootTimeBlock()) { TimeBlockAccumulator& accumulator = timerp->getCurrentAccumulator(); @@ -245,7 +245,7 @@ void TimeBlock::incrementalUpdateTimerTree() } -void TimeBlock::updateTimes() +void BlockTimerStatHandle::updateTimes() { // walk up stack of active timers and accumulate current time while leaving timing structures active BlockTimerStackRecord* stack_record = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance(); @@ -273,11 +273,11 @@ void TimeBlock::updateTimes() } } -static LLTrace::TimeBlock FTM_PROCESS_TIMES("Process FastTimer Times"); +static LLTrace::BlockTimerStatHandle FTM_PROCESS_TIMES("Process FastTimer Times"); // not thread safe, so only call on main thread //static -void TimeBlock::processTimes() +void BlockTimerStatHandle::processTimes() { LL_RECORD_BLOCK_TIME(FTM_PROCESS_TIMES); get_clock_count(); // good place to calculate clock frequency @@ -290,12 +290,12 @@ void TimeBlock::processTimes() updateTimes(); // reset for next frame - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), - end_it = LLInstanceTracker<TimeBlock>::endInstances(); + for (BlockTimerStatHandle::instance_tracker_t::instance_iter it = BlockTimerStatHandle::instance_tracker_t::beginInstances(), + end_it = BlockTimerStatHandle::instance_tracker_t::endInstances(); it != end_it; ++it) { - TimeBlock& timer = *it; + BlockTimerStatHandle& timer = static_cast<BlockTimerStatHandle&>(*it); TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); accumulator.mLastCaller = NULL; @@ -303,23 +303,23 @@ void TimeBlock::processTimes() } } -std::vector<TimeBlock*>::iterator TimeBlock::beginChildren() +std::vector<BlockTimerStatHandle*>::iterator BlockTimerStatHandle::beginChildren() { return getTreeNode().mChildren.begin(); } -std::vector<TimeBlock*>::iterator TimeBlock::endChildren() +std::vector<BlockTimerStatHandle*>::iterator BlockTimerStatHandle::endChildren() { return getTreeNode().mChildren.end(); } -std::vector<TimeBlock*>& TimeBlock::getChildren() +std::vector<BlockTimerStatHandle*>& BlockTimerStatHandle::getChildren() { return getTreeNode().mChildren; } // static -void TimeBlock::logStats() +void BlockTimerStatHandle::logStats() { // get ready for next frame if (sLog) @@ -340,12 +340,12 @@ void TimeBlock::logStats() LLSD sd; { - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), - end_it = LLInstanceTracker<TimeBlock>::endInstances(); + for (BlockTimerStatHandle::instance_tracker_t::instance_iter it = BlockTimerStatHandle::instance_tracker_t::beginInstances(), + end_it = BlockTimerStatHandle::instance_tracker_t::endInstances(); it != end_it; ++it) { - TimeBlock& timer = *it; + BlockTimerStatHandle& timer = static_cast<BlockTimerStatHandle&>(*it); LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecording().getSum(timer).value()); sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecording().getSum(timer.callCount())); @@ -368,17 +368,17 @@ void TimeBlock::logStats() } //static -void TimeBlock::dumpCurTimes() +void BlockTimerStatHandle::dumpCurTimes() { LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimeBlock()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(BlockTimerStatHandle::getRootTimeBlock()); it != end_timer_tree(); ++it) { - TimeBlock* timerp = (*it); + BlockTimerStatHandle* timerp = (*it); F64Seconds total_time = last_frame_recording.getSum(*timerp); U32 num_calls = last_frame_recording.getSum(timerp->callCount()); @@ -386,7 +386,7 @@ void TimeBlock::dumpCurTimes() if (total_time < F32Milliseconds(0.1f)) continue; std::ostringstream out_str; - TimeBlock* parent_timerp = timerp; + BlockTimerStatHandle* parent_timerp = timerp; while(parent_timerp && parent_timerp != parent_timerp->getParent()) { out_str << "\t"; @@ -402,7 +402,7 @@ void TimeBlock::dumpCurTimes() } //static -void TimeBlock::writeLog(std::ostream& os) +void BlockTimerStatHandle::writeLog(std::ostream& os) { while (!sLogQueue.empty()) { @@ -458,9 +458,9 @@ void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other ) F64Seconds BlockTimer::getElapsedTime() { - U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; + U64 total_time = BlockTimerStatHandle::getCPUClockCount64() - mStartTime; - return F64Seconds((F64)total_time / (F64)TimeBlock::countsPerSecond()); + return F64Seconds((F64)total_time / (F64)BlockTimerStatHandle::countsPerSecond()); } diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 1266d87f08..faa622628b 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -30,36 +30,34 @@ #include "llinstancetracker.h" #include "lltrace.h" -#define FAST_TIMER_ON 1 +#define LL_FAST_TIMER_ON 1 #define LL_FASTTIMER_USE_RDTSC 1 -class LLMutex; - #define LL_RECORD_BLOCK_TIME(timer_stat) const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__); namespace LLTrace { - -class BlockTimer timeThisBlock(class TimeBlock& timer); +// use to create blocktimer rvalue to be captured in a reference so that the BlockTimer lives to the end of the block. +class BlockTimer timeThisBlock(class BlockTimerStatHandle& timer); class BlockTimer { public: typedef BlockTimer self_t; - typedef class TimeBlock DeclareTimer; + typedef class BlockTimerStatHandle DeclareTimer; ~BlockTimer(); F64Seconds getElapsedTime(); private: - friend class TimeBlock; + friend class BlockTimerStatHandle; // FIXME: this friendship exists so that each thread can instantiate a root timer, // which could be a derived class with a public constructor instead, possibly friend class ThreadRecorder; - friend BlockTimer timeThisBlock(TimeBlock&); + friend BlockTimer timeThisBlock(BlockTimerStatHandle&); - BlockTimer(TimeBlock& timer); + BlockTimer(BlockTimerStatHandle& timer); #if !defined(MSC_VER) || MSC_VER < 1700 // Visual Studio 2010 has a bug where capturing an object returned by value // into a local reference requires access to the copy constructor at the call site. @@ -79,28 +77,28 @@ private: // (This is most easily done using the macro LL_RECORD_BLOCK_TIME) // Otherwise, it would be possible to store a BlockTimer on the heap, resulting in non-nested lifetimes, // which would break the invariants of the timing hierarchy logic -LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer) +LL_FORCE_INLINE class BlockTimer timeThisBlock(class BlockTimerStatHandle& timer) { return BlockTimer(timer); } // stores a "named" timer instance to be reused via multiple BlockTimer stack instances -class TimeBlock -: public StatType<TimeBlockAccumulator>, - public LLInstanceTracker<TimeBlock> +class BlockTimerStatHandle +: public StatType<TimeBlockAccumulator> { public: - TimeBlock(const char* name, TimeBlock* parent = &getRootTimeBlock()); + typedef LLInstanceTracker<StatType<TimeBlockAccumulator>, std::string> instance_tracker_t; + BlockTimerStatHandle(const char* name, const char* description = ""); TimeBlockTreeNode& getTreeNode() const; - TimeBlock* getParent() const { return getTreeNode().getParent(); } - void setParent(TimeBlock* parent) { getTreeNode().setParent(parent); } + BlockTimerStatHandle* getParent() const { return getTreeNode().getParent(); } + void setParent(BlockTimerStatHandle* parent) { getTreeNode().setParent(parent); } - typedef std::vector<TimeBlock*>::iterator child_iter; - typedef std::vector<TimeBlock*>::const_iterator child_const_iter; + typedef std::vector<BlockTimerStatHandle*>::iterator child_iter; + typedef std::vector<BlockTimerStatHandle*>::const_iterator child_const_iter; child_iter beginChildren(); child_iter endChildren(); - std::vector<TimeBlock*>& getChildren(); + std::vector<BlockTimerStatHandle*>& getChildren(); StatType<TimeBlockAccumulator::CallCountFacet>& callCount() { @@ -112,9 +110,9 @@ public: return static_cast<StatType<TimeBlockAccumulator::SelfTimeFacet>&>(*(StatType<TimeBlockAccumulator>*)this); } - static TimeBlock& getRootTimeBlock(); + static BlockTimerStatHandle& getRootTimeBlock(); static void pushLog(LLSD sd); - static void setLogLock(LLMutex* mutex); + static void setLogLock(class LLMutex* mutex); static void writeLog(std::ostream& os); static void updateTimes(); @@ -144,14 +142,14 @@ public: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 TimeBlock::getCPUClockCount32() + //inline U32 BlockTimerStatHandle::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 TimeBlock::getCPUClockCount64() + //inline U64 BlockTimerStatHandle::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -279,9 +277,9 @@ public: static U64 sClockResolution; }; -LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) +LL_FORCE_INLINE BlockTimer::BlockTimer(BlockTimerStatHandle& timer) { -#if FAST_TIMER_ON +#if LL_FAST_TIMER_ON BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance(); if (!cur_timer_data) return; TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); @@ -296,14 +294,14 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; - mStartTime = TimeBlock::getCPUClockCount64(); + mStartTime = BlockTimerStatHandle::getCPUClockCount64(); #endif } LL_FORCE_INLINE BlockTimer::~BlockTimer() { -#if FAST_TIMER_ON - U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; +#if LL_FAST_TIMER_ON + U64 total_time = BlockTimerStatHandle::getCPUClockCount64() - mStartTime; BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance(); if (!cur_timer_data) return; diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index 88287e5786..7963485456 100755 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -91,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s // Return TRUE if this metric is requested or if the general default "catch all" metric is requested BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name) { - return (LLTrace::TimeBlock::sMetricLog && ((LLTrace::TimeBlock::sLogName == name) || (LLTrace::TimeBlock::sLogName == DEFAULT_METRIC_NAME))); + return (LLTrace::BlockTimerStatHandle::sMetricLog && ((LLTrace::BlockTimerStatHandle::sLogName == name) || (LLTrace::BlockTimerStatHandle::sLogName == DEFAULT_METRIC_NAME))); } /*static*/ @@ -194,7 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd) void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd) { - LLTrace::TimeBlock::pushLog(*sd); + LLTrace::BlockTimerStatHandle::pushLog(*sd); } void LLMetricPerformanceTesterBasic::outputTestResults() diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 371bd49c04..2e7b46f885 100755 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -37,7 +37,7 @@ static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs; static const LLSD NO_VALUE_MARKER; -LLTrace::TimeBlock FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion"); +LLTrace::BlockTimerStatHandle FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion"); // // LLParamSDParser diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 47ec6414dd..1542f95e68 100755 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -110,7 +110,7 @@ private: }; -extern LL_COMMON_API LLTrace::TimeBlock FTM_SD_PARAM_ADAPTOR; +extern LL_COMMON_API LLTrace::BlockTimerStatHandle FTM_SD_PARAM_ADAPTOR; template<typename T> class LLSDParamAdapter : public T { diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index a4b1d2ede3..76979f29f6 100755 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -36,7 +36,7 @@ #include <winnls.h> // for WideCharToMultiByte #endif -LLTrace::TimeBlock FT_STRING_FORMAT("String Format"); +LLTrace::BlockTimerStatHandle FT_STRING_FORMAT("String Format"); std::string ll_safe_string(const char* in) diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 1ad31cacfe..5c4b7b5bb4 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -59,7 +59,7 @@ TimeBlockTreeNode::TimeBlockTreeNode() mCollapsed(true) {} -void TimeBlockTreeNode::setParent( TimeBlock* parent ) +void TimeBlockTreeNode::setParent( BlockTimerStatHandle* parent ) { llassert_always(parent != mBlock); llassert_always(parent != NULL); @@ -69,8 +69,8 @@ void TimeBlockTreeNode::setParent( TimeBlock* parent ) if (mParent) { - std::vector<TimeBlock*>& children = mParent->getChildren(); - std::vector<TimeBlock*>::iterator found_it = std::find(children.begin(), children.end(), mBlock); + std::vector<BlockTimerStatHandle*>& children = mParent->getChildren(); + std::vector<BlockTimerStatHandle*>::iterator found_it = std::find(children.begin(), children.end(), mBlock); if (found_it != children.end()) { children.erase(found_it); diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 2f4390e4d1..cbdf4e4a6f 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -72,7 +72,7 @@ class StatType public LLInstanceTracker<StatType<ACCUMULATOR>, std::string> { public: - StatType(const char* name, const char* description = NULL) + StatType(const char* name, const char* description) : LLInstanceTracker<StatType<ACCUMULATOR>, std::string>(name), StatBase(name, description), mAccumulatorIndex(AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot()) @@ -210,8 +210,8 @@ class MemStatHandle : public StatType<MemAccumulator> { public: typedef StatType<MemAccumulator> stat_t; - MemStatHandle(const char* name) - : stat_t(name) + MemStatHandle(const char* name, const char* description = "") + : stat_t(name, description) { mName = name; } diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 77370629d3..c30cc9a107 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -460,26 +460,26 @@ namespace LLTrace U64 mTotalTimeCounter, mSelfTimeCounter; S32 mCalls; - class TimeBlock* mParent; // last acknowledged parent of this time block - class TimeBlock* mLastCaller; // used to bootstrap tree construction + class BlockTimerStatHandle* mParent; // last acknowledged parent of this time block + class BlockTimerStatHandle* mLastCaller; // 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 }; - class TimeBlock; + class BlockTimerStatHandle; class TimeBlockTreeNode { public: TimeBlockTreeNode(); - void setParent(TimeBlock* parent); - TimeBlock* getParent() { return mParent; } + void setParent(BlockTimerStatHandle* parent); + BlockTimerStatHandle* getParent() { return mParent; } - TimeBlock* mBlock; - TimeBlock* mParent; - std::vector<TimeBlock*> mChildren; + BlockTimerStatHandle* mBlock; + BlockTimerStatHandle* mParent; + std::vector<BlockTimerStatHandle*> mChildren; bool mCollapsed; bool mNeedsSorting; }; @@ -487,7 +487,7 @@ namespace LLTrace struct BlockTimerStackRecord { class BlockTimer* mActiveTimer; - class TimeBlock* mTimeBlock; + class BlockTimerStatHandle* mTimeBlock; U64 mChildTime; }; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 87083eee96..2b2b55f614 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -139,192 +139,228 @@ void Recording::appendRecording( Recording& other ) F64Seconds Recording::getSum(const StatType<TimeBlockAccumulator>& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / (F64)LLTrace::TimeBlock::countsPerSecond()); + / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } F64Seconds Recording::getSum(const StatType<TimeBlockAccumulator::SelfTimeFacet>& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); + return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } S32 Recording::getSum(const StatType<TimeBlockAccumulator::CallCountFacet>& stat) { + llassert(!isStarted()); return mBuffers->mStackTimers[stat.getIndex()].mCalls; } F64Seconds Recording::getPerSec(const StatType<TimeBlockAccumulator>& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F64Seconds Recording::getPerSec(const StatType<TimeBlockAccumulator::SelfTimeFacet>& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const StatType<TimeBlockAccumulator::CallCountFacet>& stat) { + llassert(!isStarted()); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } bool Recording::hasValue(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } F64Kilobytes Recording::getMin(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } F64Kilobytes Recording::getMean(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } F64Kilobytes Recording::getMax(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } F64Kilobytes Recording::getStandardDeviation(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } F64Kilobytes Recording::getLastValue(const StatType<MemAccumulator>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } F64Kilobytes Recording::getSum(const StatType<MemAccumulator::AllocationFacet>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType<MemAccumulator::AllocationFacet>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType<MemAccumulator::AllocationFacet>& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const StatType<MemAccumulator::DeallocationFacet>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType<MemAccumulator::DeallocationFacet>& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType<MemAccumulator::DeallocationFacet>& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } F64 Recording::getSum( const StatType<CountAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const StatType<CountAccumulator>& stat ) { + llassert(!isStarted()); F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } S32 Recording::getSampleCount( const StatType<CountAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType<SampleAccumulator>& stat) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType<SampleAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType<EventAccumulator>& stat) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType<EventAccumulator>& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 9dac4f6771..20e8a0bbaa 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -50,7 +50,7 @@ void ThreadRecorder::init() LLThreadLocalSingletonPointer<BlockTimerStackRecord>::setInstance(&mBlockTimerStackRecord); //NB: the ordering of initialization in this function is very fragile due to a large number of implicit dependencies set_thread_recorder(this); - TimeBlock& root_time_block = TimeBlock::getRootTimeBlock(); + BlockTimerStatHandle& root_time_block = BlockTimerStatHandle::getRootTimeBlock(); BlockTimerStackRecord* timer_stack = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance(); timer_stack->mTimeBlock = &root_time_block; @@ -63,11 +63,11 @@ void ThreadRecorder::init() activate(&mThreadRecordingBuffers); // initialize time block parent pointers - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); + for (BlockTimerStatHandle::instance_tracker_t::instance_iter it = BlockTimerStatHandle::instance_tracker_t::beginInstances(), end_it = BlockTimerStatHandle::instance_tracker_t::endInstances(); it != end_it; ++it) { - TimeBlock& time_block = *it; + BlockTimerStatHandle& time_block = static_cast<BlockTimerStatHandle&>(*it); TimeBlockTreeNode& tree_node = mTimeBlockTreeNodes[it->getIndex()]; tree_node.mBlock = &time_block; tree_node.mParent = &root_time_block; @@ -78,7 +78,7 @@ void ThreadRecorder::init() mRootTimer = new BlockTimer(root_time_block); timer_stack->mActiveTimer = mRootTimer; - TimeBlock::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1; + BlockTimerStatHandle::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1; claim_alloc(gTraceMemStat, this); claim_alloc(gTraceMemStat, sizeof(BlockTimer)); @@ -138,7 +138,7 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand { AccumulatorBufferGroup& prev_active_recording = mActiveRecordings.back()->mPartialRecording; prev_active_recording.sync(); - TimeBlock::updateTimes(); + BlockTimerStatHandle::updateTimes(); prev_active_recording.handOffTo(active_recording->mPartialRecording); } mActiveRecordings.push_back(active_recording); @@ -151,7 +151,7 @@ ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::bringUpToDate( if (mActiveRecordings.empty()) return mActiveRecordings.end(); mActiveRecordings.back()->mPartialRecording.sync(); - TimeBlock::updateTimes(); + BlockTimerStatHandle::updateTimes(); active_recording_list_t::reverse_iterator it, end_it; for (it = mActiveRecordings.rbegin(), end_it = mActiveRecordings.rend(); @@ -265,7 +265,7 @@ void ThreadRecorder::pushToParent() } -static LLTrace::TimeBlock FTM_PULL_TRACE_DATA_FROM_CHILDREN("Pull child thread trace data"); +static LLTrace::BlockTimerStatHandle FTM_PULL_TRACE_DATA_FROM_CHILDREN("Pull child thread trace data"); void ThreadRecorder::pullFromChildren() { |