From 62fcbb063a191fa4789145c3937e7bef6ce544bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 5 Sep 2012 18:49:28 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages first pass at LLTrace framework --- indra/llcommon/llfasttimer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..061a37ae31 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -45,18 +45,17 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: - class NamedTimer; - struct LL_COMMON_API FrameState { FrameState(); void setNamedTimer(NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; + U32 mTotalTimeCounter; U32 mCalls; FrameState* mParent; // info for caller timer FrameState* mLastCaller; // used to bootstrap tree construction - NamedTimer* mTimer; + class NamedTimer* mTimer; 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 }; @@ -120,7 +119,8 @@ public: std::string mName; - U32 mTotalTimeCounter; + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; U32 mCountAverage; U32 mCallAverage; @@ -186,6 +186,7 @@ public: U32 total_time = getCPUClockCount32() - mStartTime; frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + frame_state->mTotalTimeCounter += total_time; frame_state->mActiveCount--; // store last caller to bootstrap tree creation -- cgit v1.2.3 From 6814906fec95aeb90dbc99605f74f241a72af12b Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 5 Sep 2012 18:54:26 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages build fix --- indra/llcommon/llfasttimer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 061a37ae31..4660fad5e3 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -45,10 +45,12 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: + class NamedTimer; + struct LL_COMMON_API FrameState { FrameState(); - void setNamedTimer(NamedTimer* timerp) { mTimer = timerp; } + void setNamedTimer(class NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; U32 mTotalTimeCounter; @@ -152,13 +154,12 @@ public: }; public: - LLFastTimer(LLFastTimer::FrameState* state); + //LLFastTimer(LLFastTimer::FrameState* state); LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - : mFrameState(&timer.mFrameState) { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; + LLFastTimer::FrameState* frame_state = &timer.mFrameState; mStartTime = getCPUClockCount32(); frame_state->mActiveCount++; @@ -182,7 +183,7 @@ public: LL_FORCE_INLINE ~LLFastTimer() { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; + LLFastTimer::FrameState* frame_state = LLFastTimer::sCurTimerData.mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; @@ -380,7 +381,6 @@ private: static U64 sLastFrameTime; U32 mStartTime; - LLFastTimer::FrameState* mFrameState; LLFastTimer::CurTimerData mLastTimerData; }; -- cgit v1.2.3 From a3e3e8b4ccd96e98da73acf1c584bbfa5a8b2b56 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Nov 2012 19:08:14 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system simplified llfasttimer code down to 2 classes llunit unit conversion now done in floating point or 64 bit integer precision, depending on source type --- indra/llcommon/llfasttimer.h | 121 +++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 78 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4660fad5e3..31872e4e65 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -30,7 +30,6 @@ #include "llinstancetracker.h" #define FAST_TIMER_ON 1 -#define DEBUG_FAST_TIMER_THREADS 1 class LLMutex; @@ -45,64 +44,53 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: - class NamedTimer; - + class DeclareTimer; struct LL_COMMON_API FrameState { FrameState(); - void setNamedTimer(class NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; U32 mTotalTimeCounter; U32 mCalls; - FrameState* mParent; // info for caller timer - FrameState* mLastCaller; // used to bootstrap tree construction - class NamedTimer* mTimer; + DeclareTimer* 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 }; // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances - class LL_COMMON_API NamedTimer - : public LLInstanceTracker + class LL_COMMON_API DeclareTimer + : public LLInstanceTracker { - friend class DeclareTimer; public: - ~NamedTimer(); + DeclareTimer(const std::string& name, bool open = false, DeclareTimer* parent = &getRootTimer()); + ~DeclareTimer(); enum { HISTORY_NUM = 300 }; const std::string& getName() const { return mName; } - NamedTimer* getParent() const { return mParent; } - void setParent(NamedTimer* parent); + DeclareTimer* getParent() const { return mParent; } + void setParent(DeclareTimer* parent); S32 getDepth(); - std::string getToolTip(S32 history_index = -1); - typedef std::vector::const_iterator child_const_iter; + typedef std::vector::const_iterator child_const_iter; child_const_iter beginChildren(); child_const_iter endChildren(); - std::vector& getChildren(); + std::vector& getChildren(); - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } + U32 getCallAverage() const { return mCallAverage; } U32 getHistoricalCount(S32 history_index = 0) const; U32 getHistoricalCalls(S32 history_index = 0) const; - void setFrameState(FrameState* state) { mFrameState = state; state->setNamedTimer(this); } - FrameState& getFrameState() const; + static DeclareTimer& getRootTimer(); private: friend class LLFastTimer; - friend class NamedTimerFactory; - // - // methods - // - NamedTimer(const std::string& name); // recursive call to gather total time from children static void accumulateTimings(); @@ -117,82 +105,62 @@ public: // // members // - FrameState* mFrameState; + U32 mSelfTimeCounter; + U32 mTotalTimeCounter; + U32 mCalls; + DeclareTimer* 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 - std::string mName; + std::string mName; - // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; + // sum of recored self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; - U32 mCountAverage; - U32 mCallAverage; + U32 mCountAverage; + U32 mCallAverage; - U32* mCountHistory; - U32* mCallHistory; + U32* mCountHistory; + U32* mCallHistory; // tree structure - NamedTimer* mParent; // NamedTimer of caller(parent) - std::vector mChildren; + DeclareTimer* mParent; // DeclareTimer of caller(parent) + std::vector mChildren; bool mCollapsed; // don't show children bool mNeedsSorting; // sort children whenever child added }; - // used to statically declare a new named timer - class LL_COMMON_API DeclareTimer - : public LLInstanceTracker - { - friend class LLFastTimer; - public: - DeclareTimer(const std::string& name, bool open); - DeclareTimer(const std::string& name); - - NamedTimer& getNamedTimer() { return mTimer; } - - private: - FrameState mFrameState; - NamedTimer& mTimer; - }; - public: - //LLFastTimer(LLFastTimer::FrameState* state); - LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = &timer.mFrameState; mStartTime = getCPUClockCount32(); - frame_state->mActiveCount++; - frame_state->mCalls++; + timer.mActiveCount++; + timer.mCalls++; // keep current parent as long as it is active when we are - frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); + timer.mMoveUpTree |= (timer.mParent->mActiveCount == 0); LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; mLastTimerData = *cur_timer_data; cur_timer_data->mCurTimer = this; - cur_timer_data->mFrameState = frame_state; + cur_timer_data->mTimerData = &timer; cur_timer_data->mChildTime = 0; -#endif -#if DEBUG_FAST_TIMER_THREADS -#if !LL_RELEASE - assert_main_thread(); -#endif #endif } LL_FORCE_INLINE ~LLFastTimer() { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = LLFastTimer::sCurTimerData.mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; - - frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; - frame_state->mTotalTimeCounter += total_time; - frame_state->mActiveCount--; + DeclareTimer* timer_data = LLFastTimer::sCurTimerData.mTimerData; + timer_data->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + timer_data->mTotalTimeCounter += total_time; + timer_data->mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - frame_state->mLastCaller = mLastTimerData.mFrameState; + timer_data->mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; @@ -225,12 +193,11 @@ public: static S32 getCurFrameIndex() { return sCurFrameIndex; } static void writeLog(std::ostream& os); - static const NamedTimer* getTimerByName(const std::string& name); struct CurTimerData { LLFastTimer* mCurTimer; - FrameState* mFrameState; + DeclareTimer* mTimerData; U32 mChildTime; }; static CurTimerData sCurTimerData; @@ -374,15 +341,13 @@ private: #endif - static U64 sClockResolution; - - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; - static U64 sLastFrameTime; + static U64 sClockResolution; + static S32 sCurFrameIndex; + static S32 sLastFrameIndex; + static U64 sLastFrameTime; U32 mStartTime; LLFastTimer::CurTimerData mLastTimerData; - }; typedef class LLFastTimer LLFastTimer; -- cgit v1.2.3 From c76ed72c609b80b08df6cebd68274c9da6d3de2c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Nov 2012 19:12:20 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed remnants of LLFastTimer::FrameState --- indra/llcommon/llfasttimer.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 31872e4e65..40c2af34e8 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,25 +38,9 @@ class LLMutex; #define LL_FASTTIMER_USE_RDTSC 1 - -LL_COMMON_API void assert_main_thread(); - class LL_COMMON_API LLFastTimer { public: - class DeclareTimer; - struct LL_COMMON_API FrameState - { - FrameState(); - - U32 mSelfTimeCounter; - U32 mTotalTimeCounter; - U32 mCalls; - DeclareTimer* 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 - }; - // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances class LL_COMMON_API DeclareTimer : public LLInstanceTracker -- cgit v1.2.3 From 67ec47e6da389661934ed2ddfa55ca58455fa7e5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 13 Nov 2012 17:10:10 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system moving fast timers into lltrace namespace and accumulation system --- indra/llcommon/llfasttimer.h | 268 +++++++++++++++++++++++-------------------- 1 file changed, 142 insertions(+), 126 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 40c2af34e8..f5e6d874a2 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -33,131 +33,26 @@ class LLMutex; -#include -#include "llsd.h" +#include "lltrace.h" #define LL_FASTTIMER_USE_RDTSC 1 -class LL_COMMON_API LLFastTimer +namespace LLTrace { -public: - // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances - class LL_COMMON_API DeclareTimer - : public LLInstanceTracker - { - public: - DeclareTimer(const std::string& name, bool open = false, DeclareTimer* parent = &getRootTimer()); - ~DeclareTimer(); - - enum { HISTORY_NUM = 300 }; - - const std::string& getName() const { return mName; } - DeclareTimer* getParent() const { return mParent; } - void setParent(DeclareTimer* parent); - S32 getDepth(); - - typedef std::vector::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); - std::vector& getChildren(); - - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U32 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; - - static DeclareTimer& getRootTimer(); - - private: - friend class LLFastTimer; - - // recursive call to gather total time from children - static void accumulateTimings(); - - // updates cumulative times and hierarchy, - // can be called multiple times in a frame, at any point - static void processTimes(); - - static void buildHierarchy(); - static void resetFrame(); - static void reset(); - - // - // members - // - U32 mSelfTimeCounter; - U32 mTotalTimeCounter; - U32 mCalls; - DeclareTimer* 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 - - std::string mName; - - // sum of recored self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; - - U32 mCountAverage; - U32 mCallAverage; - - U32* mCountHistory; - U32* mCallHistory; - - // tree structure - DeclareTimer* mParent; // DeclareTimer of caller(parent) - std::vector mChildren; - bool mCollapsed; // don't show children - bool mNeedsSorting; // sort children whenever child added - }; +class Time +{ public: - LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - { -#if FAST_TIMER_ON - mStartTime = getCPUClockCount32(); - - timer.mActiveCount++; - timer.mCalls++; - // keep current parent as long as it is active when we are - timer.mMoveUpTree |= (timer.mParent->mActiveCount == 0); - - LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; - mLastTimerData = *cur_timer_data; - cur_timer_data->mCurTimer = this; - cur_timer_data->mTimerData = &timer; - cur_timer_data->mChildTime = 0; -#endif - } - - LL_FORCE_INLINE ~LLFastTimer() - { -#if FAST_TIMER_ON - U32 total_time = getCPUClockCount32() - mStartTime; - DeclareTimer* timer_data = LLFastTimer::sCurTimerData.mTimerData; - timer_data->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; - timer_data->mTotalTimeCounter += total_time; - timer_data->mActiveCount--; - - // store last caller to bootstrap tree creation - // do this in the destructor in case of recursion to get topmost caller - timer_data->mLastCaller = mLastTimerData.mTimerData; - - // we are only tracking self time, so subtract our total time delta from parents - mLastTimerData.mChildTime += total_time; + typedef Time self_t; + typedef class BlockTimer DeclareTimer; - LLFastTimer::sCurTimerData = mLastTimerData; -#endif - } +public: + Time(BlockTimer& timer); + ~Time(); public: - static LLMutex* sLogLock; - static std::queue sLogQueue; - static BOOL sLog; - static BOOL sMetricLog; + static bool sLog; + static bool sMetricLog; static std::string sLogName; static bool sPauseHistory; static bool sResetHistory; @@ -180,11 +75,11 @@ public: struct CurTimerData { - LLFastTimer* mCurTimer; - DeclareTimer* mTimerData; - U32 mChildTime; + Time* mCurTimer; + BlockTimer* mTimerData; + U64 mChildTime; }; - static CurTimerData sCurTimerData; + static LLThreadLocalPointer sCurTimerData; private: @@ -211,14 +106,14 @@ private: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 LLFastTimer::getCPUClockCount32() + //inline U32 Time::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 LLFastTimer::getCPUClockCount64() + //inline U64 Time::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -258,7 +153,7 @@ private: } #else - //LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp + //U64 get_clock_count(); // in lltimer.cpp // These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures. static U32 getCPUClockCount32() { @@ -330,10 +225,131 @@ private: static S32 sLastFrameIndex; static U64 sLastFrameTime; - U32 mStartTime; - LLFastTimer::CurTimerData mLastTimerData; + U64 mStartTime; + Time::CurTimerData mLastTimerData; +}; + +struct TimerAccumulator +{ + void addSamples(const TimerAccumulator& other); + void reset(const TimerAccumulator* other); + + // + // members + // + U64 mSelfTimeCounter, + mTotalTimeCounter; + U32 mCalls; + BlockTimer* 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 +}; + +// stores a "named" timer instance to be reused via multiple Time stack instances +class BlockTimer +: public TraceType, + public LLInstanceTracker +{ +public: + BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); + ~BlockTimer(); + + enum { HISTORY_NUM = 300 }; + + BlockTimer* getParent() const { return mParent; } + void setParent(BlockTimer* parent); + S32 getDepth(); + + typedef std::vector::const_iterator child_const_iter; + child_const_iter beginChildren(); + child_const_iter endChildren(); + std::vector& getChildren(); + + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } + + U32 getCountAverage() const { return mCountAverage; } + U32 getCallAverage() const { return mCallAverage; } + + U32 getHistoricalCount(S32 history_index = 0) const; + U32 getHistoricalCalls(S32 history_index = 0) const; + + static BlockTimer& getRootTimer(); + +private: + friend class Time; + + // recursive call to gather total time from children + static void accumulateTimings(); + + // updates cumulative times and hierarchy, + // can be called multiple times in a frame, at any point + static void processTimes(); + + static void buildHierarchy(); + static void resetFrame(); + static void reset(); + + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; + + U32 mCountAverage; + U32 mCallAverage; + + U32* mCountHistory; + U32* mCallHistory; + + // tree structure + BlockTimer* mParent; // BlockTimer of caller(parent) + std::vector mChildren; + bool mCollapsed; // don't show children + bool mNeedsSorting; // sort children whenever child added }; -typedef class LLFastTimer LLFastTimer; +LL_FORCE_INLINE Time::Time(BlockTimer& timer) +{ +#if FAST_TIMER_ON + mStartTime = getCPUClockCount64(); + + TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); + accumulator.mActiveCount++; + accumulator.mCalls++; + // keep current parent as long as it is active when we are + accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); + + CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + // store top of stack + mLastTimerData = *cur_timer_data; + // push new information + cur_timer_data->mCurTimer = this; + cur_timer_data->mTimerData = &timer; + cur_timer_data->mChildTime = 0; +#endif +} + +LL_FORCE_INLINE Time::~Time() +{ +#if FAST_TIMER_ON + U64 total_time = getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator.mSelfTimeCounter += total_time - 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.mTimerData; + + // we are only tracking self time, so subtract our total time delta from parents + mLastTimerData.mChildTime += total_time; + + *sCurTimerData = mLastTimerData; +#endif +} + +} + +typedef LLTrace::Time LLFastTimer; #endif // LL_LLFASTTIMER_H -- cgit v1.2.3 From 9d77e030d9a0d23cebce616631677459eec1612c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Nov 2012 23:52:27 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system cleaning up build moved most includes of windows.h to llwin32headers.h to disable min/max macros, etc streamlined Time class and consolidated functionality in BlockTimer class llfasttimer is no longer included via llstring.h, so had to add it manually in several places --- indra/llcommon/llfasttimer.h | 165 +++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 93 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index f5e6d874a2..69a6773b12 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -28,60 +28,77 @@ #define LL_FASTTIMER_H #include "llinstancetracker.h" +#include "lltrace.h" #define FAST_TIMER_ON 1 +#define LL_FASTTIMER_USE_RDTSC 1 class LLMutex; -#include "lltrace.h" - -#define LL_FASTTIMER_USE_RDTSC 1 - namespace LLTrace { +struct CurTimerData +{ + class Time* mCurTimer; + class BlockTimer* mTimerData; + U64 mChildTime; +}; class Time { public: + friend class BlockTimer; typedef Time self_t; typedef class BlockTimer DeclareTimer; -public: Time(BlockTimer& timer); ~Time(); public: - static bool sLog; - static bool sMetricLog; - static std::string sLogName; - static bool sPauseHistory; - static bool sResetHistory; - - // call this once a frame to reset timers - static void nextFrame(); - // dumps current cumulative frame stats to log // call nextFrame() to reset timers static void dumpCurTimes(); - // call this to reset timer hierarchy, averages, etc. - static void reset(); + static void writeLog(std::ostream& os); - static U64 countsPerSecond(); - static S32 getLastFrameIndex() { return sLastFrameIndex; } - static S32 getCurFrameIndex() { return sCurFrameIndex; } +private: - static void writeLog(std::ostream& os); + U64 mStartTime; + CurTimerData mLastTimerData; +}; - struct CurTimerData - { - Time* mCurTimer; - BlockTimer* mTimerData; - U64 mChildTime; - }; - static LLThreadLocalPointer sCurTimerData; +// stores a "named" timer instance to be reused via multiple Time stack instances +class BlockTimer +: public TraceType, + public LLInstanceTracker +{ +public: + BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); + ~BlockTimer(); -private: + enum { HISTORY_NUM = 300 }; + + BlockTimer* getParent() const { return mParent; } + void setParent(BlockTimer* parent); + S32 getDepth(); + + typedef std::vector::const_iterator child_const_iter; + child_const_iter beginChildren(); + child_const_iter endChildren(); + std::vector& getChildren(); + + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } + + U32 getCountAverage() const { return mCountAverage; } + U32 getCallAverage() const { return mCallAverage; } + + U32 getHistoricalCount(S32 history_index = 0) const; + U32 getHistoricalCalls(S32 history_index = 0) const; + + static BlockTimer& getRootTimer(); + static void pushLog(LLSD sd); + friend class Time; ////////////////////////////////////////////////////////////////////////////// @@ -106,14 +123,14 @@ private: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 Time::getCPUClockCount32() + //inline U32 BlockTimer::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 Time::getCPUClockCount64() + //inline U64 BlockTimer::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -220,64 +237,7 @@ private: #endif - static U64 sClockResolution; - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; - static U64 sLastFrameTime; - - U64 mStartTime; - Time::CurTimerData mLastTimerData; -}; - -struct TimerAccumulator -{ - void addSamples(const TimerAccumulator& other); - void reset(const TimerAccumulator* other); - - // - // members - // - U64 mSelfTimeCounter, - mTotalTimeCounter; - U32 mCalls; - BlockTimer* 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 -}; - -// stores a "named" timer instance to be reused via multiple Time stack instances -class BlockTimer -: public TraceType, - public LLInstanceTracker -{ -public: - BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); - ~BlockTimer(); - - enum { HISTORY_NUM = 300 }; - - BlockTimer* getParent() const { return mParent; } - void setParent(BlockTimer* parent); - S32 getDepth(); - - typedef std::vector::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); - std::vector& getChildren(); - - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U32 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; - - static BlockTimer& getRootTimer(); - -private: - friend class Time; + static U64 countsPerSecond(); // recursive call to gather total time from children static void accumulateTimings(); @@ -289,6 +249,12 @@ private: static void buildHierarchy(); static void resetFrame(); static void reset(); + // call this once a frame to reset timers + static void nextFrame(); + static S32 getLastFrameIndex() { return sLastFrameIndex; } + static S32 getCurFrameIndex() { return sCurFrameIndex; } + + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete U32 mTreeTimeCounter; @@ -304,12 +270,25 @@ private: std::vector mChildren; bool mCollapsed; // don't show children bool mNeedsSorting; // sort children whenever child added + + // statics + static std::string sLogName; + static bool sMetricLog; + static bool sLog; + static LLThreadLocalPointer sCurTimerData; + static U64 sClockResolution; + static S32 sCurFrameIndex; + static S32 sLastFrameIndex; + static U64 sLastFrameTime; + static bool sPauseHistory; + static bool sResetHistory; + }; LL_FORCE_INLINE Time::Time(BlockTimer& timer) { #if FAST_TIMER_ON - mStartTime = getCPUClockCount64(); + mStartTime = BlockTimer::getCPUClockCount64(); TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); accumulator.mActiveCount++; @@ -317,7 +296,7 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) // keep current parent as long as it is active when we are accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); - CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); // store top of stack mLastTimerData = *cur_timer_data; // push new information @@ -330,8 +309,8 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) LL_FORCE_INLINE Time::~Time() { #if FAST_TIMER_ON - U64 total_time = getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; @@ -344,7 +323,7 @@ LL_FORCE_INLINE Time::~Time() // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *sCurTimerData = mLastTimerData; + *BlockTimer::sCurTimerData = mLastTimerData; #endif } -- cgit v1.2.3 From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Nov 2012 19:46:09 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and max macros from windows.h got rest of viewer to compile against llfasttimer changes --- indra/llcommon/llfasttimer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 69a6773b12..af9b360e01 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -98,6 +98,7 @@ public: static BlockTimer& getRootTimer(); static void pushLog(LLSD sd); + static void setLogLock(LLMutex* mutex); friend class Time; @@ -329,6 +330,6 @@ LL_FORCE_INLINE Time::~Time() } -typedef LLTrace::Time LLFastTimer; +typedef LLTrace::Time LLFastTimer; #endif // LL_LLFASTTIMER_H -- cgit v1.2.3 From 1c894c05c10ef37be6507ee4bc4e9173506adfb6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Nov 2012 17:26:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system hunting down bad values and crashes --- indra/llcommon/llfasttimer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index af9b360e01..cfe2cf5371 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -93,7 +93,7 @@ public: U32 getCountAverage() const { return mCountAverage; } U32 getCallAverage() const { return mCallAverage; } - U32 getHistoricalCount(S32 history_index = 0) const; + U64 getHistoricalCount(S32 history_index = 0) const; U32 getHistoricalCalls(S32 history_index = 0) const; static BlockTimer& getRootTimer(); @@ -258,12 +258,12 @@ public: // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; + U64 mTreeTimeCounter; - U32 mCountAverage; + U64 mCountAverage; U32 mCallAverage; - U32* mCountHistory; + U64* mCountHistory; U32* mCallHistory; // tree structure -- cgit v1.2.3 From 02d503bf8f8890c6d4b57dd09a1fde2973715b75 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 29 Nov 2012 00:43:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system moved runtime timer tree topology information to separate array instead of recording stack --- indra/llcommon/llfasttimer.h | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index cfe2cf5371..9f981480f2 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -37,11 +37,13 @@ class LLMutex; namespace LLTrace { + struct CurTimerData { class Time* mCurTimer; class BlockTimer* mTimerData; U64 mChildTime; + TimerTreeNode* mTimerTreeData; }; class Time @@ -269,20 +271,20 @@ public: // tree structure BlockTimer* mParent; // BlockTimer of caller(parent) std::vector mChildren; - bool mCollapsed; // don't show children - bool mNeedsSorting; // sort children whenever child added + bool mCollapsed, // don't show children + mNeedsSorting; // sort children whenever child added // statics static std::string sLogName; - static bool sMetricLog; - static bool sLog; + static bool sMetricLog, + sLog; static LLThreadLocalPointer sCurTimerData; static U64 sClockResolution; - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; + static S32 sCurFrameIndex, + sLastFrameIndex; static U64 sLastFrameTime; - static bool sPauseHistory; - static bool sResetHistory; + static bool sPauseHistory, + sResetHistory; }; @@ -291,13 +293,12 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) #if FAST_TIMER_ON mStartTime = BlockTimer::getCPUClockCount64(); - TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); - accumulator.mActiveCount++; - accumulator.mCalls++; + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); + TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; + tree_node.mActiveCount++; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); + tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); // store top of stack mLastTimerData = *cur_timer_data; // push new information @@ -313,13 +314,16 @@ LL_FORCE_INLINE Time::~Time() U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; + + accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; - accumulator.mActiveCount--; + tree_node.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator.mLastCaller = mLastTimerData.mTimerData; + tree_node.mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; -- cgit v1.2.3 From 407e5013f3845208e0a60e26e8f0a7fad997df5d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 3 Dec 2012 19:54:53 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system converted fast timer view over to new lltrace mechanisms --- indra/llcommon/llfasttimer.h | 111 +++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 68 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 9f981480f2..e3d99a9e4b 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -40,28 +40,21 @@ namespace LLTrace struct CurTimerData { - class Time* mCurTimer; - class BlockTimer* mTimerData; + class BlockTimer* mCurTimer; + class TimeBlock* mTimerData; U64 mChildTime; - TimerTreeNode* mTimerTreeData; + TimeBlockTreeNode* mTimerTreeData; }; -class Time +class BlockTimer { public: - friend class BlockTimer; - typedef Time self_t; - typedef class BlockTimer DeclareTimer; + friend class TimeBlock; + typedef BlockTimer self_t; + typedef class TimeBlock DeclareTimer; - Time(BlockTimer& timer); - ~Time(); - -public: - // dumps current cumulative frame stats to log - // call nextFrame() to reset timers - static void dumpCurTimes(); - - static void writeLog(std::ostream& os); + BlockTimer(TimeBlock& timer); + ~BlockTimer(); private: @@ -69,40 +62,41 @@ private: CurTimerData mLastTimerData; }; -// stores a "named" timer instance to be reused via multiple Time stack instances -class BlockTimer -: public TraceType, - public LLInstanceTracker +// stores a "named" timer instance to be reused via multiple BlockTimer stack instances +class TimeBlock +: public TraceType, + public LLInstanceTracker { public: - BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); - ~BlockTimer(); + TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); enum { HISTORY_NUM = 300 }; - BlockTimer* getParent() const { return mParent; } - void setParent(BlockTimer* parent); + TimeBlock* getParent() const { return mParent; } + void setParent(TimeBlock* parent); S32 getDepth(); - typedef std::vector::const_iterator child_const_iter; + typedef std::vector::const_iterator child_const_iter; child_const_iter beginChildren(); child_const_iter endChildren(); - std::vector& getChildren(); + std::vector& getChildren(); void setCollapsed(bool collapsed) { mCollapsed = collapsed; } bool getCollapsed() const { return mCollapsed; } - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U64 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; + TraceType& callCount() + { + return static_cast&>(*(TraceType*)this); + } - static BlockTimer& getRootTimer(); + static TimeBlock& getRootTimer(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); - friend class Time; + static void writeLog(std::ostream& os); + // dumps current cumulative frame stats to log + // call nextFrame() to reset timers + static void dumpCurTimes(); ////////////////////////////////////////////////////////////////////////////// // @@ -126,14 +120,14 @@ public: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 BlockTimer::getCPUClockCount32() + //inline U32 TimeBlock::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 BlockTimer::getCPUClockCount64() + //inline U64 TimeBlock::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -242,35 +236,16 @@ public: static U64 countsPerSecond(); - // recursive call to gather total time from children - static void accumulateTimings(); - // updates cumulative times and hierarchy, // can be called multiple times in a frame, at any point static void processTimes(); - static void buildHierarchy(); - static void resetFrame(); - static void reset(); // call this once a frame to reset timers static void nextFrame(); - static S32 getLastFrameIndex() { return sLastFrameIndex; } - static S32 getCurFrameIndex() { return sCurFrameIndex; } - - - - // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U64 mTreeTimeCounter; - - U64 mCountAverage; - U32 mCallAverage; - - U64* mCountHistory; - U32* mCallHistory; - // tree structure - BlockTimer* mParent; // BlockTimer of caller(parent) - std::vector mChildren; + // tree structure, only updated from master trace thread + TimeBlock* mParent; // TimeBlock of caller(parent) + std::vector mChildren; bool mCollapsed, // don't show children mNeedsSorting; // sort children whenever child added @@ -288,13 +263,13 @@ public: }; -LL_FORCE_INLINE Time::Time(BlockTimer& timer) +LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) { #if FAST_TIMER_ON - mStartTime = BlockTimer::getCPUClockCount64(); + mStartTime = TimeBlock::getCPUClockCount64(); - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); - TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; + CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); + TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; tree_node.mActiveCount++; // keep current parent as long as it is active when we are tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); @@ -308,13 +283,13 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) #endif } -LL_FORCE_INLINE Time::~Time() +LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if FAST_TIMER_ON - U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); - TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; + U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; @@ -328,12 +303,12 @@ LL_FORCE_INLINE Time::~Time() // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *BlockTimer::sCurTimerData = mLastTimerData; + *TimeBlock::sCurTimerData = mLastTimerData; #endif } } -typedef LLTrace::Time LLFastTimer; +typedef LLTrace::BlockTimer LLFastTimer; #endif // LL_LLFASTTIMER_H -- cgit v1.2.3 From 8c2e3bea71ea15b805a9e2a288744f10d195d803 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 9 Dec 2012 23:19:11 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added ability to query self time of block timers indepedently --- indra/llcommon/llfasttimer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e3d99a9e4b..b5b4a8d0b4 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -89,6 +89,11 @@ public: return static_cast&>(*(TraceType*)this); } + TraceType& selfTime() + { + return static_cast&>(*(TraceType*)this); + } + static TimeBlock& getRootTimer(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); -- cgit v1.2.3 From c219282f5de753a044cecb53bd806145f68add9a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Dec 2012 20:07:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed some potential data races got memory stats recording in trace system --- indra/llcommon/llfasttimer.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index b5b4a8d0b4..1e2e4b590f 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -43,7 +43,6 @@ struct CurTimerData class BlockTimer* mCurTimer; class TimeBlock* mTimerData; U64 mChildTime; - TimeBlockTreeNode* mTimerTreeData; }; class BlockTimer @@ -70,11 +69,8 @@ class TimeBlock public: TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); - enum { HISTORY_NUM = 300 }; - TimeBlock* getParent() const { return mParent; } void setParent(TimeBlock* parent); - S32 getDepth(); typedef std::vector::const_iterator child_const_iter; child_const_iter beginChildren(); @@ -245,12 +241,12 @@ public: // can be called multiple times in a frame, at any point static void processTimes(); - // call this once a frame to reset timers - static void nextFrame(); + // call this once a frame to periodically log timers + static void logStats(); // tree structure, only updated from master trace thread TimeBlock* mParent; // TimeBlock of caller(parent) - std::vector mChildren; + std::vector mChildren; // TimeBlock of callees bool mCollapsed, // don't show children mNeedsSorting; // sort children whenever child added @@ -260,12 +256,6 @@ public: sLog; static LLThreadLocalPointer sCurTimerData; static U64 sClockResolution; - static S32 sCurFrameIndex, - sLastFrameIndex; - static U64 sLastFrameTime; - static bool sPauseHistory, - sResetHistory; - }; LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) @@ -274,10 +264,10 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) mStartTime = TimeBlock::getCPUClockCount64(); CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; - tree_node.mActiveCount++; + TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator.mActiveCount++; // keep current parent as long as it is active when we are - tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); // store top of stack mLastTimerData = *cur_timer_data; @@ -294,16 +284,15 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; - tree_node.mActiveCount--; + accumulator.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - tree_node.mLastCaller = mLastTimerData.mTimerData; + accumulator.mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; -- cgit v1.2.3 From 013f04cabec8e110ee659d9b3f75a4d25f114b7b Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Dec 2012 00:13:21 -0800 Subject: SH-3468 WIP add memory tracking base class improvements on lifetime of lltrace core data structures tweaks to thread local pointer handling so that static constructors/destructors can safely call functions that use lltrace --- indra/llcommon/llfasttimer.h | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 1e2e4b590f..4d820d0664 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -69,12 +69,14 @@ class TimeBlock public: TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); - TimeBlock* getParent() const { return mParent; } - void setParent(TimeBlock* parent); + TimeBlockTreeNode& getTreeNode() const; + TimeBlock* getParent() const { return getTreeNode().getParent(); } + void setParent(TimeBlock* parent) { getTreeNode().setParent(parent); } + typedef std::vector::iterator child_iter; typedef std::vector::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); + child_iter beginChildren(); + child_iter endChildren(); std::vector& getChildren(); void setCollapsed(bool collapsed) { mCollapsed = collapsed; } @@ -244,11 +246,7 @@ public: // call this once a frame to periodically log timers static void logStats(); - // tree structure, only updated from master trace thread - TimeBlock* mParent; // TimeBlock of caller(parent) - std::vector mChildren; // TimeBlock of callees - bool mCollapsed, // don't show children - mNeedsSorting; // sort children whenever child added + bool mCollapsed; // don't show children // statics static std::string sLogName; @@ -264,10 +262,10 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) mStartTime = TimeBlock::getCPUClockCount64(); CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - accumulator.mActiveCount++; + TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator->mActiveCount++; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); + accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); // store top of stack mLastTimerData = *cur_timer_data; @@ -283,16 +281,16 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() #if FAST_TIMER_ON U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - accumulator.mCalls++; - accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; - accumulator.mTotalTimeCounter += total_time; - accumulator.mActiveCount--; + accumulator->mCalls++; + accumulator->mSelfTimeCounter += total_time - 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.mTimerData; + accumulator->mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; -- cgit v1.2.3 From cda2cdda511eb2f7a58e284db2c852fd4a3808ae Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Jan 2013 00:30:54 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system made fast timer stack thread local added LLThreadLocalSingleton made LLThreadLocalPointer obey pointer rules for const added LLThreadLocalSingletonPointer for fast thread local pointers --- indra/llcommon/llfasttimer.h | 45 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4d820d0664..995eebd16a 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,13 +38,29 @@ class LLMutex; namespace LLTrace { -struct CurTimerData +struct BlockTimerStackRecord { - class BlockTimer* mCurTimer; - class TimeBlock* mTimerData; + class BlockTimer* mActiveTimer; + class TimeBlock* mTimeBlock; U64 mChildTime; }; +class ThreadTimerStack +: public BlockTimerStackRecord, + public LLThreadLocalSingleton +{ + friend LLThreadLocalSingleton; + ThreadTimerStack() + {} + +public: + ThreadTimerStack& operator=(const BlockTimerStackRecord& other) + { + BlockTimerStackRecord::operator=(other); + return *this; + } +}; + class BlockTimer { public: @@ -58,7 +74,7 @@ public: private: U64 mStartTime; - CurTimerData mLastTimerData; + BlockTimerStackRecord mLastTimerData; }; // stores a "named" timer instance to be reused via multiple BlockTimer stack instances @@ -67,7 +83,7 @@ class TimeBlock public LLInstanceTracker { public: - TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); + TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimeBlock()); TimeBlockTreeNode& getTreeNode() const; TimeBlock* getParent() const { return getTreeNode().getParent(); } @@ -92,7 +108,7 @@ public: return static_cast&>(*(TraceType*)this); } - static TimeBlock& getRootTimer(); + static TimeBlock& getRootTimeBlock(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); static void writeLog(std::ostream& os); @@ -252,7 +268,6 @@ public: static std::string sLogName; static bool sMetricLog, sLog; - static LLThreadLocalPointer sCurTimerData; static U64 sClockResolution; }; @@ -261,8 +276,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON mStartTime = TimeBlock::getCPUClockCount64(); - CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mActiveCount++; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -270,8 +285,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) // store top of stack mLastTimerData = *cur_timer_data; // push new information - cur_timer_data->mCurTimer = this; - cur_timer_data->mTimerData = &timer; + cur_timer_data->mActiveTimer = this; + cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; #endif } @@ -280,8 +295,8 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if FAST_TIMER_ON U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mCalls++; accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; @@ -290,12 +305,12 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator->mLastCaller = mLastTimerData.mTimerData; + accumulator->mLastCaller = mLastTimerData.mTimeBlock; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *TimeBlock::sCurTimerData = mLastTimerData; + *ThreadTimerStack::getIfExists() = mLastTimerData; #endif } -- cgit v1.2.3 From 6e82bb7789c1e046dcfb97c6773150df110153f8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 3 Jan 2013 22:34:34 +0000 Subject: fixing linux compile errors for llcommon after LLTrace work --- indra/llcommon/llfasttimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 995eebd16a..fb2868ff98 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -49,7 +49,7 @@ class ThreadTimerStack : public BlockTimerStackRecord, public LLThreadLocalSingleton { - friend LLThreadLocalSingleton; + friend class LLThreadLocalSingleton; ThreadTimerStack() {} -- cgit v1.2.3 From 20b2fa4052ae6789ec8894f33f4764a1f7233b24 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Jan 2013 23:08:01 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved performance of fast timer stat gathering --- indra/llcommon/llfasttimer.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') 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 } -- cgit v1.2.3 From 43a92d01afdb4f1dd4003059b79f87e9687527a1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Jan 2013 20:11:43 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed some uninitialized variables root timer accumulator was being initialized to NULL --- indra/llcommon/llfasttimer.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 2d87629561..06de8ea6ee 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -74,7 +74,7 @@ public: private: U64 mStartTime; - BlockTimerStackRecord mLastTimerData; + BlockTimerStackRecord mParentTimerData; }; // stores a "named" timer instance to be reused via multiple BlockTimer stack instances @@ -280,10 +280,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; // keep current parent as long as it is active when we are + llassert(accumulator->mParent); accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); // store top of stack - mLastTimerData = *cur_timer_data; + mParentTimerData = *cur_timer_data; // push new information cur_timer_data->mActiveTimer = this; cur_timer_data->mAccumulator = accumulator; @@ -305,13 +306,13 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator->mLastAccumulator = mLastTimerData.mAccumulator; + accumulator->mLastAccumulator = mParentTimerData.mAccumulator; // we are only tracking self time, so subtract our total time delta from parents - mLastTimerData.mChildTime += total_time; + mParentTimerData.mChildTime += total_time; //pop stack - *cur_timer_data = mLastTimerData; + *cur_timer_data = mParentTimerData; #endif } -- cgit v1.2.3 From e975ae35ab57f56adfaed64bc108240a5013f040 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 18 Jan 2013 15:59:16 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed crash on startup --- indra/llcommon/llfasttimer.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 06de8ea6ee..726db70fbe 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -40,9 +40,9 @@ namespace LLTrace struct BlockTimerStackRecord { - class BlockTimer* mActiveTimer; - class TimeBlockAccumulator* mAccumulator; - U64 mChildTime; + class BlockTimer* mActiveTimer; + class TimeBlock* mTimeBlock; + U64 mChildTime; }; class ThreadTimerStack @@ -73,7 +73,7 @@ public: private: - U64 mStartTime; + U64 mStartTime; BlockTimerStackRecord mParentTimerData; }; @@ -280,14 +280,13 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; // keep current parent as long as it is active when we are - llassert(accumulator->mParent); accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); // store top of stack mParentTimerData = *cur_timer_data; // push new information cur_timer_data->mActiveTimer = this; - cur_timer_data->mAccumulator = accumulator; + cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; #endif } @@ -297,7 +296,7 @@ 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->mAccumulator; + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mCalls++; accumulator->mChildTimeCounter += cur_timer_data->mChildTime; @@ -306,7 +305,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() // store last caller to bootstrap tree creation // 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 mParentTimerData.mChildTime += total_time; -- cgit v1.2.3 From 438cbfe489cc34261ac600bbb22983164e59b1d9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 7 Feb 2013 20:07:31 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fix for timings for recursive fast timers not being correct --- indra/llcommon/llfasttimer.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 726db70fbe..9402bb7267 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -71,9 +71,12 @@ public: BlockTimer(TimeBlock& timer); ~BlockTimer(); + void logCurrentTime(); + private: U64 mStartTime; + U64 mStartSelfTimeCount; BlockTimerStackRecord mParentTimerData; }; @@ -279,6 +282,7 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; + mStartSelfTimeCount = accumulator->mSelfTimeCounter; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -298,9 +302,10 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); + U64 child_time = cur_timer_data->mChildTime - (accumulator->mSelfTimeCounter - mStartSelfTimeCount); accumulator->mCalls++; - accumulator->mChildTimeCounter += cur_timer_data->mChildTime; - accumulator->mTotalTimeCounter += total_time; + accumulator->mChildTimeCounter += child_time; + accumulator->mSelfTimeCounter += total_time - child_time; accumulator->mActiveCount--; // store last caller to bootstrap tree creation @@ -315,6 +320,11 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() #endif } +inline void BlockTimer::logCurrentTime() +{ + U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; + llinfos << "Time elapsed: " << (1000.0 * (F64)total_time / (F64)TimeBlock::countsPerSecond()) << llendl; +} } typedef LLTrace::BlockTimer LLFastTimer; -- cgit v1.2.3 From e3700112f313f3570887047d5b56a661af0afac5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 8 Feb 2013 00:03:31 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible added debug output to BlockTimer --- indra/llcommon/llfasttimer.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 726db70fbe..edbcb896b3 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -71,6 +71,8 @@ public: BlockTimer(TimeBlock& timer); ~BlockTimer(); + LLUnit getElapsedTime(); + private: U64 mStartTime; -- cgit v1.2.3 From 2e15e8fd4ba62204c76f6e2a91d3e50f62e6c1fc Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 9 Feb 2013 00:34:59 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible fixed anamolous LLFastTimer timings --- indra/llcommon/llfasttimer.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 2994b35e58..28e54a37de 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -76,7 +76,8 @@ public: private: U64 mStartTime; - U64 mStartSelfTimeCount; + U64 mStartSelfTimeCounter; + U64 mStartChildTimeCounter; BlockTimerStackRecord mParentTimerData; }; @@ -282,7 +283,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; - mStartSelfTimeCount = accumulator->mSelfTimeCounter; + mStartSelfTimeCounter = accumulator->mSelfTimeCounter; + mStartChildTimeCounter = accumulator->mChildTimeCounter; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -302,10 +304,12 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); - U64 child_time = cur_timer_data->mChildTime - (accumulator->mSelfTimeCounter - mStartSelfTimeCount); + U64 child_time = cur_timer_data->mChildTime + - (accumulator->mSelfTimeCounter - mStartSelfTimeCounter) + - (accumulator->mChildTimeCounter - mStartChildTimeCounter); accumulator->mCalls++; accumulator->mChildTimeCounter += child_time; - accumulator->mSelfTimeCounter += total_time - child_time; + accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator->mActiveCount--; // store last caller to bootstrap tree creation @@ -320,11 +324,6 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() #endif } -inline void BlockTimer::logCurrentTime() -{ - U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; - llinfos << "Time elapsed: " << (1000.0 * (F64)total_time / (F64)TimeBlock::countsPerSecond()) << llendl; -} } typedef LLTrace::BlockTimer LLFastTimer; -- cgit v1.2.3 From 67ac6e7a294bd7401c55ed1d7423166dda1c0ee6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 10 Feb 2013 23:53:45 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible streamlined fast timer delta tracking --- indra/llcommon/llfasttimer.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 28e54a37de..ec1720d2df 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -76,8 +76,7 @@ public: private: U64 mStartTime; - U64 mStartSelfTimeCounter; - U64 mStartChildTimeCounter; + U64 mStartTotalTimeCounter; BlockTimerStackRecord mParentTimerData; }; @@ -283,8 +282,7 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; - mStartSelfTimeCounter = accumulator->mSelfTimeCounter; - mStartChildTimeCounter = accumulator->mChildTimeCounter; + mStartTotalTimeCounter = accumulator->mTotalTimeCounter; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -304,11 +302,8 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); - U64 child_time = cur_timer_data->mChildTime - - (accumulator->mSelfTimeCounter - mStartSelfTimeCounter) - - (accumulator->mChildTimeCounter - mStartChildTimeCounter); accumulator->mCalls++; - accumulator->mChildTimeCounter += child_time; + accumulator->mTotalTimeCounter += total_time - (accumulator->mTotalTimeCounter - mStartTotalTimeCounter); accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator->mActiveCount--; -- cgit v1.2.3 From a6bb68b6e530df91d03abfc062c700ebc4e856aa Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 13 Feb 2013 15:21:20 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible fix for inaccurate optimization of full block time calculations --- indra/llcommon/llfasttimer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index ec1720d2df..32a0629a87 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -76,7 +76,7 @@ public: private: U64 mStartTime; - U64 mStartTotalTimeCounter; + U64 mBlockStartTotalTimeCounter; BlockTimerStackRecord mParentTimerData; }; @@ -282,7 +282,7 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; - mStartTotalTimeCounter = accumulator->mTotalTimeCounter; + mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -303,7 +303,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mCalls++; - accumulator->mTotalTimeCounter += total_time - (accumulator->mTotalTimeCounter - mStartTotalTimeCounter); + accumulator->mTotalTimeCounter += total_time - (accumulator->mTotalTimeCounter - mBlockStartTotalTimeCounter); accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator->mActiveCount--; -- cgit v1.2.3 From a74b5dfa923f8eeccc9b786143f0f832de3ad450 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Jun 2013 19:45:33 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed mem stat tracking...now properly tracks memory footprint with floating point precision cleaned up macros for unit declaration renamed units to SI standard for 1024 multiples (kibibytes, etc) fixed units output for scene monitor dump --- indra/llcommon/llfasttimer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 32a0629a87..f329b30472 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -101,14 +101,14 @@ public: void setCollapsed(bool collapsed) { mCollapsed = collapsed; } bool getCollapsed() const { return mCollapsed; } - TraceType& callCount() + TraceType& callCount() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(TraceType*)this); } - TraceType& selfTime() + TraceType& selfTime() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(TraceType*)this); } static TimeBlock& getRootTimeBlock(); @@ -277,8 +277,6 @@ public: LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) { #if FAST_TIMER_ON - mStartTime = TimeBlock::getCPUClockCount64(); - BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; @@ -292,6 +290,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) cur_timer_data->mActiveTimer = this; cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; + + mStartTime = TimeBlock::getCPUClockCount64(); #endif } -- cgit v1.2.3 From 9fd3af3c389ed491b515cbb5136b344b069913e4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 13 Jun 2013 15:29:15 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed Units macros and argument order to make it more clear optimized units for integer types fixed merging of periodicrecordings...should eliminate duplicate entries in sceneloadmonitor history --- indra/llcommon/llfasttimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 20514d1638..fdc6997d45 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -71,7 +71,7 @@ public: BlockTimer(TimeBlock& timer); ~BlockTimer(); - LLUnit getElapsedTime(); + LLUnit getElapsedTime(); private: -- cgit v1.2.3 From d136c4c29686c565b5a46503aa67a9c958b4145d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Jun 2013 23:41:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate removed implicit flushes on reads from recorders for better performance made sure stack timers were updated on recorder deactivate faster rendering and better ui for fast timer view --- indra/llcommon/llfasttimer.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index fdc6997d45..e800befd9f 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -115,6 +115,7 @@ public: static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); static void writeLog(std::ostream& os); + static void updateTimes(); // dumps current cumulative frame stats to log // call nextFrame() to reset timers @@ -262,6 +263,9 @@ public: // can be called multiple times in a frame, at any point static void processTimes(); + static void bootstrapTimerTree(); + static void incrementalUpdateTimerTree(); + // call this once a frame to periodically log timers static void logStats(); -- cgit v1.2.3 From c5fc8f90060aa7a6c8fbb72313172423b01eddc5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 19 Jun 2013 08:23:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate moved collapsed flag to fast timer tree node --- indra/llcommon/llfasttimer.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e800befd9f..642c99ccce 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -86,7 +86,7 @@ class TimeBlock public LLInstanceTracker { public: - TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimeBlock()); + TimeBlock(const char* name, TimeBlock* parent = &getRootTimeBlock()); TimeBlockTreeNode& getTreeNode() const; TimeBlock* getParent() const { return getTreeNode().getParent(); } @@ -98,9 +98,6 @@ public: child_iter endChildren(); std::vector& getChildren(); - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - TraceType& callCount() { return static_cast&>(*(TraceType*)this); -- cgit v1.2.3 From 808d3eff198d65e5a870abb670786935fc8356bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 27 Jun 2013 00:07:21 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console fixed some lltrace logic errors more consistent syncing of timestamps of sample values in recording stack selection of primary buffers was completely incorrect assignment of recordings got wrong play state due to implicit operator = defined in base class fixed asset stats only working up to the first send --- indra/llcommon/llfasttimer.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 642c99ccce..ab8612a8ad 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,13 +38,6 @@ class LLMutex; namespace LLTrace { -struct BlockTimerStackRecord -{ - class BlockTimer* mActiveTimer; - class TimeBlock* mTimeBlock; - U64 mChildTime; -}; - class ThreadTimerStack : public BlockTimerStackRecord, public LLThreadLocalSingleton -- cgit v1.2.3 From 2fc422f39ddaca25c69e8cf2092a9d66840379f3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 30 Jun 2013 13:32:34 -0700 Subject: fixed memory leak due to implementation of LLThreadLocalSingleton removed LLThreadLocalSingleton collapsed all thread recorder classes to single type, LLTrace::ThreadRecorder moved fasttimer stack head to llthreadlocalsingletonpointer via ThreadRecorder --- indra/llcommon/llfasttimer.h | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index ab8612a8ad..73c40749ed 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,22 +38,6 @@ class LLMutex; namespace LLTrace { -class ThreadTimerStack -: public BlockTimerStackRecord, - public LLThreadLocalSingleton -{ - friend class LLThreadLocalSingleton; - ThreadTimerStack() - {} - -public: - ThreadTimerStack& operator=(const BlockTimerStackRecord& other) - { - BlockTimerStackRecord::operator=(other); - return *this; - } -}; - class BlockTimer { public: @@ -271,7 +255,8 @@ public: LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) { #if FAST_TIMER_ON - BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); + if (!cur_timer_data) return; TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); accumulator->mActiveCount++; mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; @@ -293,7 +278,9 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if FAST_TIMER_ON U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; - BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); + if (!cur_timer_data) return; + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mCalls++; -- cgit v1.2.3 From 26581404e426b00cd0a07c38b5cb858d5d5faa28 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Aug 2013 11:51:49 -0700 Subject: BUILDFIX: added header for numeric_limits support on gcc added convenience types for units F32Seconds, etc. --- indra/llcommon/llfasttimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 73c40749ed..589b9bb941 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -48,7 +48,7 @@ public: BlockTimer(TimeBlock& timer); ~BlockTimer(); - LLUnit getElapsedTime(); + LLUnits::F64Seconds getElapsedTime(); private: -- cgit v1.2.3 From 9f7bfa1c3710856cd2b0a0a8a429d6c45b0fcd09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Aug 2013 00:02:23 -0700 Subject: moved unit types out of LLUnits namespace, since they are prefixed --- indra/llcommon/llfasttimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 589b9bb941..ccf71c3f4c 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -48,7 +48,7 @@ public: BlockTimer(TimeBlock& timer); ~BlockTimer(); - LLUnits::F64Seconds getElapsedTime(); + F64Seconds getElapsedTime(); private: -- cgit v1.2.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llcommon/llfasttimer.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index ccf71c3f4c..7bad6134c5 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -257,11 +257,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); - accumulator->mActiveCount++; - mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + accumulator.mActiveCount++; + mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter; // keep current parent as long as it is active when we are - accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); // store top of stack mParentTimerData = *cur_timer_data; @@ -281,16 +281,16 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); - accumulator->mCalls++; - accumulator->mTotalTimeCounter += total_time - (accumulator->mTotalTimeCounter - mBlockStartTotalTimeCounter); - accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; - accumulator->mActiveCount--; + accumulator.mCalls++; + accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter); + accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; + accumulator.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator->mLastCaller = mParentTimerData.mTimeBlock; + accumulator.mLastCaller = mParentTimerData.mTimeBlock; // we are only tracking self time, so subtract our total time delta from parents mParentTimerData.mChildTime += total_time; -- cgit v1.2.3 From cbe397ad13665c7bc993e10d8fe1e4a876253378 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 5 Sep 2013 14:04:13 -0700 Subject: changed fast timer over to using macro another attempt to move mem stat into base class --- indra/llcommon/llfasttimer.h | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 7bad6134c5..e6bf544b51 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -35,28 +35,56 @@ 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); + class BlockTimer { public: - friend class TimeBlock; typedef BlockTimer self_t; typedef class TimeBlock DeclareTimer; - BlockTimer(TimeBlock& timer); ~BlockTimer(); F64Seconds getElapsedTime(); private: + friend class TimeBlock; + // 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&); + BlockTimer(TimeBlock& 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. + // This appears to be fixed in 2012. +public: +#endif + // no-copy + BlockTimer(const BlockTimer& other) {}; + +private: U64 mStartTime; U64 mBlockStartTotalTimeCounter; BlockTimerStackRecord mParentTimerData; }; +// this dummy function assists in allocating a block timer with stack-based lifetime. +// this is done by capturing the return value in a stack-allocated const reference variable. +// (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) +{ + return BlockTimer(timer); +} + // stores a "named" timer instance to be reused via multiple BlockTimer stack instances class TimeBlock : public TraceType, -- cgit v1.2.3 From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 7 Sep 2013 21:16:39 -0700 Subject: added memory usage and occlusion events to traces renamed "current" to "primary" when referring to accumulators --- indra/llcommon/llfasttimer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 7bad6134c5..1586ea2d04 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -257,11 +257,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); accumulator.mActiveCount++; mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getCurrentAccumulator().mActiveCount == 0); // store top of stack mParentTimerData = *cur_timer_data; @@ -281,7 +281,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getCurrentAccumulator(); accumulator.mCalls++; accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter); -- cgit v1.2.3 From 053d97db1b283ca2548dc1f64756ddfc5166158f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 25 Sep 2013 19:12:35 -0700 Subject: better memory usage for LLTrace (tighter packing of recording arrays) removed complicated and unnecessary fast timer gapless handoff logic (it should be gapless anyway) improved MemTrackable API, better separation of shadow and footprint added memory usage stats to floater_stats.xml --- indra/llcommon/llfasttimer.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 53c61734e5..4eb12907dc 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -71,7 +71,6 @@ public: private: U64 mStartTime; - U64 mBlockStartTotalTimeCounter; BlockTimerStackRecord mParentTimerData; }; @@ -287,7 +286,6 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) if (!cur_timer_data) return; TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); accumulator.mActiveCount++; - mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter; // keep current parent as long as it is active when we are accumulator.mMoveUpTree |= (accumulator.mParent->getCurrentAccumulator().mActiveCount == 0); @@ -312,7 +310,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getCurrentAccumulator(); accumulator.mCalls++; - accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter); + accumulator.mTotalTimeCounter += total_time; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mActiveCount--; -- cgit v1.2.3 From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/llcommon/llfasttimer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4eb12907dc..1266d87f08 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -86,7 +86,7 @@ LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer) // stores a "named" timer instance to be reused via multiple BlockTimer stack instances class TimeBlock -: public TraceType, +: public StatType, public LLInstanceTracker { public: @@ -102,14 +102,14 @@ public: child_iter endChildren(); std::vector& getChildren(); - TraceType& callCount() + StatType& callCount() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } - TraceType& selfTime() + StatType& selfTime() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } static TimeBlock& getRootTimeBlock(); -- cgit v1.2.3 From 697d2e720ba75e142a4d56ae8794bab8d7698dad Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Oct 2013 20:24:42 -0700 Subject: renamed TimeBlock to BlockTimerStatHandle --- indra/llcommon/llfasttimer.h | 54 +++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') 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, - public LLInstanceTracker +class BlockTimerStatHandle +: public StatType { public: - TimeBlock(const char* name, TimeBlock* parent = &getRootTimeBlock()); + typedef LLInstanceTracker, 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::iterator child_iter; - typedef std::vector::const_iterator child_const_iter; + typedef std::vector::iterator child_iter; + typedef std::vector::const_iterator child_const_iter; child_iter beginChildren(); child_iter endChildren(); - std::vector& getChildren(); + std::vector& getChildren(); StatType& callCount() { @@ -112,9 +110,9 @@ public: return static_cast&>(*(StatType*)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::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::getInstance(); if (!cur_timer_data) return; -- cgit v1.2.3 From 1c26d4265666cd232d38724ad6f1e32fd2dc2d34 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 16 Oct 2013 16:42:27 -0700 Subject: moved tree iterators into llfasttimer.h --- indra/llcommon/llfasttimer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index faa622628b..4821d6c386 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -29,6 +29,7 @@ #include "llinstancetracker.h" #include "lltrace.h" +#include "lltreeiterators.h" #define LL_FAST_TIMER_ON 1 #define LL_FASTTIMER_USE_RDTSC 1 @@ -277,6 +278,18 @@ public: static U64 sClockResolution; }; +// iterators and helper functions for walking the call hierarchy of block timers in different ways +typedef LLTreeDFSIter block_timer_tree_df_iterator_t; +typedef LLTreeDFSPostIter block_timer_tree_df_post_iterator_t; +typedef LLTreeBFSIter block_timer_tree_bf_iterator_t; + +block_timer_tree_df_iterator_t begin_block_timer_tree_df(BlockTimerStatHandle& id); +block_timer_tree_df_iterator_t end_block_timer_tree_df(); +block_timer_tree_df_post_iterator_t begin_block_timer_tree_df_post(BlockTimerStatHandle& id); +block_timer_tree_df_post_iterator_t end_block_timer_tree_df_post(); +block_timer_tree_bf_iterator_t begin_block_timer_tree_bf(BlockTimerStatHandle& id); +block_timer_tree_bf_iterator_t end_block_timer_tree_bf(); + LL_FORCE_INLINE BlockTimer::BlockTimer(BlockTimerStatHandle& timer) { #if LL_FAST_TIMER_ON -- cgit v1.2.3 From 1beaedacadc8093c9df612992a873f9c89354bce Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Oct 2013 14:23:56 -0700 Subject: moved root timer to global variable added flag to LLInstanceTracker to allow multiple values per key made StatType allow multiple values per key to eliminate block timer related crash --- indra/llcommon/llfasttimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4821d6c386..614e7fdb4c 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -88,7 +88,6 @@ class BlockTimerStatHandle : public StatType { public: - typedef LLInstanceTracker, std::string> instance_tracker_t; BlockTimerStatHandle(const char* name, const char* description = ""); TimeBlockTreeNode& getTreeNode() const; @@ -99,6 +98,7 @@ public: typedef std::vector::const_iterator child_const_iter; child_iter beginChildren(); child_iter endChildren(); + bool hasChildren(); std::vector& getChildren(); StatType& callCount() -- cgit v1.2.3 From ab43be5ddb50198304de1ae0e82b641c7d343449 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 23 Oct 2013 13:24:47 -0700 Subject: moved some common functionality from LLTrace::BlockTimerStatHandle to BlockTimer updates appearance utility dependency --- indra/llcommon/llfasttimer.h | 162 ++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 80 deletions(-) (limited to 'indra/llcommon/llfasttimer.h') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 614e7fdb4c..2370253078 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -51,77 +51,7 @@ public: F64Seconds getElapsedTime(); -private: - 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(BlockTimerStatHandle&); - - 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. - // This appears to be fixed in 2012. -public: -#endif - // no-copy - BlockTimer(const BlockTimer& other) {}; - -private: - U64 mStartTime; - BlockTimerStackRecord mParentTimerData; -}; - -// this dummy function assists in allocating a block timer with stack-based lifetime. -// this is done by capturing the return value in a stack-allocated const reference variable. -// (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 BlockTimerStatHandle& timer) -{ - return BlockTimer(timer); -} - -// stores a "named" timer instance to be reused via multiple BlockTimer stack instances -class BlockTimerStatHandle -: public StatType -{ -public: - BlockTimerStatHandle(const char* name, const char* description = ""); - - TimeBlockTreeNode& getTreeNode() const; - BlockTimerStatHandle* getParent() const { return getTreeNode().getParent(); } - void setParent(BlockTimerStatHandle* parent) { getTreeNode().setParent(parent); } - - typedef std::vector::iterator child_iter; - typedef std::vector::const_iterator child_const_iter; - child_iter beginChildren(); - child_iter endChildren(); - bool hasChildren(); - std::vector& getChildren(); - - StatType& callCount() - { - return static_cast&>(*(StatType*)this); - } - - StatType& selfTime() - { - return static_cast&>(*(StatType*)this); - } - - static BlockTimerStatHandle& getRootTimeBlock(); - static void pushLog(LLSD sd); - static void setLogLock(class LLMutex* mutex); - static void writeLog(std::ostream& os); - static void updateTimes(); - - // dumps current cumulative frame stats to log - // call nextFrame() to reset timers - static void dumpCurTimes(); - - ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// // // Important note: These implementations must be FAST! // @@ -143,14 +73,14 @@ public: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 BlockTimerStatHandle::getCPUClockCount32() + //inline U32 getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 BlockTimerStatHandle::getCPUClockCount64() + //inline U64 getCPUClockCount64() //{ // return __rdtsc(); //} @@ -257,6 +187,12 @@ public: #endif + static BlockTimerStatHandle& getRootTimeBlock(); + static void pushLog(LLSD sd); + static void setLogLock(class LLMutex* mutex); + static void writeLog(std::ostream& os); + static void updateTimes(); + static U64 countsPerSecond(); // updates cumulative times and hierarchy, @@ -269,13 +205,79 @@ public: // call this once a frame to periodically log timers static void logStats(); - bool mCollapsed; // don't show children + // dumps current cumulative frame stats to log + // call nextFrame() to reset timers + static void dumpCurTimes(); + +private: + 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(BlockTimerStatHandle&); + + 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. + // This appears to be fixed in 2012. +public: +#endif + // no-copy + BlockTimer(const BlockTimer& other) {}; + +private: + U64 mStartTime; + BlockTimerStackRecord mParentTimerData; +public: // statics - static std::string sLogName; - static bool sMetricLog, - sLog; - static U64 sClockResolution; + static std::string sLogName; + static bool sMetricLog, + sLog; + static U64 sClockResolution; + +}; + +// this dummy function assists in allocating a block timer with stack-based lifetime. +// this is done by capturing the return value in a stack-allocated const reference variable. +// (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 BlockTimerStatHandle& timer) +{ + return BlockTimer(timer); +} + +// stores a "named" timer instance to be reused via multiple BlockTimer stack instances +class BlockTimerStatHandle +: public StatType +{ +public: + BlockTimerStatHandle(const char* name, const char* description = ""); + + TimeBlockTreeNode& getTreeNode() const; + BlockTimerStatHandle* getParent() const { return getTreeNode().getParent(); } + void setParent(BlockTimerStatHandle* parent) { getTreeNode().setParent(parent); } + + typedef std::vector::iterator child_iter; + typedef std::vector::const_iterator child_const_iter; + child_iter beginChildren(); + child_iter endChildren(); + bool hasChildren(); + std::vector& getChildren(); + + StatType& callCount() + { + return static_cast&>(*(StatType*)this); + } + + StatType& selfTime() + { + return static_cast&>(*(StatType*)this); + } + + bool mCollapsed; // don't show children }; // iterators and helper functions for walking the call hierarchy of block timers in different ways @@ -307,14 +309,14 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(BlockTimerStatHandle& timer) cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; - mStartTime = BlockTimerStatHandle::getCPUClockCount64(); + mStartTime = getCPUClockCount64(); #endif } LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if LL_FAST_TIMER_ON - U64 total_time = BlockTimerStatHandle::getCPUClockCount64() - mStartTime; + U64 total_time = getCPUClockCount64() - mStartTime; BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; -- cgit v1.2.3