summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/llqueuedthread.cpp2
-rw-r--r--indra/llcommon/llthread.cpp2
-rw-r--r--indra/llcommon/llthread.h5
-rw-r--r--indra/llcommon/lltrace.cpp71
-rw-r--r--indra/llcommon/lltrace.h63
-rw-r--r--indra/newview/llappviewer.cpp1
6 files changed, 93 insertions, 51 deletions
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 1738c16dea..a741d342d3 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -111,6 +111,8 @@ void LLQueuedThread::shutdown()
// virtual
S32 LLQueuedThread::update(F32 max_time_ms)
{
+ LLThread::getTraceData()->pushToMaster();
+
if (!mStarted)
{
if (!mThreaded)
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 2e6eb085dc..2ff524d9ba 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -66,7 +66,7 @@ U32 __thread LLThread::sThreadID = 0;
#endif
U32 LLThread::sIDIter = 0;
-LLThreadLocalPtr<LLTrace::SlaveThreadTrace> LLThread::sTraceData;
+LLThreadLocalPtr<LLTrace::ThreadTrace> LLThread::sTraceData;
LL_COMMON_API void assert_main_thread()
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 6889fab2c1..5cd287ec39 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -87,7 +87,8 @@ public:
U32 getID() const { return mID; }
- static LLTrace::ThreadTraceData* getTraceData() { return sTraceData.get(); }
+ static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); }
+ static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;}
private:
BOOL mPaused;
@@ -105,7 +106,7 @@ protected:
EThreadStatus mStatus;
U32 mID;
- static LLThreadLocalPtr<LLTrace::SlaveThreadTrace> sTraceData;
+ static LLThreadLocalPtr<LLTrace::ThreadTrace> sTraceData;
//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index 8cedcafd10..24a2b33a5f 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -72,7 +72,7 @@ void Sampler::resume()
getThreadTrace()->activate(this);
}
-class ThreadTraceData* Sampler::getThreadTrace()
+class ThreadTrace* Sampler::getThreadTrace()
{
return LLThread::getTraceData();
}
@@ -81,6 +81,64 @@ class ThreadTraceData* Sampler::getThreadTrace()
// MasterThreadTrace
///////////////////////////////////////////////////////////////////////
+ThreadTrace::ThreadTrace()
+{
+ mPrimarySampler.makePrimary();
+}
+
+ThreadTrace::ThreadTrace( const ThreadTrace& other ) : mPrimarySampler(other.mPrimarySampler)
+{
+ mPrimarySampler.makePrimary();
+}
+
+void ThreadTrace::activate( Sampler* sampler )
+{
+ flushPrimary();
+ mActiveSamplers.push_back(sampler);
+}
+
+void ThreadTrace::deactivate( Sampler* sampler )
+{
+ sampler->mergeFrom(mPrimarySampler);
+
+ // TODO: replace with intrusive list
+ std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler);
+ if (found_it != mActiveSamplers.end())
+ {
+ mActiveSamplers.erase(found_it);
+ }
+}
+
+void ThreadTrace::flushPrimary()
+{
+ for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end();
+ it != end_it;
+ ++it)
+ {
+ (*it)->mergeFrom(mPrimarySampler);
+ }
+ mPrimarySampler.reset();
+}
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+// SlaveThreadTrace
+///////////////////////////////////////////////////////////////////////
+
+void SlaveThreadTrace::pushToMaster()
+{
+ mSharedData.copyFrom(mPrimarySampler);
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// MasterThreadTrace
+///////////////////////////////////////////////////////////////////////
+
void MasterThreadTrace::pullFromSlaveThreads()
{
LLMutexLock lock(&mSlaveListMutex);
@@ -116,5 +174,16 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child )
}
}
+void MasterThreadTrace::pushToMaster()
+{
+
+}
+
+MasterThreadTrace::MasterThreadTrace()
+{
+ LLThread::setTraceData(this);
+}
+
+
}
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index e4bec0a644..601b5ed182 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -396,7 +396,7 @@ namespace LLTrace
private:
// returns data for current thread
- class ThreadTraceData* getThreadTrace();
+ class ThreadTrace* getThreadTrace();
AccumulatorBuffer<StatAccumulator<F32> > mF32Stats;
AccumulatorBuffer<StatAccumulator<S32> > mS32Stats;
@@ -404,48 +404,19 @@ namespace LLTrace
AccumulatorBuffer<TimerAccumulator> mTimers;
};
- class ThreadTraceData
+ class ThreadTrace
{
public:
- ThreadTraceData()
- {
- mPrimarySampler.makePrimary();
- }
-
- ThreadTraceData(const ThreadTraceData& other)
- : mPrimarySampler(other.mPrimarySampler)
- {
- mPrimarySampler.makePrimary();
- }
+ ThreadTrace();
+ ThreadTrace(const ThreadTrace& other);
- void activate(Sampler* sampler)
- {
- flushPrimary();
- mActiveSamplers.push_back(sampler);
- }
+ virtual ~ThreadTrace() {}
- void deactivate(Sampler* sampler)
- {
- sampler->mergeFrom(mPrimarySampler);
-
- // TODO: replace with intrusive list
- std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler);
- if (found_it != mActiveSamplers.end())
- {
- mActiveSamplers.erase(found_it);
- }
- }
+ void activate(Sampler* sampler);
+ void deactivate(Sampler* sampler);
+ void flushPrimary();
- void flushPrimary()
- {
- for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end();
- it != end_it;
- ++it)
- {
- (*it)->mergeFrom(mPrimarySampler);
- }
- mPrimarySampler.reset();
- }
+ virtual void pushToMaster() = 0;
Sampler* getPrimarySampler() { return &mPrimarySampler; }
protected:
@@ -453,15 +424,16 @@ namespace LLTrace
std::list<Sampler*> mActiveSamplers;
};
- class MasterThreadTrace : public ThreadTraceData
+ class MasterThreadTrace : public ThreadTrace
{
public:
- MasterThreadTrace()
- {}
+ MasterThreadTrace();
void addSlaveThread(class SlaveThreadTrace* child);
void removeSlaveThread(class SlaveThreadTrace* child);
+ /*virtual */ void pushToMaster();
+
// call this periodically to gather stats data from slave threads
void pullFromSlaveThreads();
@@ -480,12 +452,12 @@ namespace LLTrace
LLMutex mSlaveListMutex;
};
- class SlaveThreadTrace : public ThreadTraceData
+ class SlaveThreadTrace : public ThreadTrace
{
public:
explicit
SlaveThreadTrace()
- : ThreadTraceData(getMasterThreadTrace()),
+ : ThreadTrace(getMasterThreadTrace()),
mSharedData(mPrimarySampler)
{
getMasterThreadTrace().addSlaveThread(this);
@@ -497,10 +469,7 @@ namespace LLTrace
}
// call this periodically to gather stats data for master thread to consume
- void pushToParent()
- {
- mSharedData.copyFrom(mPrimarySampler);
- }
+ /*virtual*/ void pushToMaster();
MasterThreadTrace* mMaster;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c3ac615169..fcbef491fe 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1222,6 +1222,7 @@ bool LLAppViewer::mainLoop()
{
LLFastTimer _(FTM_FRAME);
LLFastTimer::nextFrame();
+ LLTrace::getMasterThreadTrace().pullFromSlaveThreads();
//clear call stack records
llclearcallstacks;