From ab5106535758393e02b075d1e404e4e1fcf81abf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 19:27:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed extra dereference for copy on write pointer moved copyonwrite mechanism to RecordingBuffers from individual buffer fixed logic that was leaving scene unfrozen when camera moved during metrics gathering --- indra/llcommon/lltracerecording.cpp | 173 ++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 97 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 4aa3a5a0f7..cced6546ba 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -40,37 +40,31 @@ namespace LLTrace /////////////////////////////////////////////////////////////////////// RecordingBuffers::RecordingBuffers() -: mCountsFloat(new AccumulatorBuffer >()), - mMeasurementsFloat(new AccumulatorBuffer >()), - mCounts(new AccumulatorBuffer >()), - mMeasurements(new AccumulatorBuffer >()), - mStackTimers(new AccumulatorBuffer()), - mMemStats(new AccumulatorBuffer()) {} void RecordingBuffers::handOffTo(RecordingBuffers& other) { - other.mCountsFloat.write()->reset(mCountsFloat); - other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); - other.mCounts.write()->reset(mCounts); - other.mMeasurements.write()->reset(mMeasurements); - other.mStackTimers.write()->reset(mStackTimers); - other.mMemStats.write()->reset(mMemStats); + other.mCountsFloat.reset(&mCountsFloat); + other.mMeasurementsFloat.reset(&mMeasurementsFloat); + other.mCounts.reset(&mCounts); + other.mMeasurements.reset(&mMeasurements); + other.mStackTimers.reset(&mStackTimers); + other.mMemStats.reset(&mMemStats); } void RecordingBuffers::makePrimary() { - mCountsFloat.write()->makePrimary(); - mMeasurementsFloat.write()->makePrimary(); - mCounts.write()->makePrimary(); - mMeasurements.write()->makePrimary(); - mStackTimers.write()->makePrimary(); - mMemStats.write()->makePrimary(); + mCountsFloat.makePrimary(); + mMeasurementsFloat.makePrimary(); + mCounts.makePrimary(); + mMeasurements.makePrimary(); + mStackTimers.makePrimary(); + mMemStats.makePrimary(); ThreadRecorder* thread_recorder = get_thread_recorder().get(); - AccumulatorBuffer& timer_accumulator_buffer = *mStackTimers.write(); + AccumulatorBuffer& timer_accumulator_buffer = mStackTimers; // update stacktimer parent pointers - for (S32 i = 0, end_i = mStackTimers->size(); i < end_i; i++) + for (S32 i = 0, end_i = mStackTimers.size(); i < end_i; i++) { TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); if (tree_node) @@ -82,46 +76,36 @@ void RecordingBuffers::makePrimary() bool RecordingBuffers::isPrimary() const { - return mCounts->isPrimary(); + return mCounts.isPrimary(); } -void RecordingBuffers::makeUnique() +void RecordingBuffers::append( const RecordingBuffers& other ) { - mCountsFloat.makeUnique(); - mMeasurementsFloat.makeUnique(); - mCounts.makeUnique(); - mMeasurements.makeUnique(); - mStackTimers.makeUnique(); - mMemStats.makeUnique(); + mCountsFloat.addSamples(other.mCountsFloat); + mMeasurementsFloat.addSamples(other.mMeasurementsFloat); + mCounts.addSamples(other.mCounts); + mMeasurements.addSamples(other.mMeasurements); + mMemStats.addSamples(other.mMemStats); + mStackTimers.addSamples(other.mStackTimers); } -void RecordingBuffers::appendBuffers( const RecordingBuffers& other ) +void RecordingBuffers::merge( const RecordingBuffers& other) { - mCountsFloat.write()->addSamples(*other.mCountsFloat); - mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); - mCounts.write()->addSamples(*other.mCounts); - mMeasurements.write()->addSamples(*other.mMeasurements); - mMemStats.write()->addSamples(*other.mMemStats); - mStackTimers.write()->addSamples(*other.mStackTimers); + mCountsFloat.addSamples(other.mCountsFloat); + mMeasurementsFloat.addSamples(other.mMeasurementsFloat); + mCounts.addSamples(other.mCounts); + mMeasurements.addSamples(other.mMeasurements); + mMemStats.addSamples(other.mMemStats); } -void RecordingBuffers::mergeBuffers( const RecordingBuffers& other) +void RecordingBuffers::reset(RecordingBuffers* other) { - mCountsFloat.write()->addSamples(*other.mCountsFloat); - mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); - mCounts.write()->addSamples(*other.mCounts); - mMeasurements.write()->addSamples(*other.mMeasurements); - mMemStats.write()->addSamples(*other.mMemStats); -} - -void RecordingBuffers::resetBuffers(RecordingBuffers* other) -{ - mCountsFloat.write()->reset(other ? other->mCountsFloat : LLCopyOnWritePointer > >()); - mMeasurementsFloat.write()->reset(other ? other->mMeasurementsFloat : LLCopyOnWritePointer > >()); - mCounts.write()->reset(other ? other->mCounts : LLCopyOnWritePointer > >()); - mMeasurements.write()->reset(other ? other->mMeasurements : LLCopyOnWritePointer > >()); - mStackTimers.write()->reset(other ? other->mStackTimers : LLCopyOnWritePointer >()); - mMemStats.write()->reset(other ? other->mMemStats : LLCopyOnWritePointer >()); + mCountsFloat.reset(other ? &other->mCountsFloat : NULL); + mMeasurementsFloat.reset(other ? &other->mMeasurementsFloat : NULL); + mCounts.reset(other ? &other->mCounts : NULL); + mMeasurements.reset(other ? &other->mMeasurements : NULL); + mStackTimers.reset(other ? &other->mStackTimers : NULL); + mMemStats.reset(other ? &other->mMemStats : NULL); } /////////////////////////////////////////////////////////////////////// @@ -130,22 +114,24 @@ void RecordingBuffers::resetBuffers(RecordingBuffers* other) Recording::Recording() : mElapsedSeconds(0) -{} +{ + mBuffers = new RecordingBuffers(); +} Recording::Recording( const Recording& other ) -: mSamplingTimer(other.mSamplingTimer) { Recording& mutable_other = const_cast(other); EPlayState other_play_state = other.getPlayState(); mutable_other.pause(); - appendBuffers(other); + mBuffers = other.mBuffers; LLStopWatchControlsMixin::setPlayState(other_play_state); mutable_other.setPlayState(other_play_state); // above call will clear mElapsedSeconds as a side effect, so copy it here mElapsedSeconds = other.mElapsedSeconds; + mSamplingTimer = other.mSamplingTimer; } @@ -166,7 +152,7 @@ void Recording::update() void Recording::handleReset() { - resetBuffers(); + mBuffers.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -187,42 +173,42 @@ void Recording::handleStop() void Recording::handleSplitTo(Recording& other) { - handOffTo(other); + mBuffers.write()->handOffTo(*other.mBuffers.write()); } void Recording::appendRecording( const Recording& other ) { - appendBuffers(other); + mBuffers.write()->append(*other.mBuffers); mElapsedSeconds += other.mElapsedSeconds; } void Recording::mergeRecording( const Recording& other) { - mergeBuffers(other); + mBuffers.write()->merge(*other.mBuffers); } LLUnit Recording::getSum(const TraceType& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } LLUnit Recording::getSum(const TraceType& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } U32 Recording::getSum(const TraceType& stat) const { - return (*mStackTimers)[stat.getIndex()].mCalls; + return mBuffers->mStackTimers[stat.getIndex()].mCalls; } LLUnit Recording::getPerSec(const TraceType& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); @@ -230,7 +216,7 @@ LLUnit Recording::getPerSec(const TraceType Recording::getPerSec(const TraceType& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); @@ -238,45 +224,45 @@ LLUnit Recording::getPerSec(const TraceType& stat) const { - return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; + return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds; } LLUnit Recording::getSum(const TraceType& stat) const { - return (*mMemStats)[stat.getIndex()].mAllocatedCount; + return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } LLUnit Recording::getPerSec(const TraceType& stat) const { - return (F32)(*mMemStats)[stat.getIndex()].mAllocatedCount / mElapsedSeconds; + return (F32)mBuffers->mMemStats[stat.getIndex()].mAllocatedCount / mElapsedSeconds; } F64 Recording::getSum( const TraceType >& stat ) const { - return (*mCountsFloat)[stat.getIndex()].getSum(); + return mBuffers->mCountsFloat[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType >& stat ) const { - return (*mCounts)[stat.getIndex()].getSum(); + return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const TraceType >& stat ) const { - return (F64)(*mMeasurementsFloat)[stat.getIndex()].getSum(); + return (F64)mBuffers->mMeasurementsFloat[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType >& stat ) const { - return (S64)(*mMeasurements)[stat.getIndex()].getSum(); + return (S64)mBuffers->mMeasurements[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const TraceType >& stat ) const { - F64 sum = (*mCountsFloat)[stat.getIndex()].getSum(); + F64 sum = mBuffers->mCountsFloat[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -284,7 +270,7 @@ F64 Recording::getPerSec( const TraceType >& stat ) const F64 Recording::getPerSec( const TraceType >& stat ) const { - S64 sum = (*mCounts)[stat.getIndex()].getSum(); + S64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; @@ -292,72 +278,72 @@ F64 Recording::getPerSec( const TraceType >& stat ) const U32 Recording::getSampleCount( const TraceType >& stat ) const { - return (*mCountsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); } F64 Recording::getMin( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMin(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMin(); } S64 Recording::getMin( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMin(); + return mBuffers->mMeasurements[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMax(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMax(); } S64 Recording::getMax( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMax(); + return mBuffers->mMeasurements[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMean(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMean(); } F64 Recording::getMean( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMean(); + return mBuffers->mMeasurements[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getStandardDeviation(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getStandardDeviation(); } F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getStandardDeviation(); + return mBuffers->mMeasurements[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getLastValue(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getLastValue(); } S64 Recording::getLastValue( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getLastValue(); + return mBuffers->mMeasurements[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurements[stat.getIndex()].getSampleCount(); } /////////////////////////////////////////////////////////////////////// @@ -366,16 +352,9 @@ U32 Recording::getSampleCount( const TraceType >& st PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), - mCurPeriod(0) + mCurPeriod(0), + mRecordingPeriods(num_periods ? num_periods : 1) { - if (mAutoResize) - { - num_periods = 1; - } - if (num_periods) - { - mRecordingPeriods.resize(num_periods); - } setPlayState(state); } @@ -552,7 +531,7 @@ void PeriodicRecording::handleReset() void PeriodicRecording::handleSplitTo(PeriodicRecording& other) { - getCurRecording().handOffTo(other.getCurRecording()); + getCurRecording().splitTo(other.getCurRecording()); } /////////////////////////////////////////////////////////////////////// @@ -589,7 +568,7 @@ void ExtendableRecording::handleReset() void ExtendableRecording::handleSplitTo(ExtendableRecording& other) { - mPotentialRecording.handOffTo(other.mPotentialRecording); + mPotentialRecording.splitTo(other.mPotentialRecording); } -- cgit v1.2.3