summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/llmemory.cpp137
-rwxr-xr-xindra/llcommon/llmemory.h45
-rwxr-xr-xindra/llcommon/llthread.cpp39
-rw-r--r--indra/llcommon/lltrace.h3
-rw-r--r--indra/llcommon/lltraceaccumulators.h1
-rw-r--r--indra/llcommon/lltracerecording.cpp15
-rw-r--r--indra/llcommon/lltracerecording.h143
-rw-r--r--indra/llcommon/lltracethreadrecorder.cpp7
-rw-r--r--indra/llcommon/lltracethreadrecorder.h2
-rw-r--r--indra/llcommon/llunit.h5
10 files changed, 170 insertions, 227 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index c6b02df939..3fe7470d06 100755
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -27,9 +27,7 @@
#include "linden_common.h"
-//#if MEM_TRACK_MEM
#include "llthread.h"
-//#endif
#if defined(LL_WINDOWS)
# include <psapi.h>
@@ -422,141 +420,6 @@ U32 LLMemory::getWorkingSetSize()
#endif
//--------------------------------------------------------------------------------------------------
-#if MEM_TRACK_MEM
-#include "llframetimer.h"
-
-//static
-LLMemTracker* LLMemTracker::sInstance = NULL ;
-
-LLMemTracker::LLMemTracker()
-{
- mLastAllocatedMem = LLMemory::getWorkingSetSize() ;
- mCapacity = 128 ;
- mCurIndex = 0 ;
- mCounter = 0 ;
- mDrawnIndex = 0 ;
- mPaused = FALSE ;
-
- mMutexp = new LLMutex() ;
- mStringBuffer = new char*[128] ;
- mStringBuffer[0] = new char[mCapacity * 128] ;
- for(S32 i = 1 ; i < mCapacity ; i++)
- {
- mStringBuffer[i] = mStringBuffer[i-1] + 128 ;
- }
-}
-
-LLMemTracker::~LLMemTracker()
-{
- delete[] mStringBuffer[0] ;
- delete[] mStringBuffer;
- delete mMutexp ;
-}
-
-//static
-LLMemTracker* LLMemTracker::getInstance()
-{
- if(!sInstance)
- {
- sInstance = new LLMemTracker() ;
- }
- return sInstance ;
-}
-
-//static
-void LLMemTracker::release()
-{
- if(sInstance)
- {
- delete sInstance ;
- sInstance = NULL ;
- }
-}
-
-//static
-void LLMemTracker::track(const char* function, const int line)
-{
- static const S32 MIN_ALLOCATION = 0 ; //1KB
-
- if(mPaused)
- {
- return ;
- }
-
- U32 allocated_mem = LLMemory::getWorkingSetSize() ;
-
- LLMutexLock lock(mMutexp) ;
-
- S32 delta_mem = allocated_mem - mLastAllocatedMem ;
- mLastAllocatedMem = allocated_mem ;
-
- if(delta_mem <= 0)
- {
- return ; //occupied memory does not grow
- }
-
- if(delta_mem < MIN_ALLOCATION)
- {
- return ;
- }
-
- char* buffer = mStringBuffer[mCurIndex++] ;
- F32 time = (F32)LLFrameTimer::getElapsedSeconds() ;
- S32 hours = (S32)(time / (60*60));
- S32 mins = (S32)((time - hours*(60*60)) / 60);
- S32 secs = (S32)((time - hours*(60*60) - mins*60));
- strcpy(buffer, function) ;
- sprintf(buffer + strlen(function), " line: %d DeltaMem: %d (bytes) Time: %d:%02d:%02d", line, delta_mem, hours,mins,secs) ;
-
- if(mCounter < mCapacity)
- {
- mCounter++ ;
- }
- if(mCurIndex >= mCapacity)
- {
- mCurIndex = 0 ;
- }
-}
-
-
-//static
-void LLMemTracker::preDraw(BOOL pause)
-{
- mMutexp->lock() ;
-
- mPaused = pause ;
- mDrawnIndex = mCurIndex - 1;
- mNumOfDrawn = 0 ;
-}
-
-//static
-void LLMemTracker::postDraw()
-{
- mMutexp->unlock() ;
-}
-
-//static
-const char* LLMemTracker::getNextLine()
-{
- if(mNumOfDrawn >= mCounter)
- {
- return NULL ;
- }
- mNumOfDrawn++;
-
- if(mDrawnIndex < 0)
- {
- mDrawnIndex = mCapacity - 1 ;
- }
-
- return mStringBuffer[mDrawnIndex--] ;
-}
-
-#endif //MEM_TRACK_MEM
-//--------------------------------------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//minimum slot size and minimal slot size interval
const U32 ATOMIC_MEM_SLOT = 16 ; //bytes
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 95500753e4..a24d97576f 100755
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -184,51 +184,6 @@ private:
static BOOL sEnableMemoryFailurePrevention;
};
-//----------------------------------------------------------------------------
-#if MEM_TRACK_MEM
-class LLMutex ;
-class LL_COMMON_API LLMemTracker
-{
-private:
- LLMemTracker() ;
- ~LLMemTracker() ;
-
-public:
- static void release() ;
- static LLMemTracker* getInstance() ;
-
- void track(const char* function, const int line) ;
- void preDraw(BOOL pause) ;
- void postDraw() ;
- const char* getNextLine() ;
-
-private:
- static LLMemTracker* sInstance ;
-
- char** mStringBuffer ;
- S32 mCapacity ;
- U32 mLastAllocatedMem ;
- S32 mCurIndex ;
- S32 mCounter;
- S32 mDrawnIndex;
- S32 mNumOfDrawn;
- BOOL mPaused;
- LLMutex* mMutexp ;
-};
-
-#define MEM_TRACK_RELEASE LLMemTracker::release() ;
-#define MEM_TRACK LLMemTracker::getInstance()->track(__FUNCTION__, __LINE__) ;
-
-#else // MEM_TRACK_MEM
-
-#define MEM_TRACK_RELEASE
-#define MEM_TRACK
-
-#endif // MEM_TRACK_MEM
-
-//----------------------------------------------------------------------------
-
-
//
//class LLPrivateMemoryPool defines a private memory pool for an application to use, so the application does not
//need to access the heap directly fro each memory allocation. Throught this, the allocation speed is faster,
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 166a4eb26d..e0f53fb9c4 100755
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -39,6 +39,39 @@
#include <sched.h>
#endif
+
+#ifdef LL_WINDOWS
+const DWORD MS_VC_EXCEPTION=0x406D1388;
+
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+ DWORD dwType; // Must be 0x1000.
+ const char* szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+
+void SetThreadName( DWORD dwThreadID, const char* threadName)
+{
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = threadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
+
+ __try
+ {
+ RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );
+ }
+ __except(EXCEPTION_CONTINUE_EXECUTION)
+ {
+ }
+}
+#endif
+
+
//----------------------------------------------------------------------------
// Usage:
// void run_func(LLThread* thread)
@@ -93,6 +126,11 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
{
LLThread *threadp = (LLThread *)datap;
+#ifdef LL_WINDOWS
+ SetThreadName(-1, threadp->mName.c_str());
+#endif
+
+
LLTrace::ThreadRecorder thread_recorder(*LLTrace::get_master_thread_recorder());
#if !LL_DARWIN
@@ -224,6 +262,7 @@ void LLThread::start()
llwarns << "failed to start thread " << mName << llendl;
ll_apr_warn_status(status);
}
+
}
//============================================================================
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 2c45923aac..2c84b1596a 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -61,6 +61,7 @@ public:
virtual const char* getUnitLabel();
const std::string& getName() const { return mName; }
+ const std::string& getDescription() const { return mDescription; }
protected:
const std::string mName;
@@ -169,7 +170,7 @@ public:
typedef TraceType<CountAccumulator> trace_t;
CountStatHandle(const char* name, const char* description = NULL)
- : trace_t(name)
+ : trace_t(name, description)
{}
/*virtual*/ const char* getUnitLabel() { return LLGetUnitLabel<T>::getUnitLabel(); }
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index fac6347ff9..a2f9f4c090 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -37,7 +37,6 @@
namespace LLTrace
{
-
template<typename ACCUMULATOR>
class AccumulatorBuffer : public LLRefCount
{
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index f1388e7935..875c371068 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -38,10 +38,13 @@ namespace LLTrace
// Recording
///////////////////////////////////////////////////////////////////////
-Recording::Recording()
-: mElapsedSeconds(0)
+Recording::Recording(EPlayState state)
+: mElapsedSeconds(0),
+ mInHandOff(false)
+
{
mBuffers = new AccumulatorBufferGroup();
+ setPlayState(state);
}
Recording::Recording( const Recording& other )
@@ -101,7 +104,8 @@ void Recording::handleStart()
{
mSamplingTimer.reset();
mBuffers.setStayUnique(true);
- LLTrace::get_thread_recorder()->activate(mBuffers.write());
+ LLTrace::get_thread_recorder()->activate(mBuffers.write(), mInHandOff);
+ mInHandOff = false;
}
void Recording::handleStop()
@@ -113,6 +117,7 @@ void Recording::handleStop()
void Recording::handleSplitTo(Recording& other)
{
+ other.mInHandOff = true;
mBuffers.write()->handOffTo(*other.mBuffers.write());
}
@@ -485,6 +490,8 @@ void PeriodicRecording::handleStop()
void PeriodicRecording::handleReset()
{
+ getCurRecording().stop();
+
if (mAutoResize)
{
mRecordingPeriods.clear();
@@ -500,6 +507,7 @@ void PeriodicRecording::handleReset()
}
}
mCurPeriod = 0;
+ mNumPeriods = 0;
getCurRecording().setPlayState(getPlayState());
}
@@ -719,7 +727,6 @@ void LLStopWatchControlsMixinCommon::start()
handleStart();
break;
case STARTED:
- handleReset();
break;
default:
llassert(false);
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 7b0970ffdf..31616a52cc 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -124,11 +124,32 @@ namespace LLTrace
template<typename T>
class EventStatHandle;
+ template<typename T>
+ struct RelatedTypes
+ {
+ typedef F64 fractional_t;
+ typedef T sum_t;
+ };
+
+ template<typename T, typename UNIT_T>
+ struct RelatedTypes<LLUnit<T, UNIT_T> >
+ {
+ typedef LLUnit<typename RelatedTypes<T>::fractional_t, UNIT_T> fractional_t;
+ typedef LLUnit<typename RelatedTypes<T>::sum_t, UNIT_T> sum_t;
+ };
+
+ template<>
+ struct RelatedTypes<bool>
+ {
+ typedef F64 fractional_t;
+ typedef U32 sum_t;
+ };
+
class Recording
: public LLStopWatchControlsMixin<Recording>
{
public:
- Recording();
+ Recording(EPlayState state = LLStopWatchControlsMixinCommon::STOPPED);
Recording(const Recording& other);
~Recording();
@@ -172,16 +193,16 @@ namespace LLTrace
// CountStatHandle accessors
F64 getSum(const TraceType<CountAccumulator>& stat);
template <typename T>
- T getSum(const CountStatHandle<T>& stat)
+ typename RelatedTypes<T>::sum_t getSum(const CountStatHandle<T>& stat)
{
- return (T)getSum(static_cast<const TraceType<CountAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::sum_t)getSum(static_cast<const TraceType<CountAccumulator>&> (stat));
}
F64 getPerSec(const TraceType<CountAccumulator>& stat);
template <typename T>
- T getPerSec(const CountStatHandle<T>& stat)
+ typename RelatedTypes<T>::fractional_t getPerSec(const CountStatHandle<T>& stat)
{
- return (T)getPerSec(static_cast<const TraceType<CountAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::fractional_t)getPerSec(static_cast<const TraceType<CountAccumulator>&> (stat));
}
U32 getSampleCount(const TraceType<CountAccumulator>& stat);
@@ -197,9 +218,9 @@ namespace LLTrace
F64 getMean(const TraceType<SampleAccumulator>& stat);
template <typename T>
- T getMean(SampleStatHandle<T>& stat)
+ typename RelatedTypes<T>::fractional_t getMean(SampleStatHandle<T>& stat)
{
- return (T)getMean(static_cast<const TraceType<SampleAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::fractional_t)getMean(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
F64 getMax(const TraceType<SampleAccumulator>& stat);
@@ -211,9 +232,9 @@ namespace LLTrace
F64 getStandardDeviation(const TraceType<SampleAccumulator>& stat);
template <typename T>
- T getStandardDeviation(const SampleStatHandle<T>& stat)
+ typename RelatedTypes<T>::fractional_t getStandardDeviation(const SampleStatHandle<T>& stat)
{
- return (T)getStandardDeviation(static_cast<const TraceType<SampleAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::fractional_t)getStandardDeviation(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
F64 getLastValue(const TraceType<SampleAccumulator>& stat);
@@ -228,9 +249,9 @@ namespace LLTrace
// EventStatHandle accessors
F64 getSum(const TraceType<EventAccumulator>& stat);
template <typename T>
- T getSum(const EventStatHandle<T>& stat)
+ typename RelatedTypes<T>::sum_t getSum(const EventStatHandle<T>& stat)
{
- return (T)getSum(static_cast<const TraceType<EventAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::sum_t)getSum(static_cast<const TraceType<EventAccumulator>&> (stat));
}
F64 getMin(const TraceType<EventAccumulator>& stat);
@@ -249,16 +270,16 @@ namespace LLTrace
F64 getMean(const TraceType<EventAccumulator>& stat);
template <typename T>
- T getMean(EventStatHandle<T>& stat)
+ typename RelatedTypes<T>::fractional_t getMean(EventStatHandle<T>& stat)
{
- return (T)getMean(static_cast<const TraceType<EventAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::fractional_t)getMean(static_cast<const TraceType<EventAccumulator>&> (stat));
}
F64 getStandardDeviation(const TraceType<EventAccumulator>& stat);
template <typename T>
- T getStandardDeviation(const EventStatHandle<T>& stat)
+ typename RelatedTypes<T>::fractional_t getStandardDeviation(const EventStatHandle<T>& stat)
{
- return (T)getStandardDeviation(static_cast<const TraceType<EventAccumulator>&> (stat));
+ return (typename RelatedTypes<T>::fractional_t)getStandardDeviation(static_cast<const TraceType<EventAccumulator>&> (stat));
}
F64 getLastValue(const TraceType<EventAccumulator>& stat);
@@ -284,9 +305,11 @@ namespace LLTrace
// returns data for current thread
class ThreadRecorder* getThreadRecorder();
- LLTimer mSamplingTimer;
- LLUnit<F64, LLUnits::Seconds> mElapsedSeconds;
+ LLTimer mSamplingTimer;
+ LLUnit<F64, LLUnits::Seconds> mElapsedSeconds;
LLCopyOnWritePointer<AccumulatorBufferGroup> mBuffers;
+ bool mInHandOff;
+
};
class LL_COMMON_API PeriodicRecording
@@ -310,11 +333,15 @@ namespace LLTrace
const Recording& getPrevRecording(U32 offset) const;
Recording snapshotCurRecording() const;
+ //
+ // PERIODIC MIN
+ //
+
// catch all for stats that have a defined sum
template <typename T>
typename T::value_t getPeriodMin(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename T::value_t min_val = std::numeric_limits<typename T::value_t>::max();
@@ -326,6 +353,12 @@ namespace LLTrace
return min_val;
}
+ template<typename T>
+ T getPeriodMin(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return T(getPeriodMin(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
+ }
+
F64 getPeriodMin(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
template<typename T>
T getPeriodMin(const SampleStatHandle<T>& stat, size_t num_periods = U32_MAX)
@@ -341,9 +374,9 @@ namespace LLTrace
}
template <typename T>
- F64 getPeriodMinPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
+ typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMinPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 min_val = std::numeric_limits<F64>::max();
@@ -352,14 +385,24 @@ namespace LLTrace
S32 index = (mCurPeriod + total_periods - i) % total_periods;
min_val = llmin(min_val, mRecordingPeriods[index].getPerSec(stat));
}
- return min_val;
+ return (typename RelatedTypes<typename T::value_t>::fractional_t) min_val;
+ }
+
+ template<typename T>
+ typename RelatedTypes<T>::fractional_t getPeriodMinPerSec(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return typename RelatedTypes<T>::fractional_t(getPeriodMinPerSec(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
}
+ //
+ // PERIODIC MAX
+ //
+
// catch all for stats that have a defined sum
template <typename T>
typename T::value_t getPeriodMax(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename T::value_t max_val = std::numeric_limits<typename T::value_t>::min();
@@ -371,6 +414,12 @@ namespace LLTrace
return max_val;
}
+ template<typename T>
+ T getPeriodMax(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return T(getPeriodMax(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
+ }
+
F64 getPeriodMax(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
template<typename T>
T getPeriodMax(const SampleStatHandle<T>& stat, size_t num_periods = U32_MAX)
@@ -386,9 +435,9 @@ namespace LLTrace
}
template <typename T>
- F64 getPeriodMaxPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
+ typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMaxPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
F64 max_val = std::numeric_limits<F64>::min();
@@ -397,14 +446,24 @@ namespace LLTrace
S32 index = (mCurPeriod + total_periods - i) % total_periods;
max_val = llmax(max_val, mRecordingPeriods[index].getPerSec(stat));
}
- return max_val;
+ return (typename RelatedTypes<typename T::value_t>::fractional_t)max_val;
+ }
+
+ template<typename T>
+ typename RelatedTypes<T>::fractional_t getPeriodMaxPerSec(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return typename RelatedTypes<T>::fractional_t(getPeriodMaxPerSec(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
}
+ //
+ // PERIODIC MEAN
+ //
+
// catch all for stats that have a defined sum
template <typename T>
typename T::mean_t getPeriodMean(const TraceType<T >& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename T::mean_t mean = 0;
@@ -422,24 +481,29 @@ namespace LLTrace
return mean;
}
+ template<typename T>
+ typename RelatedTypes<T>::fractional_t getPeriodMean(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return typename RelatedTypes<T>::fractional_t(getPeriodMean(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
+ }
F64 getPeriodMean(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
template<typename T>
- T getPeriodMean(const SampleStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ typename RelatedTypes<T>::fractional_t getPeriodMean(const SampleStatHandle<T>& stat, size_t num_periods = U32_MAX)
{
- return T(getPeriodMean(static_cast<const TraceType<SampleAccumulator>&>(stat), num_periods));
+ return typename RelatedTypes<T>::fractional_t(getPeriodMean(static_cast<const TraceType<SampleAccumulator>&>(stat), num_periods));
}
F64 getPeriodMean(const TraceType<EventAccumulator>& stat, size_t num_periods = U32_MAX);
template<typename T>
- T getPeriodMean(const EventStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ typename RelatedTypes<T>::fractional_t getPeriodMean(const EventStatHandle<T>& stat, size_t num_periods = U32_MAX)
{
- return T(getPeriodMean(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
+ return typename RelatedTypes<T>::fractional_t(getPeriodMean(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
template <typename T>
- typename T::mean_t getPeriodMeanPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
+ typename RelatedTypes<typename T::mean_t>::fractional_t getPeriodMeanPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
+ size_t total_periods = mNumPeriods;
num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods);
typename T::mean_t mean = 0;
@@ -454,7 +518,13 @@ namespace LLTrace
}
}
mean = mean / num_periods;
- return mean;
+ return (typename RelatedTypes<typename T::mean_t>::fractional_t)mean;
+ }
+
+ template<typename T>
+ typename RelatedTypes<T>::fractional_t getPeriodMeanPerSec(const CountStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return typename RelatedTypes<T>::fractional_t(getPeriodMeanPerSec(static_cast<const TraceType<CountAccumulator>&>(stat), num_periods));
}
private:
@@ -504,11 +574,10 @@ namespace LLTrace
ExtendablePeriodicRecording();
void extend();
- PeriodicRecording& getAcceptedRecording() { return mAcceptedRecording; }
- const PeriodicRecording& getAcceptedRecording() const {return mAcceptedRecording;}
+ PeriodicRecording& getResults() { return mAcceptedRecording; }
+ const PeriodicRecording& getResults() const {return mAcceptedRecording;}
- PeriodicRecording& getPotentialRecording() { return mPotentialRecording; }
- const PeriodicRecording& getPotentialRecording() const {return mPotentialRecording;}
+ void nextPeriod() { mPotentialRecording.nextPeriod(); }
private:
// implementation for LLStopWatchControlsMixin
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp
index 7ac0e75154..e20d8b63de 100644
--- a/indra/llcommon/lltracethreadrecorder.cpp
+++ b/indra/llcommon/lltracethreadrecorder.cpp
@@ -120,13 +120,17 @@ TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode( S32 index )
}
-void ThreadRecorder::activate( AccumulatorBufferGroup* recording )
+void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_handoff )
{
ActiveRecording* active_recording = new ActiveRecording(recording);
if (!mActiveRecordings.empty())
{
AccumulatorBufferGroup& prev_active_recording = mActiveRecordings.back()->mPartialRecording;
prev_active_recording.sync();
+ if (!from_handoff)
+ {
+ TimeBlock::updateTimes();
+ }
prev_active_recording.handOffTo(active_recording->mPartialRecording);
}
mActiveRecordings.push_back(active_recording);
@@ -240,6 +244,7 @@ void ThreadRecorder::pushToParent()
{ LLMutexLock lock(&mSharedRecordingMutex);
LLTrace::get_thread_recorder()->bringUpToDate(&mThreadRecordingBuffers);
mSharedRecordingBuffers.append(mThreadRecordingBuffers);
+ mThreadRecordingBuffers.reset();
}
}
diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h
index 535f855200..c40228785e 100644
--- a/indra/llcommon/lltracethreadrecorder.h
+++ b/indra/llcommon/lltracethreadrecorder.h
@@ -47,7 +47,7 @@ namespace LLTrace
~ThreadRecorder();
- void activate(AccumulatorBufferGroup* recording);
+ void activate(AccumulatorBufferGroup* recording, bool from_handoff = false);
void deactivate(AccumulatorBufferGroup* recording);
active_recording_list_t::reverse_iterator bringUpToDate(AccumulatorBufferGroup* recording);
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index c9bbed5574..79465715cf 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -571,6 +571,11 @@ LL_DECLARE_DERIVED_UNIT(Gigahertz, "GHz", Megahertz, * 1000);
LL_DECLARE_BASE_UNIT(Radians, "rad");
LL_DECLARE_DERIVED_UNIT(Degrees, "deg", Radians, * 0.01745329251994);
+LL_DECLARE_BASE_UNIT(Percent, "%");
+LL_DECLARE_DERIVED_UNIT(Ratio, "x", Percent, / 100);
+
+LL_DECLARE_BASE_UNIT(Triangles, "tris");
+LL_DECLARE_DERIVED_UNIT(Kilotriangles, "ktris", Triangles, * 1000);
} // namespace LLUnits