diff options
author | Richard Linden <none@none> | 2013-06-22 12:00:18 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-06-22 12:00:18 -0700 |
commit | 8bddaeec6647e735415f9bd72a4e1313e11fe720 (patch) | |
tree | eca49ce086d071a28a0fabd17342cf79955768d6 /indra/llcommon/lltracethreadrecorder.cpp | |
parent | 090fa057b5ff17170d846473a2bc9ebc315c99d3 (diff) |
fixed scene load monitor resetting to eagerly due to spurious camer amotion
pulled swap() out of ui time block
cleaned up internal lltrace dependencies, factored out common accumulator definitions
Diffstat (limited to 'indra/llcommon/lltracethreadrecorder.cpp')
-rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 108 |
1 files changed, 52 insertions, 56 deletions
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 54006f4e5b..c571e013e1 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -31,6 +31,7 @@ namespace LLTrace { +MasterThreadRecorder* gUIThreadRecorder = NULL; /////////////////////////////////////////////////////////////////////// // ThreadRecorder @@ -49,7 +50,7 @@ ThreadRecorder::ThreadRecorder() mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size(); mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes]; - mThreadRecording.start(); + activate(&mThreadRecordingBuffers); // initialize time block parent pointers for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); @@ -72,6 +73,8 @@ ThreadRecorder::ThreadRecorder() ThreadRecorder::~ThreadRecorder() { + deactivate(&mThreadRecordingBuffers); + delete mRootTimer; if (!mActiveRecordings.empty()) @@ -94,7 +97,7 @@ TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode(S32 index) } -void ThreadRecorder::activate( Recording* recording ) +void ThreadRecorder::activate( AccumulatorBufferGroup* recording ) { ActiveRecording* active_recording = new ActiveRecording(recording); if (!mActiveRecordings.empty()) @@ -106,7 +109,7 @@ void ThreadRecorder::activate( Recording* recording ) mActiveRecordings.back()->mPartialRecording.makePrimary(); } -ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringUpToDate( Recording* recording ) +ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording ) { if (mActiveRecordings.empty()) return mActiveRecordings.rend(); @@ -148,7 +151,7 @@ ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringU return it; } -void ThreadRecorder::deactivate( Recording* recording ) +void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) { active_recording_list_t::reverse_iterator it = bringUpToDate(recording); if (it != mActiveRecordings.rend()) @@ -168,14 +171,14 @@ void ThreadRecorder::deactivate( Recording* recording ) } } -ThreadRecorder::ActiveRecording::ActiveRecording( Recording* target ) +ThreadRecorder::ActiveRecording::ActiveRecording( AccumulatorBufferGroup* target ) : mTargetRecording(target) { } void ThreadRecorder::ActiveRecording::movePartialToTarget() { - mTargetRecording->mBuffers.write()->append(mPartialRecording); + mTargetRecording->append(mPartialRecording); // reset based on self to keep history mPartialRecording.reset(&mPartialRecording); } @@ -197,46 +200,14 @@ SlaveThreadRecorder::~SlaveThreadRecorder() } void SlaveThreadRecorder::pushToMaster() -{ - mThreadRecording.stop(); - { - LLMutexLock(mMasterRecorder.getSlaveListMutex()); - mSharedData.appendFrom(mThreadRecording); +{ + { LLMutexLock lock(&mSharedRecordingMutex); + mThreadRecordingBuffers.flush(); + LLTrace::get_thread_recorder()->bringUpToDate(&mThreadRecordingBuffers); + mSharedRecordingBuffers.append(mThreadRecordingBuffers); } - mThreadRecording.start(); -} - -void SlaveThreadRecorder::SharedData::appendFrom( const Recording& source ) -{ - LLMutexLock lock(&mRecordingMutex); - appendRecording(source); } -void SlaveThreadRecorder::SharedData::appendTo( Recording& sink ) -{ - LLMutexLock lock(&mRecordingMutex); - sink.appendRecording(*this); -} - -void SlaveThreadRecorder::SharedData::mergeFrom( const RecordingBuffers& source ) -{ - LLMutexLock lock(&mRecordingMutex); - mBuffers.write()->merge(source); -} - -void SlaveThreadRecorder::SharedData::mergeTo( RecordingBuffers& sink ) -{ - LLMutexLock lock(&mRecordingMutex); - sink.merge(*mBuffers); -} - -void SlaveThreadRecorder::SharedData::reset() -{ - LLMutexLock lock(&mRecordingMutex); - Recording::reset(); -} - - /////////////////////////////////////////////////////////////////////// // MasterThreadRecorder /////////////////////////////////////////////////////////////////////// @@ -247,29 +218,30 @@ void MasterThreadRecorder::pullFromSlaveThreads() LLFastTimer _(FTM_PULL_TRACE_DATA_FROM_SLAVES); if (mActiveRecordings.empty()) return; - LLMutexLock lock(&mSlaveListMutex); + { LLMutexLock lock(&mSlaveListMutex); - RecordingBuffers& target_recording_buffers = mActiveRecordings.back()->mPartialRecording; - for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); - it != end_it; - ++it) - { - // ignore block timing info for now - (*it)->mSharedData.mergeTo(target_recording_buffers); - (*it)->mSharedData.reset(); + AccumulatorBufferGroup& target_recording_buffers = mActiveRecordings.back()->mPartialRecording; + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); + it != end_it; + ++it) + { LLMutexLock lock(&(*it)->mSharedRecordingMutex); + + target_recording_buffers.merge((*it)->mSharedRecordingBuffers); + (*it)->mSharedRecordingBuffers.reset(); + } } } +// called by slave thread void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child ) -{ - LLMutexLock lock(&mSlaveListMutex); +{ LLMutexLock lock(&mSlaveListMutex); mSlaveThreadRecorders.push_back(child); } +// called by slave thread void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) -{ - LLMutexLock lock(&mSlaveListMutex); +{ LLMutexLock lock(&mSlaveListMutex); for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); it != end_it; @@ -289,4 +261,28 @@ void MasterThreadRecorder::pushToMaster() MasterThreadRecorder::MasterThreadRecorder() {} + +MasterThreadRecorder& getUIThreadRecorder() +{ + llassert(gUIThreadRecorder != NULL); + return *gUIThreadRecorder; +} + +LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder_ptr() +{ + static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; + return s_thread_recorder; +} + +const LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() +{ + return get_thread_recorder_ptr(); +} + +void set_thread_recorder(ThreadRecorder* recorder) +{ + get_thread_recorder_ptr() = recorder; +} + + } |