SH-3404 create sampler class
renamed LLTrace::ThreadTrace to LLTrace::ThreadRecorder renamed LLTrace::Sampler to LLTrace::Recordingmaster
parent
14b1b0b2bb
commit
dbe9742703
|
|
@ -101,7 +101,7 @@ set(llcommon_SOURCE_FILES
|
|||
llthreadsafequeue.cpp
|
||||
lltimer.cpp
|
||||
lltrace.cpp
|
||||
lltracesampler.cpp
|
||||
lltracerecording.cpp
|
||||
lluri.cpp
|
||||
lluuid.cpp
|
||||
llworkerthread.cpp
|
||||
|
|
@ -244,7 +244,7 @@ set(llcommon_HEADER_FILES
|
|||
llthreadsafequeue.h
|
||||
lltimer.h
|
||||
lltrace.h
|
||||
lltracesampler.h
|
||||
lltracerecording.h
|
||||
lltreeiterators.h
|
||||
lltypeinfolookup.h
|
||||
lluri.h
|
||||
|
|
|
|||
|
|
@ -486,29 +486,6 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset)
|
|||
//
|
||||
bool LLThreadLocalPointerBase::sInitialized = false;
|
||||
|
||||
LLThreadLocalPointerBase::LLThreadLocalPointerBase()
|
||||
: mThreadKey(NULL)
|
||||
{
|
||||
if (sInitialized)
|
||||
{
|
||||
initStorage();
|
||||
}
|
||||
}
|
||||
|
||||
LLThreadLocalPointerBase::LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other)
|
||||
: mThreadKey(NULL)
|
||||
{
|
||||
if (sInitialized)
|
||||
{
|
||||
initStorage();
|
||||
}
|
||||
}
|
||||
|
||||
LLThreadLocalPointerBase::~LLThreadLocalPointerBase()
|
||||
{
|
||||
destroyStorage();
|
||||
}
|
||||
|
||||
void LLThreadLocalPointerBase::set( void* value )
|
||||
{
|
||||
llassert(sInitialized && mThreadKey);
|
||||
|
|
|
|||
|
|
@ -261,9 +261,28 @@ public:
|
|||
class LLThreadLocalPointerBase : LLInstanceTracker<LLThreadLocalPointerBase>
|
||||
{
|
||||
public:
|
||||
LLThreadLocalPointerBase();
|
||||
LLThreadLocalPointerBase(const LLThreadLocalPointerBase& other);
|
||||
~LLThreadLocalPointerBase();
|
||||
LLThreadLocalPointerBase()
|
||||
: mThreadKey(NULL)
|
||||
{
|
||||
if (sInitialized)
|
||||
{
|
||||
initStorage();
|
||||
}
|
||||
}
|
||||
|
||||
LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other)
|
||||
: mThreadKey(NULL)
|
||||
{
|
||||
if (sInitialized)
|
||||
{
|
||||
initStorage();
|
||||
}
|
||||
}
|
||||
|
||||
~LLThreadLocalPointerBase()
|
||||
{
|
||||
destroyStorage();
|
||||
}
|
||||
|
||||
static void initAllThreadLocalStorage();
|
||||
static void destroyAllThreadLocalStorage();
|
||||
|
|
@ -312,7 +331,6 @@ class LLThreadLocalPointer : public LLThreadLocalPointerBase
|
|||
public:
|
||||
|
||||
LLThreadLocalPointer()
|
||||
: LLThreadLocalPointerBase()
|
||||
{}
|
||||
|
||||
explicit LLThreadLocalPointer(T* value)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ void LLQueuedThread::shutdown()
|
|||
// virtual
|
||||
S32 LLQueuedThread::update(F32 max_time_ms)
|
||||
{
|
||||
LLTrace::get_thread_trace()->pushToMaster();
|
||||
LLTrace::get_thread_recorder()->pushToMaster();
|
||||
|
||||
if (!mStarted)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
|
|||
{
|
||||
LLThread *threadp = (LLThread *)datap;
|
||||
|
||||
LLTrace::ThreadTrace* thread_trace = new LLTrace::SlaveThreadTrace();
|
||||
LLTrace::ThreadRecorder* thread_recorder = new LLTrace::SlaveThreadRecorder();
|
||||
|
||||
#if !LL_DARWIN
|
||||
sThreadIndex = threadp->mID;
|
||||
|
|
@ -99,7 +99,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
|
|||
// We're done with the run function, this thread is done executing now.
|
||||
threadp->mStatus = STOPPED;
|
||||
|
||||
delete thread_trace;
|
||||
delete thread_recorder;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,28 +26,28 @@
|
|||
#include "linden_common.h"
|
||||
|
||||
#include "lltrace.h"
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
|
||||
namespace LLTrace
|
||||
{
|
||||
|
||||
static MasterThreadTrace* gMasterThreadTrace = NULL;
|
||||
static MasterThreadRecorder* gMasterThreadRecorder = NULL;
|
||||
|
||||
void init()
|
||||
{
|
||||
gMasterThreadTrace = new MasterThreadTrace();
|
||||
gMasterThreadRecorder = new MasterThreadRecorder();
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
delete gMasterThreadTrace;
|
||||
gMasterThreadTrace = NULL;
|
||||
delete gMasterThreadRecorder;
|
||||
gMasterThreadRecorder = NULL;
|
||||
}
|
||||
|
||||
LLThreadLocalPointer<ThreadTrace>& get_thread_trace()
|
||||
LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder()
|
||||
{
|
||||
static LLThreadLocalPointer<ThreadTrace> s_trace_data;
|
||||
return s_trace_data;
|
||||
static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder;
|
||||
return s_thread_recorder;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -55,164 +55,161 @@ BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder;
|
|||
|
||||
|
||||
|
||||
MasterThreadTrace& getMasterThreadTrace()
|
||||
MasterThreadRecorder& getMasterThreadRecorder()
|
||||
{
|
||||
llassert(gMasterThreadTrace != NULL);
|
||||
return *gMasterThreadTrace;
|
||||
llassert(gMasterThreadRecorder != NULL);
|
||||
return *gMasterThreadRecorder;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// MasterThreadTrace
|
||||
// ThreadRecorder
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
ThreadTrace::ThreadTrace()
|
||||
ThreadRecorder::ThreadRecorder()
|
||||
{
|
||||
get_thread_trace() = this;
|
||||
mPrimarySampler.makePrimary();
|
||||
mTotalSampler.start();
|
||||
get_thread_recorder() = this;
|
||||
mPrimaryRecording.makePrimary();
|
||||
mFullRecording.start();
|
||||
}
|
||||
|
||||
ThreadTrace::ThreadTrace( const ThreadTrace& other )
|
||||
: mPrimarySampler(other.mPrimarySampler),
|
||||
mTotalSampler(other.mTotalSampler)
|
||||
ThreadRecorder::ThreadRecorder( const ThreadRecorder& other )
|
||||
: mPrimaryRecording(other.mPrimaryRecording),
|
||||
mFullRecording(other.mFullRecording)
|
||||
{
|
||||
get_thread_trace() = this;
|
||||
mPrimarySampler.makePrimary();
|
||||
mTotalSampler.start();
|
||||
get_thread_recorder() = this;
|
||||
mPrimaryRecording.makePrimary();
|
||||
mFullRecording.start();
|
||||
}
|
||||
|
||||
ThreadTrace::~ThreadTrace()
|
||||
ThreadRecorder::~ThreadRecorder()
|
||||
{
|
||||
get_thread_trace() = NULL;
|
||||
get_thread_recorder() = NULL;
|
||||
}
|
||||
|
||||
//TODO: remove this and use llviewerstats sampler
|
||||
Sampler* ThreadTrace::getPrimarySampler()
|
||||
//TODO: remove this and use llviewerstats recording
|
||||
Recording* ThreadRecorder::getPrimaryRecording()
|
||||
{
|
||||
return &mPrimarySampler;
|
||||
return &mPrimaryRecording;
|
||||
}
|
||||
|
||||
void ThreadTrace::activate( Sampler* sampler )
|
||||
void ThreadRecorder::activate( Recording* recorder )
|
||||
{
|
||||
for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end();
|
||||
for (std::list<Recording*>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end();
|
||||
it != end_it;
|
||||
++it)
|
||||
{
|
||||
(*it)->mMeasurements.write()->mergeSamples(*mPrimarySampler.mMeasurements);
|
||||
(*it)->mMeasurements.write()->mergeSamples(*mPrimaryRecording.mMeasurements);
|
||||
}
|
||||
mPrimarySampler.mMeasurements.write()->reset();
|
||||
mPrimaryRecording.mMeasurements.write()->reset();
|
||||
|
||||
sampler->initDeltas(mPrimarySampler);
|
||||
recorder->initDeltas(mPrimaryRecording);
|
||||
|
||||
mActiveSamplers.push_front(sampler);
|
||||
mActiveRecordings.push_front(recorder);
|
||||
}
|
||||
|
||||
//TODO: consider merging results down the list to one past the buffered item.
|
||||
// this would require 2 buffers per sampler, to separate current total from running total
|
||||
|
||||
void ThreadTrace::deactivate( Sampler* sampler )
|
||||
void ThreadRecorder::deactivate( Recording* recorder )
|
||||
{
|
||||
sampler->mergeDeltas(mPrimarySampler);
|
||||
recorder->mergeDeltas(mPrimaryRecording);
|
||||
|
||||
// TODO: replace with intrusive list
|
||||
std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler);
|
||||
if (found_it != mActiveSamplers.end())
|
||||
std::list<Recording*>::iterator found_it = std::find(mActiveRecordings.begin(), mActiveRecordings.end(), recorder);
|
||||
if (found_it != mActiveRecordings.end())
|
||||
{
|
||||
mActiveSamplers.erase(found_it);
|
||||
mActiveRecordings.erase(found_it);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// SlaveThreadTrace
|
||||
// SlaveThreadRecorder
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
SlaveThreadTrace::SlaveThreadTrace()
|
||||
: ThreadTrace(getMasterThreadTrace())
|
||||
SlaveThreadRecorder::SlaveThreadRecorder()
|
||||
: ThreadRecorder(getMasterThreadRecorder())
|
||||
{
|
||||
getMasterThreadTrace().addSlaveThread(this);
|
||||
getMasterThreadRecorder().addSlaveThread(this);
|
||||
}
|
||||
|
||||
SlaveThreadTrace::~SlaveThreadTrace()
|
||||
SlaveThreadRecorder::~SlaveThreadRecorder()
|
||||
{
|
||||
getMasterThreadTrace().removeSlaveThread(this);
|
||||
getMasterThreadRecorder().removeSlaveThread(this);
|
||||
}
|
||||
|
||||
void SlaveThreadTrace::pushToMaster()
|
||||
void SlaveThreadRecorder::pushToMaster()
|
||||
{
|
||||
mTotalSampler.stop();
|
||||
mFullRecording.stop();
|
||||
{
|
||||
LLMutexLock(getMasterThreadTrace().getSlaveListMutex());
|
||||
mSharedData.copyFrom(mTotalSampler);
|
||||
LLMutexLock(getMasterThreadRecorder().getSlaveListMutex());
|
||||
mSharedData.copyFrom(mFullRecording);
|
||||
}
|
||||
mTotalSampler.start();
|
||||
mFullRecording.start();
|
||||
}
|
||||
|
||||
void SlaveThreadTrace::SharedData::copyFrom( const Sampler& source )
|
||||
void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source )
|
||||
{
|
||||
LLMutexLock lock(&mSamplerMutex);
|
||||
mSampler.mergeSamples(source);
|
||||
LLMutexLock lock(&mRecorderMutex);
|
||||
mRecorder.mergeSamples(source);
|
||||
}
|
||||
|
||||
void SlaveThreadTrace::SharedData::copyTo( Sampler& sink )
|
||||
void SlaveThreadRecorder::SharedData::copyTo( Recording& sink )
|
||||
{
|
||||
LLMutexLock lock(&mSamplerMutex);
|
||||
sink.mergeSamples(mSampler);
|
||||
LLMutexLock lock(&mRecorderMutex);
|
||||
sink.mergeSamples(mRecorder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// MasterThreadTrace
|
||||
// MasterThreadRecorder
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MasterThreadTrace::pullFromSlaveThreads()
|
||||
void MasterThreadRecorder::pullFromSlaveThreads()
|
||||
{
|
||||
LLMutexLock lock(&mSlaveListMutex);
|
||||
|
||||
for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end();
|
||||
for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end();
|
||||
it != end_it;
|
||||
++it)
|
||||
{
|
||||
(*it)->mSlaveTrace->mSharedData.copyTo((*it)->mSamplerStorage);
|
||||
(*it)->mRecorder->mSharedData.copyTo((*it)->mSlaveRecording);
|
||||
}
|
||||
}
|
||||
|
||||
void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child )
|
||||
void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child )
|
||||
{
|
||||
LLMutexLock lock(&mSlaveListMutex);
|
||||
|
||||
mSlaveThreadTraces.push_back(new SlaveThreadTraceProxy(child));
|
||||
mSlaveThreadRecorders.push_back(new SlaveThreadRecorderProxy(child));
|
||||
}
|
||||
|
||||
void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child )
|
||||
void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child )
|
||||
{
|
||||
LLMutexLock lock(&mSlaveListMutex);
|
||||
|
||||
for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end();
|
||||
for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end();
|
||||
it != end_it;
|
||||
++it)
|
||||
{
|
||||
if ((*it)->mSlaveTrace == child)
|
||||
if ((*it)->mRecorder == child)
|
||||
{
|
||||
mSlaveThreadTraces.erase(it);
|
||||
mSlaveThreadRecorders.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MasterThreadTrace::pushToMaster()
|
||||
void MasterThreadRecorder::pushToMaster()
|
||||
{}
|
||||
|
||||
MasterThreadTrace::MasterThreadTrace()
|
||||
MasterThreadRecorder::MasterThreadRecorder()
|
||||
{}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// MasterThreadTrace::SlaveThreadTraceProxy
|
||||
// MasterThreadRecorder::SlaveThreadTraceProxy
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace)
|
||||
: mSlaveTrace(trace)
|
||||
MasterThreadRecorder::SlaveThreadRecorderProxy::SlaveThreadRecorderProxy( class SlaveThreadRecorder* recorder)
|
||||
: mRecorder(recorder)
|
||||
{}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include "llmemory.h"
|
||||
#include "lltimer.h"
|
||||
#include "llrefcount.h"
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
@ -45,14 +45,14 @@
|
|||
|
||||
namespace LLTrace
|
||||
{
|
||||
class Sampler;
|
||||
class Recording;
|
||||
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
LLThreadLocalPointer<class ThreadTrace>& get_thread_trace();
|
||||
LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder();
|
||||
|
||||
class LL_COMMON_API MasterThreadTrace& getMasterThreadTrace();
|
||||
class LL_COMMON_API MasterThreadRecorder& getMasterThreadRecorder();
|
||||
|
||||
// one per thread per type
|
||||
template<typename ACCUMULATOR>
|
||||
|
|
@ -482,33 +482,33 @@ namespace LLTrace
|
|||
static Recorder::StackEntry sCurRecorder;
|
||||
};
|
||||
|
||||
class LL_COMMON_API ThreadTrace
|
||||
class LL_COMMON_API ThreadRecorder
|
||||
{
|
||||
public:
|
||||
ThreadTrace();
|
||||
ThreadTrace(const ThreadTrace& other);
|
||||
ThreadRecorder();
|
||||
ThreadRecorder(const ThreadRecorder& other);
|
||||
|
||||
virtual ~ThreadTrace();
|
||||
virtual ~ThreadRecorder();
|
||||
|
||||
void activate(Sampler* sampler);
|
||||
void deactivate(Sampler* sampler);
|
||||
void activate(Recording* recording);
|
||||
void deactivate(Recording* recording);
|
||||
|
||||
virtual void pushToMaster() = 0;
|
||||
|
||||
Sampler* getPrimarySampler();
|
||||
Recording* getPrimaryRecording();
|
||||
protected:
|
||||
Sampler mPrimarySampler;
|
||||
Sampler mTotalSampler;
|
||||
std::list<Sampler*> mActiveSamplers;
|
||||
Recording mPrimaryRecording;
|
||||
Recording mFullRecording;
|
||||
std::list<Recording*> mActiveRecordings;
|
||||
};
|
||||
|
||||
class LL_COMMON_API MasterThreadTrace : public ThreadTrace
|
||||
class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder
|
||||
{
|
||||
public:
|
||||
MasterThreadTrace();
|
||||
MasterThreadRecorder();
|
||||
|
||||
void addSlaveThread(class SlaveThreadTrace* child);
|
||||
void removeSlaveThread(class SlaveThreadTrace* child);
|
||||
void addSlaveThread(class SlaveThreadRecorder* child);
|
||||
void removeSlaveThread(class SlaveThreadRecorder* child);
|
||||
|
||||
/*virtual */ void pushToMaster();
|
||||
|
||||
|
|
@ -518,41 +518,41 @@ namespace LLTrace
|
|||
LLMutex* getSlaveListMutex() { return &mSlaveListMutex; }
|
||||
|
||||
private:
|
||||
struct SlaveThreadTraceProxy
|
||||
struct SlaveThreadRecorderProxy
|
||||
{
|
||||
SlaveThreadTraceProxy(class SlaveThreadTrace* trace);
|
||||
SlaveThreadRecorderProxy(class SlaveThreadRecorder* recorder);
|
||||
|
||||
class SlaveThreadTrace* mSlaveTrace;
|
||||
Sampler mSamplerStorage;
|
||||
class SlaveThreadRecorder* mRecorder;
|
||||
Recording mSlaveRecording;
|
||||
private:
|
||||
//no need to copy these and then have to duplicate the storage
|
||||
SlaveThreadTraceProxy(const SlaveThreadTraceProxy& other) {}
|
||||
SlaveThreadRecorderProxy(const SlaveThreadRecorderProxy& other) {}
|
||||
};
|
||||
typedef std::list<SlaveThreadTraceProxy*> slave_thread_trace_list_t;
|
||||
typedef std::list<SlaveThreadRecorderProxy*> slave_thread_recorder_list_t;
|
||||
|
||||
slave_thread_trace_list_t mSlaveThreadTraces;
|
||||
slave_thread_recorder_list_t mSlaveThreadRecorders;
|
||||
LLMutex mSlaveListMutex;
|
||||
};
|
||||
|
||||
class LL_COMMON_API SlaveThreadTrace : public ThreadTrace
|
||||
class LL_COMMON_API SlaveThreadRecorder : public ThreadRecorder
|
||||
{
|
||||
public:
|
||||
SlaveThreadTrace();
|
||||
~SlaveThreadTrace();
|
||||
SlaveThreadRecorder();
|
||||
~SlaveThreadRecorder();
|
||||
|
||||
// call this periodically to gather stats data for master thread to consume
|
||||
/*virtual*/ void pushToMaster();
|
||||
|
||||
MasterThreadTrace* mMaster;
|
||||
MasterThreadRecorder* mMaster;
|
||||
|
||||
class SharedData
|
||||
{
|
||||
public:
|
||||
void copyFrom(const Sampler& source);
|
||||
void copyTo(Sampler& sink);
|
||||
void copyFrom(const Recording& source);
|
||||
void copyTo(Recording& sink);
|
||||
private:
|
||||
LLMutex mSamplerMutex;
|
||||
Sampler mSampler;
|
||||
LLMutex mRecorderMutex;
|
||||
Recording mRecorder;
|
||||
};
|
||||
SharedData mSharedData;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
#include "lltrace.h"
|
||||
#include "llthread.h"
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ namespace LLTrace
|
|||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Sampler
|
||||
// Recording
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sampler::Sampler()
|
||||
Recording::Recording()
|
||||
: mElapsedSeconds(0),
|
||||
mIsStarted(false),
|
||||
mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()),
|
||||
|
|
@ -47,17 +47,17 @@ Sampler::Sampler()
|
|||
{
|
||||
}
|
||||
|
||||
Sampler::~Sampler()
|
||||
Recording::~Recording()
|
||||
{
|
||||
}
|
||||
|
||||
void Sampler::start()
|
||||
void Recording::start()
|
||||
{
|
||||
reset();
|
||||
resume();
|
||||
}
|
||||
|
||||
void Sampler::reset()
|
||||
void Recording::reset()
|
||||
{
|
||||
mRates.write()->reset();
|
||||
mMeasurements.write()->reset();
|
||||
|
|
@ -67,54 +67,54 @@ void Sampler::reset()
|
|||
mSamplingTimer.reset();
|
||||
}
|
||||
|
||||
void Sampler::resume()
|
||||
void Recording::resume()
|
||||
{
|
||||
if (!mIsStarted)
|
||||
{
|
||||
mSamplingTimer.reset();
|
||||
LLTrace::get_thread_trace()->activate(this);
|
||||
LLTrace::get_thread_recorder()->activate(this);
|
||||
mIsStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Sampler::stop()
|
||||
void Recording::stop()
|
||||
{
|
||||
if (mIsStarted)
|
||||
{
|
||||
mElapsedSeconds += mSamplingTimer.getElapsedTimeF64();
|
||||
LLTrace::get_thread_trace()->deactivate(this);
|
||||
LLTrace::get_thread_recorder()->deactivate(this);
|
||||
mIsStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Sampler::makePrimary()
|
||||
void Recording::makePrimary()
|
||||
{
|
||||
mRates.write()->makePrimary();
|
||||
mMeasurements.write()->makePrimary();
|
||||
mStackTimers.write()->makePrimary();
|
||||
}
|
||||
|
||||
bool Sampler::isPrimary()
|
||||
bool Recording::isPrimary()
|
||||
{
|
||||
return mRates->isPrimary();
|
||||
}
|
||||
|
||||
void Sampler::mergeSamples( const Sampler& other )
|
||||
void Recording::mergeSamples( const Recording& other )
|
||||
{
|
||||
mRates.write()->mergeSamples(*other.mRates);
|
||||
mMeasurements.write()->mergeSamples(*other.mMeasurements);
|
||||
mStackTimers.write()->mergeSamples(*other.mStackTimers);
|
||||
}
|
||||
|
||||
void Sampler::initDeltas( const Sampler& other )
|
||||
void Recording::initDeltas( const Recording& other )
|
||||
{
|
||||
mRatesStart.write()->copyFrom(*other.mRates);
|
||||
mStackTimersStart.write()->copyFrom(*other.mStackTimers);
|
||||
}
|
||||
|
||||
|
||||
void Sampler::mergeDeltas( const Sampler& other )
|
||||
void Recording::mergeDeltas( const Recording& other )
|
||||
{
|
||||
mRates.write()->mergeDeltas(*mRatesStart, *other.mRates);
|
||||
mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers);
|
||||
|
|
@ -122,38 +122,38 @@ void Sampler::mergeDeltas( const Sampler& other )
|
|||
}
|
||||
|
||||
|
||||
F32 Sampler::getSum( Rate<F32>& stat )
|
||||
F32 Recording::getSum( Rate<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mRates).getSum();
|
||||
}
|
||||
|
||||
F32 Sampler::getSum( Measurement<F32>& stat )
|
||||
F32 Recording::getSum( Measurement<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mMeasurements).getSum();
|
||||
}
|
||||
|
||||
|
||||
F32 Sampler::getPerSec( Rate<F32>& stat )
|
||||
F32 Recording::getPerSec( Rate<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mRates).getSum() / mElapsedSeconds;
|
||||
}
|
||||
|
||||
F32 Sampler::getMin( Measurement<F32>& stat )
|
||||
F32 Recording::getMin( Measurement<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mMeasurements).getMin();
|
||||
}
|
||||
|
||||
F32 Sampler::getMax( Measurement<F32>& stat )
|
||||
F32 Recording::getMax( Measurement<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mMeasurements).getMax();
|
||||
}
|
||||
|
||||
F32 Sampler::getMean( Measurement<F32>& stat )
|
||||
F32 Recording::getMean( Measurement<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mMeasurements).getMean();
|
||||
}
|
||||
|
||||
F32 Sampler::getStandardDeviation( Measurement<F32>& stat )
|
||||
F32 Recording::getStandardDeviation( Measurement<F32>& stat )
|
||||
{
|
||||
return stat.getAccumulator(mMeasurements).getStandardDeviation();
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file lltracesampler.h
|
||||
* @file lltracerecording.h
|
||||
* @brief Sampling object for collecting runtime statistics originating from lltrace.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLTRACESAMPLER_H
|
||||
#define LL_LLTRACESAMPLER_H
|
||||
#ifndef LL_LLTRACERECORDING_H
|
||||
#define LL_LLTRACERECORDING_H
|
||||
|
||||
#include "stdtypes.h"
|
||||
#include "llpreprocessor.h"
|
||||
|
|
@ -42,12 +42,12 @@ namespace LLTrace
|
|||
template<typename T> class MeasurementAccumulator;
|
||||
class TimerAccumulator;
|
||||
|
||||
class LL_COMMON_API Sampler
|
||||
class LL_COMMON_API Recording
|
||||
{
|
||||
public:
|
||||
Sampler();
|
||||
Recording();
|
||||
|
||||
~Sampler();
|
||||
~Recording();
|
||||
|
||||
void makePrimary();
|
||||
bool isPrimary();
|
||||
|
|
@ -56,9 +56,9 @@ namespace LLTrace
|
|||
void stop();
|
||||
void resume();
|
||||
|
||||
void mergeSamples(const Sampler& other);
|
||||
void initDeltas(const Sampler& other);
|
||||
void mergeDeltas(const Sampler& other);
|
||||
void mergeSamples(const Recording& other);
|
||||
void initDeltas(const Recording& other);
|
||||
void mergeDeltas(const Recording& other);
|
||||
|
||||
void reset();
|
||||
|
||||
|
|
@ -76,9 +76,9 @@ namespace LLTrace
|
|||
F64 getSampleTime() { return mElapsedSeconds; }
|
||||
|
||||
private:
|
||||
friend class ThreadTrace;
|
||||
friend class ThreadRecorder;
|
||||
// returns data for current thread
|
||||
class ThreadTrace* getThreadTrace();
|
||||
class ThreadRecorder* getThreadRecorder();
|
||||
|
||||
LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRatesStart;
|
||||
LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates;
|
||||
|
|
@ -91,10 +91,10 @@ namespace LLTrace
|
|||
F64 mElapsedSeconds;
|
||||
};
|
||||
|
||||
class LL_COMMON_API PeriodicSampler
|
||||
class LL_COMMON_API PeriodicRecording
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LL_LLTRACESAMPLER_H
|
||||
#endif // LL_LLTRACERECORDING_H
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "llstat.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
@ -111,20 +111,20 @@ void LLStatBar::draw()
|
|||
}
|
||||
else if (mFloatStatp)
|
||||
{
|
||||
LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler();
|
||||
LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
|
||||
if (mPerSec)
|
||||
{
|
||||
current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime();
|
||||
//min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime();
|
||||
//max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime();
|
||||
//mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime();
|
||||
current = recording->getSum(*mFloatStatp) / recording->getSampleTime();
|
||||
//min = recording->getMin(*mFloatStatp) / recording->getSampleTime();
|
||||
//max = recording->getMax(*mFloatStatp) / recording->getSampleTime();
|
||||
//mean = recording->getMean(*mFloatStatp) / recording->getSampleTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
current = sampler->getSum(*mFloatStatp);
|
||||
//min = sampler->getMin(*mFloatStatp);
|
||||
//max = sampler->getMax(*mFloatStatp);
|
||||
//mean = sampler->getMean(*mFloatStatp);
|
||||
current = recording->getSum(*mFloatStatp);
|
||||
//min = recording->getMin(*mFloatStatp);
|
||||
//max = recording->getMax(*mFloatStatp);
|
||||
//mean = recording->getMean(*mFloatStatp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include "llstat.h"
|
||||
#include "llgl.h"
|
||||
#include "llglheaders.h"
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
//#include "llviewercontrol.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -85,15 +85,15 @@ void LLStatGraph::draw()
|
|||
}
|
||||
else if (mF32Statp)
|
||||
{
|
||||
LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler();
|
||||
LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
|
||||
|
||||
if (mPerSec)
|
||||
{
|
||||
mValue = sampler->getSum(*mF32Statp) / sampler->getSampleTime();
|
||||
mValue = recording->getSum(*mF32Statp) / recording->getSampleTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
mValue = sampler->getSum(*mF32Statp);
|
||||
mValue = recording->getSum(*mF32Statp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop()
|
|||
{
|
||||
LLFastTimer _(FTM_FRAME);
|
||||
LLFastTimer::nextFrame();
|
||||
LLTrace::getMasterThreadTrace().pullFromSlaveThreads();
|
||||
LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
|
||||
|
||||
//clear call stack records
|
||||
llclearcallstacks;
|
||||
|
|
|
|||
|
|
@ -276,12 +276,11 @@ LLViewerStats::LLViewerStats() :
|
|||
}
|
||||
|
||||
mAgentPositionSnaps.reset();
|
||||
mSampler->start();
|
||||
mRecording.start();
|
||||
}
|
||||
|
||||
LLViewerStats::~LLViewerStats()
|
||||
{
|
||||
delete mSampler;
|
||||
}
|
||||
|
||||
void LLViewerStats::resetStats()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
#include "llstat.h"
|
||||
#include "lltextureinfo.h"
|
||||
#include "lltracesampler.h"
|
||||
#include "lltracerecording.h"
|
||||
#include "lltrace.h"
|
||||
|
||||
extern LLTrace::Rate<F32> STAT_KBIT,
|
||||
STAT_LAYERS_KBIT,
|
||||
|
|
@ -297,11 +298,11 @@ public:
|
|||
static void recordPhaseStat(const std::string& phase_name, F32 value);
|
||||
};
|
||||
|
||||
LLTrace::Sampler* getSampler() { return mSampler; }
|
||||
LLTrace::Recording& getRecording() { return mRecording; }
|
||||
|
||||
private:
|
||||
F64 mStats[ST_COUNT];
|
||||
LLTrace::Sampler* mSampler;
|
||||
LLTrace::Recording mRecording;
|
||||
|
||||
F64 mLastTimeDiff; // used for time stat updates
|
||||
};
|
||||
|
|
|
|||
|
|
@ -622,9 +622,9 @@ void LLViewerTextureList::updateImages(F32 max_time)
|
|||
}
|
||||
cleared = FALSE;
|
||||
|
||||
LLTrace::Sampler* sampler = LLTrace::getThreadTrace()->getPrimarySampler();
|
||||
LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
|
||||
|
||||
LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime());
|
||||
LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(STAT_TEXTURE_KBIT));
|
||||
|
||||
LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
|
||||
LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
|
||||
|
|
|
|||
Loading…
Reference in New Issue