summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltrace.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/lltrace.cpp')
-rw-r--r--indra/llcommon/lltrace.cpp78
1 files changed, 56 insertions, 22 deletions
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index 6b4c3aeb06..6d928721de 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -66,18 +66,17 @@ MasterThreadRecorder& getMasterThreadRecorder()
///////////////////////////////////////////////////////////////////////
ThreadRecorder::ThreadRecorder()
+: mPrimaryRecording(NULL)
{
get_thread_recorder() = this;
- mPrimaryRecording.makePrimary();
mFullRecording.start();
}
ThreadRecorder::ThreadRecorder( const ThreadRecorder& other )
-: mPrimaryRecording(other.mPrimaryRecording),
- mFullRecording(other.mFullRecording)
+: mFullRecording(other.mFullRecording),
+ mPrimaryRecording(NULL)
{
get_thread_recorder() = this;
- mPrimaryRecording.makePrimary();
mFullRecording.start();
}
@@ -89,39 +88,74 @@ ThreadRecorder::~ThreadRecorder()
//TODO: remove this and use llviewerstats recording
Recording* ThreadRecorder::getPrimaryRecording()
{
- return &mPrimaryRecording;
+ return mPrimaryRecording;
}
-void ThreadRecorder::activate( Recording* recorder )
+void ThreadRecorder::activate( Recording* recording )
{
- for (std::list<Recording*>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end();
+ mActiveRecordings.push_front(ActiveRecording(mPrimaryRecording, recording));
+ mActiveRecordings.front().mBaseline.makePrimary();
+ mPrimaryRecording = &mActiveRecordings.front().mBaseline;
+}
+
+//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 ThreadRecorder::deactivate( Recording* recording )
+{
+ for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end();
it != end_it;
++it)
{
- (*it)->mMeasurements.write()->mergeSamples(*mPrimaryRecording.mMeasurements);
- }
- mPrimaryRecording.mMeasurements.write()->reset();
+ std::list<ActiveRecording>::iterator next_it = it;
+ if (++next_it != mActiveRecordings.end())
+ {
+ next_it->mergeMeasurements((*it));
+ }
- recorder->initDeltas(mPrimaryRecording);
+ it->flushAccumulators(mPrimaryRecording);
- mActiveRecordings.push_front(recorder);
+ if (it->mTargetRecording == recording)
+ {
+ if (next_it != mActiveRecordings.end())
+ {
+ next_it->mBaseline.makePrimary();
+ mPrimaryRecording = &next_it->mBaseline;
+ }
+ mActiveRecordings.erase(it);
+ break;
+ }
+ }
}
-//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 ThreadRecorder::deactivate( Recording* recorder )
+ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target )
+: mTargetRecording(target)
{
- recorder->mergeDeltas(mPrimaryRecording);
-
- // TODO: replace with intrusive list
- std::list<Recording*>::iterator found_it = std::find(mActiveRecordings.begin(), mActiveRecordings.end(), recorder);
- if (found_it != mActiveRecordings.end())
+ // take snapshots of current values rates and timers
+ if (source)
{
- mActiveRecordings.erase(found_it);
+ mBaseline.mRates.write()->copyFrom(*source->mRates);
+ mBaseline.mStackTimers.write()->copyFrom(*source->mStackTimers);
}
}
+void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other)
+{
+ mBaseline.mMeasurements.write()->mergeSamples(*other.mBaseline.mMeasurements);
+}
+
+void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current)
+{
+ // accumulate statistics-like measurements
+ mTargetRecording->mMeasurements.write()->mergeSamples(*mBaseline.mMeasurements);
+ // for rate-like measurements, merge total change since baseline
+ mTargetRecording->mRates.write()->mergeDeltas(*mBaseline.mRates, *current->mRates);
+ mTargetRecording->mStackTimers.write()->mergeDeltas(*mBaseline.mStackTimers, *current->mStackTimers);
+ // reset baselines
+ mBaseline.mRates.write()->copyFrom(*current->mRates);
+ mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers);
+}
+
///////////////////////////////////////////////////////////////////////
// SlaveThreadRecorder
///////////////////////////////////////////////////////////////////////