From dbe9742703cf14db85ec3d16c540efc68dce95a6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 2 Oct 2012 15:37:16 -0700 Subject: SH-3404 create sampler class renamed LLTrace::ThreadTrace to LLTrace::ThreadRecorder renamed LLTrace::Sampler to LLTrace::Recording --- indra/llcommon/lltracerecording.cpp | 167 ++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 indra/llcommon/lltracerecording.cpp (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp new file mode 100644 index 0000000000..a792d40f9d --- /dev/null +++ b/indra/llcommon/lltracerecording.cpp @@ -0,0 +1,167 @@ +/** + * @file lltracesampler.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltracerecording.h" +#include "lltrace.h" +#include "llthread.h" + +namespace LLTrace +{ + +/////////////////////////////////////////////////////////////////////// +// Recording +/////////////////////////////////////////////////////////////////////// + +Recording::Recording() +: mElapsedSeconds(0), + mIsStarted(false), + mRatesStart(new AccumulatorBuffer >()), + mRates(new AccumulatorBuffer >()), + mMeasurements(new AccumulatorBuffer >()), + mStackTimers(new AccumulatorBuffer()), + mStackTimersStart(new AccumulatorBuffer()) +{ +} + +Recording::~Recording() +{ +} + +void Recording::start() +{ + reset(); + resume(); +} + +void Recording::reset() +{ + mRates.write()->reset(); + mMeasurements.write()->reset(); + mStackTimers.write()->reset(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + +void Recording::resume() +{ + if (!mIsStarted) + { + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); + mIsStarted = true; + } +} + +void Recording::stop() +{ + if (mIsStarted) + { + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); + mIsStarted = false; + } +} + + +void Recording::makePrimary() +{ + mRates.write()->makePrimary(); + mMeasurements.write()->makePrimary(); + mStackTimers.write()->makePrimary(); +} + +bool Recording::isPrimary() +{ + return mRates->isPrimary(); +} + +void Recording::mergeSamples( const Recording& other ) +{ + mRates.write()->mergeSamples(*other.mRates); + mMeasurements.write()->mergeSamples(*other.mMeasurements); + mStackTimers.write()->mergeSamples(*other.mStackTimers); +} + +void Recording::initDeltas( const Recording& other ) +{ + mRatesStart.write()->copyFrom(*other.mRates); + mStackTimersStart.write()->copyFrom(*other.mStackTimers); +} + + +void Recording::mergeDeltas( const Recording& other ) +{ + mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); + mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); + mMeasurements.write()->mergeSamples(*other.mMeasurements); +} + + +F32 Recording::getSum( Rate& stat ) +{ + return stat.getAccumulator(mRates).getSum(); +} + +F32 Recording::getSum( Measurement& stat ) +{ + return stat.getAccumulator(mMeasurements).getSum(); +} + + +F32 Recording::getPerSec( Rate& stat ) +{ + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; +} + +F32 Recording::getMin( Measurement& stat ) +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F32 Recording::getMax( Measurement& stat ) +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F32 Recording::getMean( Measurement& stat ) +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F32 Recording::getStandardDeviation( Measurement& stat ) +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + + + + + + + +} -- cgit v1.2.3 From 7196619b4a0823a332e10b7f98464a1649e0dfd2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 2 Oct 2012 17:14:12 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible implemented minimal merging logic made recordings ligher weight by moving live tracking data into threadrecorder --- indra/llcommon/lltracerecording.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a792d40f9d..95cdb44e4b 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,17 +39,13 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), mIsStarted(false), - mRatesStart(new AccumulatorBuffer >()), mRates(new AccumulatorBuffer >()), mMeasurements(new AccumulatorBuffer >()), - mStackTimers(new AccumulatorBuffer()), - mStackTimersStart(new AccumulatorBuffer()) -{ -} + mStackTimers(new AccumulatorBuffer()) +{} Recording::~Recording() -{ -} +{} void Recording::start() { @@ -107,18 +103,10 @@ void Recording::mergeSamples( const Recording& other ) mStackTimers.write()->mergeSamples(*other.mStackTimers); } -void Recording::initDeltas( const Recording& other ) +void Recording::mergeDeltas(const Recording& baseline, const Recording& target) { - mRatesStart.write()->copyFrom(*other.mRates); - mStackTimersStart.write()->copyFrom(*other.mStackTimers); -} - - -void Recording::mergeDeltas( const Recording& other ) -{ - mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); - mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); - mMeasurements.write()->mergeSamples(*other.mMeasurements); + mRates.write()->mergeDeltas(*baseline.mRates, *target.mRates); + mStackTimers.write()->mergeDeltas(*baseline.mStackTimers, *target.mStackTimers); } -- cgit v1.2.3 From 3960fdf9e01619ddfd7903bcdd8d894f432752d0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 4 Oct 2012 23:11:57 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible moved threadrecorder classes into separate file added Count trace type, which tracks value increases and decreases and can report churn as well as overall growth rate --- indra/llcommon/lltracerecording.cpp | 54 ++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 95cdb44e4b..e4cff551f9 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -110,46 +110,80 @@ void Recording::mergeDeltas(const Recording& baseline, const Recording& target) } -F32 Recording::getSum( Rate& stat ) +F32 Recording::getSum(const Rate& stat) { return stat.getAccumulator(mRates).getSum(); } -F32 Recording::getSum( Measurement& stat ) +F32 Recording::getPerSec(const Rate& stat) { - return stat.getAccumulator(mMeasurements).getSum(); + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; } - -F32 Recording::getPerSec( Rate& stat ) +F32 Recording::getSum(const Measurement& stat) { - return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; + return stat.getAccumulator(mMeasurements).getSum(); } -F32 Recording::getMin( Measurement& stat ) +F32 Recording::getMin(const Measurement& stat) { return stat.getAccumulator(mMeasurements).getMin(); } -F32 Recording::getMax( Measurement& stat ) +F32 Recording::getMax(const Measurement& stat) { return stat.getAccumulator(mMeasurements).getMax(); } -F32 Recording::getMean( Measurement& stat ) +F32 Recording::getMean(const Measurement& stat) { return stat.getAccumulator(mMeasurements).getMean(); } -F32 Recording::getStandardDeviation( Measurement& stat ) +F32 Recording::getStandardDeviation(const Measurement& stat) { return stat.getAccumulator(mMeasurements).getStandardDeviation(); } +F32 Recording::getSum(const Count& stat) +{ + return getSum(stat.mTotal); +} + +F32 Recording::getPerSec(const Count& stat) +{ + return getPerSec(stat.mTotal); +} + +F32 Recording::getIncrease(const Count& stat) +{ + return getSum(stat.mIncrease); +} + +F32 Recording::getIncreasePerSec(const Count& stat) +{ + return getPerSec(stat.mIncrease); +} +F32 Recording::getDecrease(const Count& stat) +{ + return getSum(stat.mDecrease); +} +F32 Recording::getDecreasePerSec(const Count& stat) +{ + return getPerSec(stat.mDecrease); +} +F32 Recording::getChurn(const Count& stat) +{ + return getIncrease(stat) + getDecrease(stat); +} +F32 Recording::getChurnPerSec(const Count& stat) +{ + return getIncreasePerSec(stat) + getDecreasePerSec(stat); +} } -- cgit v1.2.3 From 4dce574a8d604a501ec3c12eef3f5d03ee188473 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 5 Oct 2012 10:51:38 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system added update() method to trace recorders to allow mid-collection snapshots --- indra/llcommon/lltracerecording.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e4cff551f9..c44cc8a8a7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -63,6 +63,12 @@ void Recording::reset() mSamplingTimer.reset(); } +void Recording::update() +{ + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + void Recording::resume() { if (!mIsStarted) -- cgit v1.2.3 From 960f8764ad2407add941bc8650b295f1e77beb19 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 5 Oct 2012 11:44:36 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system added update() method to trace recorders to allow mid-collection snapshots --- indra/llcommon/lltracerecording.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c44cc8a8a7..f0b17ef100 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -65,8 +65,12 @@ void Recording::reset() void Recording::update() { - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); + if (mIsStarted) + { + LLTrace::get_thread_recorder()->update(this); + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); + } } void Recording::resume() -- cgit v1.2.3 From aff9654c1115b4a74fc3ee8f9ca2c2ffa07f8d73 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 9 Oct 2012 18:02:47 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible added PeriodicRecorder class for frame by frame stats accumulation --- indra/llcommon/lltracerecording.cpp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e4cff551f9..7cd6280f03 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -38,7 +38,6 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mIsStarted(false), mRates(new AccumulatorBuffer >()), mMeasurements(new AccumulatorBuffer >()), mStackTimers(new AccumulatorBuffer()) @@ -47,13 +46,7 @@ Recording::Recording() Recording::~Recording() {} -void Recording::start() -{ - reset(); - resume(); -} - -void Recording::reset() +void Recording::handleReset() { mRates.write()->reset(); mMeasurements.write()->reset(); @@ -63,24 +56,22 @@ void Recording::reset() mSamplingTimer.reset(); } -void Recording::resume() +void Recording::handleStart() +{ + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); +} + +void Recording::handleStop() { - if (!mIsStarted) - { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); - mIsStarted = true; - } + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); } -void Recording::stop() +void Recording::handleSplitTo(Recording& other) { - if (mIsStarted) - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - mIsStarted = false; - } + stop(); + other.restart(); } -- cgit v1.2.3 From 8bb0a6ef737cb40c8f64f37fe64ecc7f6a87ae18 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 9 Oct 2012 18:07:31 -0700 Subject: post merge cleanup --- indra/llcommon/lltracerecording.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 93d2136e7f..d931c4ed29 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,16 @@ Recording::Recording() Recording::~Recording() {} +void Recording::update() +{ + if (isStarted()) + { + LLTrace::get_thread_recorder()->update(this); + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); + } +} + void Recording::handleReset() { mRates.write()->reset(); @@ -56,27 +66,17 @@ void Recording::handleReset() mSamplingTimer.reset(); } -void Recording::update() -{ - if (mIsStarted) - { - LLTrace::get_thread_recorder()->update(this); - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); - } -} - void Recording::handleStart() { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); } void Recording::handleStop() - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - } +{ + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); +} void Recording::handleSplitTo(Recording& other) { -- cgit v1.2.3 From 05510799e5a69eafcc919e72d25cf5b89c9274cf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 9 Oct 2012 22:18:07 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible renamed mergeSamples to mergeRecording --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index d931c4ed29..9a08770bd7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -97,7 +97,7 @@ bool Recording::isPrimary() return mRates->isPrimary(); } -void Recording::mergeSamples( const Recording& other ) +void Recording::mergeRecording( const Recording& other ) { mRates.write()->mergeSamples(*other.mRates); mMeasurements.write()->mergeSamples(*other.mMeasurements); -- cgit v1.2.3 From 74ac0182ec8f7a0f6d0ea89f5814f0998ab90b62 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 10 Oct 2012 19:25:56 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed units conversion so that trace getters return convertable units removed circular dependencies from lltrace* converted more stats to lltrace --- indra/llcommon/lltracerecording.cpp | 96 ++++--------------------------------- 1 file changed, 10 insertions(+), 86 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f0b17ef100..e20bf797e7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -25,8 +25,9 @@ #include "linden_common.h" -#include "lltracerecording.h" #include "lltrace.h" +#include "lltracerecording.h" +#include "lltracethreadrecorder.h" #include "llthread.h" namespace LLTrace @@ -101,99 +102,22 @@ void Recording::makePrimary() mStackTimers.write()->makePrimary(); } -bool Recording::isPrimary() +bool Recording::isPrimary() const { return mRates->isPrimary(); } -void Recording::mergeSamples( const Recording& other ) +void Recording::addSamples( const Recording& other ) { - mRates.write()->mergeSamples(*other.mRates); - mMeasurements.write()->mergeSamples(*other.mMeasurements); - mStackTimers.write()->mergeSamples(*other.mStackTimers); + mRates.write()->addSamples(*other.mRates); + mMeasurements.write()->addSamples(*other.mMeasurements); + mStackTimers.write()->addSamples(*other.mStackTimers); } -void Recording::mergeDeltas(const Recording& baseline, const Recording& target) +void Recording::addDeltas(const Recording& baseline, const Recording& target) { - mRates.write()->mergeDeltas(*baseline.mRates, *target.mRates); - mStackTimers.write()->mergeDeltas(*baseline.mStackTimers, *target.mStackTimers); + mRates.write()->addDeltas(*baseline.mRates, *target.mRates); + mStackTimers.write()->addDeltas(*baseline.mStackTimers, *target.mStackTimers); } - -F32 Recording::getSum(const Rate& stat) -{ - return stat.getAccumulator(mRates).getSum(); -} - -F32 Recording::getPerSec(const Rate& stat) -{ - return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; -} - -F32 Recording::getSum(const Measurement& stat) -{ - return stat.getAccumulator(mMeasurements).getSum(); -} - -F32 Recording::getMin(const Measurement& stat) -{ - return stat.getAccumulator(mMeasurements).getMin(); -} - -F32 Recording::getMax(const Measurement& stat) -{ - return stat.getAccumulator(mMeasurements).getMax(); -} - -F32 Recording::getMean(const Measurement& stat) -{ - return stat.getAccumulator(mMeasurements).getMean(); -} - -F32 Recording::getStandardDeviation(const Measurement& stat) -{ - return stat.getAccumulator(mMeasurements).getStandardDeviation(); -} - -F32 Recording::getSum(const Count& stat) -{ - return getSum(stat.mTotal); -} - -F32 Recording::getPerSec(const Count& stat) -{ - return getPerSec(stat.mTotal); -} - -F32 Recording::getIncrease(const Count& stat) -{ - return getSum(stat.mIncrease); -} - -F32 Recording::getIncreasePerSec(const Count& stat) -{ - return getPerSec(stat.mIncrease); -} - -F32 Recording::getDecrease(const Count& stat) -{ - return getSum(stat.mDecrease); -} - -F32 Recording::getDecreasePerSec(const Count& stat) -{ - return getPerSec(stat.mDecrease); -} - -F32 Recording::getChurn(const Count& stat) -{ - return getIncrease(stat) + getDecrease(stat); -} - -F32 Recording::getChurnPerSec(const Count& stat) -{ - return getIncreasePerSec(stat) + getDecreasePerSec(stat); -} - - } -- cgit v1.2.3 From 0f58ca02cdec62711eadb82ba28fcff08faef2ee Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Oct 2012 00:20:19 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible cleaned up accumulator merging logic introduced frame recording to LLTrace directly instead of going through LLViewerStats moved consumer code over to frame recording instead of whatever the current active recording was --- indra/llcommon/lltracerecording.cpp | 214 ++++++++++++++++++++++++++++++++++-- 1 file changed, 204 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0883930319..5d7b231b7d 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -68,16 +68,16 @@ void Recording::handleReset() } void Recording::handleStart() - { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); +{ + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); } void Recording::handleStop() - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - } +{ + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); +} void Recording::handleSplitTo(Recording& other) { @@ -105,10 +105,204 @@ void Recording::mergeRecording( const Recording& other ) mStackTimers.write()->addSamples(*other.mStackTimers); } -void Recording::mergeRecordingDelta(const Recording& baseline, const Recording& target) +/////////////////////////////////////////////////////////////////////// +// Recording +/////////////////////////////////////////////////////////////////////// + +PeriodicRecording::PeriodicRecording( S32 num_periods ) +: mNumPeriods(num_periods), + mCurPeriod(0), + mTotalValid(false), + mRecordingPeriods( new Recording[num_periods]) +{ + llassert(mNumPeriods > 0); +} + +PeriodicRecording::~PeriodicRecording() +{ + delete[] mRecordingPeriods; +} + + +void PeriodicRecording::nextPeriod() +{ + EPlayState play_state = getPlayState(); + getCurRecordingPeriod().stop(); + mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + switch(play_state) + { + case STOPPED: + break; + case PAUSED: + getCurRecordingPeriod().pause(); + break; + case STARTED: + getCurRecordingPeriod().start(); + break; + } + // new period, need to recalculate total + mTotalValid = false; +} + +Recording& PeriodicRecording::getTotalRecording() +{ + if (!mTotalValid) + { + mTotalRecording.reset(); + for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) + { + mTotalRecording.mergeRecording(mRecordingPeriods[i]); + } + } + mTotalValid = true; + return mTotalRecording; +} + +void PeriodicRecording::handleStart() +{ + getCurRecordingPeriod().handleStart(); +} + +void PeriodicRecording::handleStop() +{ + getCurRecordingPeriod().handleStop(); +} + +void PeriodicRecording::handleReset() +{ + getCurRecordingPeriod().handleReset(); +} + +void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) +{ + getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); +} + +/////////////////////////////////////////////////////////////////////// +// ExtendableRecording +/////////////////////////////////////////////////////////////////////// + +void ExtendableRecording::extend() { - mRates.write()->addDeltas(*baseline.mRates, *target.mRates); - mStackTimers.write()->addDeltas(*baseline.mStackTimers, *target.mStackTimers); + mAcceptedRecording.mergeRecording(mPotentialRecording); + mPotentialRecording.reset(); } +void ExtendableRecording::handleStart() +{ + mPotentialRecording.handleStart(); +} + +void ExtendableRecording::handleStop() +{ + mPotentialRecording.handleStop(); +} + +void ExtendableRecording::handleReset() +{ + mAcceptedRecording.handleReset(); + mPotentialRecording.handleReset(); +} + +void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) +{ + mPotentialRecording.handleSplitTo(other.mPotentialRecording); +} + +PeriodicRecording& get_frame_recording() +{ + static PeriodicRecording sRecording(64); + sRecording.start(); + return sRecording; +} + +} + +void LLVCRControlsMixinCommon::start() +{ + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::stop() +{ + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + handleStop(); + break; + case STARTED: + handleStop(); + break; + } + mPlayState = STOPPED; +} + +void LLVCRControlsMixinCommon::pause() +{ + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + break; + case STARTED: + handleStop(); + break; + } + mPlayState = PAUSED; +} + +void LLVCRControlsMixinCommon::resume() +{ + switch (mPlayState) + { + case STOPPED: + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::restart() +{ + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleReset(); + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::reset() +{ + handleReset(); } -- cgit v1.2.3 From 041dfccd1ea5b59c1b3c4e37e9a5495cad342c8f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Oct 2012 20:17:52 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system default to double precision now fixed unit conversion logic for LLUnit renamed LLTrace::Rate to LLTrace::Count and got rid of the old count as it was confusing some const correctness changes --- indra/llcommon/lltracerecording.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5d7b231b7d..9a769ff344 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,8 +39,8 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mRates(new AccumulatorBuffer >()), - mMeasurements(new AccumulatorBuffer >()), + mCounts(new AccumulatorBuffer >()), + mMeasurements(new AccumulatorBuffer >()), mStackTimers(new AccumulatorBuffer()) {} @@ -59,7 +59,7 @@ void Recording::update() void Recording::handleReset() { - mRates.write()->reset(); + mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); @@ -88,21 +88,22 @@ void Recording::handleSplitTo(Recording& other) void Recording::makePrimary() { - mRates.write()->makePrimary(); + mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); } bool Recording::isPrimary() const { - return mRates->isPrimary(); + return mCounts->isPrimary(); } void Recording::mergeRecording( const Recording& other ) { - mRates.write()->addSamples(*other.mRates); + mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); + mElapsedSeconds += other.mElapsedSeconds; } /////////////////////////////////////////////////////////////////////// @@ -149,9 +150,9 @@ Recording& PeriodicRecording::getTotalRecording() if (!mTotalValid) { mTotalRecording.reset(); - for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) + for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++) { - mTotalRecording.mergeRecording(mRecordingPeriods[i]); + mTotalRecording.mergeRecording(mRecordingPeriods[i % mNumPeriods]); } } mTotalValid = true; @@ -212,7 +213,6 @@ void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) PeriodicRecording& get_frame_recording() { static PeriodicRecording sRecording(64); - sRecording.start(); return sRecording; } -- cgit v1.2.3 From 819adb5eb4d7f982121f3dbd82750e05d26864d9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Nov 2012 00:26:44 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system final removal of remaining LLStat code --- indra/llcommon/lltracerecording.cpp | 119 +++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9a769ff344..f44a0a2764 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,8 +39,10 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mCounts(new AccumulatorBuffer >()), - mMeasurements(new AccumulatorBuffer >()), + mCountsFloat(new AccumulatorBuffer >()), + mMeasurementsFloat(new AccumulatorBuffer >()), + mCounts(new AccumulatorBuffer >()), + mMeasurements(new AccumulatorBuffer >()), mStackTimers(new AccumulatorBuffer()) {} @@ -59,6 +61,8 @@ void Recording::update() void Recording::handleReset() { + mCountsFloat.write()->reset(); + mMeasurementsFloat.write()->reset(); mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); @@ -88,6 +92,8 @@ void Recording::handleSplitTo(Recording& other) void Recording::makePrimary() { + mCountsFloat.write()->makePrimary(); + mMeasurementsFloat.write()->makePrimary(); mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); @@ -100,14 +106,120 @@ bool Recording::isPrimary() const void Recording::mergeRecording( const Recording& other ) { + mCountsFloat.write()->addSamples(*other.mCountsFloat); + mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); mElapsedSeconds += other.mElapsedSeconds; } +F64 Recording::getSum( const TraceType >& stat ) const +{ + return stat.getAccumulator(mCountsFloat).getSum(); +} + +S64 Recording::getSum( const TraceType >& stat ) const +{ + return stat.getAccumulator(mCounts).getSum(); +} + +F64 Recording::getSum( const TraceType >& stat ) const +{ + return (F64)stat.getAccumulator(mMeasurementsFloat).getSum(); +} + +S64 Recording::getSum( const TraceType >& stat ) const +{ + return (S64)stat.getAccumulator(mMeasurements).getSum(); +} + + + +F64 Recording::getPerSec( const TraceType >& stat ) const +{ + return stat.getAccumulator(mCountsFloat).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType >& stat ) const +{ + return (F64)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType >& stat ) const +{ + return (F64)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; +} + +F64 Recording::getMin( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMin(); +} + +S64 Recording::getMin( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F64 Recording::getMax( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMax(); +} + +S64 Recording::getMax( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F64 Recording::getMean( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMean(); +} + +F64 Recording::getMean( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F64 Recording::getStandardDeviation( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getStandardDeviation(); +} + +F64 Recording::getStandardDeviation( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + +F64 Recording::getLastValue( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getLastValue(); +} + +S64 Recording::getLastValue( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getLastValue(); +} + +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getSampleCount(); +} + +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getSampleCount(); +} + + + /////////////////////////////////////////////////////////////////////// -// Recording +// PeriodicRecording /////////////////////////////////////////////////////////////////////// PeriodicRecording::PeriodicRecording( S32 num_periods ) @@ -179,6 +291,7 @@ void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); } + /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 74fe126590fba03752d1d8d88dd3bb59c6900026 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Nov 2012 17:52:11 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system output of floater_stats is now identical to pre-lltrace system (with some tweaks) --- indra/llcommon/lltracerecording.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f44a0a2764..a2733fd0e7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -87,6 +87,8 @@ void Recording::handleSplitTo(Recording& other) { stop(); other.restart(); + other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); + other.mMeasurements.write()->reset(mMeasurements); } @@ -104,7 +106,7 @@ bool Recording::isPrimary() const return mCounts->isPrimary(); } -void Recording::mergeRecording( const Recording& other ) +void Recording::appendRecording( const Recording& other ) { mCountsFloat.write()->addSamples(*other.mCountsFloat); mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); @@ -138,22 +140,34 @@ S64 Recording::getSum( const TraceType >& stat ) con F64 Recording::getPerSec( const TraceType >& stat ) const { - return stat.getAccumulator(mCountsFloat).getSum() / mElapsedSeconds; + F64 sum = stat.getAccumulator(mCountsFloat).getSum(); + return (sum != 0.0) + ? (sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType >& stat ) const { - return (F64)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; + S64 sum = stat.getAccumulator(mCounts).getSum(); + return (sum != 0) + ? ((F64)sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getSum() / mElapsedSeconds; + F64 sum = stat.getAccumulator(mMeasurementsFloat).getSum(); + return (sum != 0.0) + ? (sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType >& stat ) const { - return (F64)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; + S64 sum = stat.getAccumulator(mMeasurements).getSum(); + return (sum != 0) + ? ((F64)sum / mElapsedSeconds) + : 0.0; } F64 Recording::getMin( const TraceType >& stat ) const @@ -240,17 +254,19 @@ PeriodicRecording::~PeriodicRecording() void PeriodicRecording::nextPeriod() { EPlayState play_state = getPlayState(); - getCurRecordingPeriod().stop(); + Recording& old_recording = getCurRecordingPeriod(); mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + old_recording.splitTo(getCurRecordingPeriod()); + switch(play_state) { case STOPPED: + getCurRecordingPeriod().stop(); break; case PAUSED: getCurRecordingPeriod().pause(); break; case STARTED: - getCurRecordingPeriod().start(); break; } // new period, need to recalculate total @@ -264,7 +280,7 @@ Recording& PeriodicRecording::getTotalRecording() mTotalRecording.reset(); for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++) { - mTotalRecording.mergeRecording(mRecordingPeriods[i % mNumPeriods]); + mTotalRecording.appendRecording(mRecordingPeriods[i % mNumPeriods]); } } mTotalValid = true; @@ -298,7 +314,7 @@ void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) void ExtendableRecording::extend() { - mAcceptedRecording.mergeRecording(mPotentialRecording); + mAcceptedRecording.appendRecording(mPotentialRecording); mPotentialRecording.reset(); } -- cgit v1.2.3 From bb6bda9eef48f5b08b56af46321b79fe7f1d49d7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Nov 2012 19:55:06 -0700 Subject: SH-3499 Ensure asset stats output is correct added support for specifying predicates for xui and llsd serialization --- indra/llcommon/lltracerecording.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a2733fd0e7..a8e1a5eec9 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -347,7 +347,7 @@ PeriodicRecording& get_frame_recording() } -void LLVCRControlsMixinCommon::start() +void LLStopWatchControlsMixinCommon::start() { switch (mPlayState) { @@ -365,7 +365,7 @@ void LLVCRControlsMixinCommon::start() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::stop() +void LLStopWatchControlsMixinCommon::stop() { switch (mPlayState) { @@ -381,7 +381,7 @@ void LLVCRControlsMixinCommon::stop() mPlayState = STOPPED; } -void LLVCRControlsMixinCommon::pause() +void LLStopWatchControlsMixinCommon::pause() { switch (mPlayState) { @@ -396,7 +396,7 @@ void LLVCRControlsMixinCommon::pause() mPlayState = PAUSED; } -void LLVCRControlsMixinCommon::resume() +void LLStopWatchControlsMixinCommon::resume() { switch (mPlayState) { @@ -412,7 +412,7 @@ void LLVCRControlsMixinCommon::resume() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::restart() +void LLStopWatchControlsMixinCommon::restart() { switch (mPlayState) { @@ -431,7 +431,7 @@ void LLVCRControlsMixinCommon::restart() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::reset() +void LLStopWatchControlsMixinCommon::reset() { handleReset(); } -- cgit v1.2.3 From 0007114cf5a60779319ab8cbd0a23a0d462b8010 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 5 Nov 2012 16:10:57 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct fixed copy behavior of recordings and accumulator buffers --- indra/llcommon/lltracerecording.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a8e1a5eec9..9cdd89c223 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -52,9 +52,8 @@ Recording::~Recording() void Recording::update() { if (isStarted()) -{ + { LLTrace::get_thread_recorder()->update(this); - mElapsedSeconds = 0.0; mSamplingTimer.reset(); } } -- cgit v1.2.3 From 860ff2f7e2a7fe932dfb7c148f0dbc0067018038 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 7 Nov 2012 00:38:21 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct fixed trace data gathering and routing from background thread simplified slave->master thread communication (eliminated redundant recording and proxy object) improved performance of fast timer data gathering (slow iterators) --- indra/llcommon/lltracerecording.cpp | 189 ++++++++++++++++++++++++++---------- 1 file changed, 138 insertions(+), 51 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9cdd89c223..435c49106f 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -117,29 +117,29 @@ void Recording::appendRecording( const Recording& other ) F64 Recording::getSum( const TraceType >& stat ) const { - return stat.getAccumulator(mCountsFloat).getSum(); + return (*mCountsFloat)[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType >& stat ) const { - return stat.getAccumulator(mCounts).getSum(); + return (*mCounts)[stat.getIndex()].getSum(); } F64 Recording::getSum( const TraceType >& stat ) const { - return (F64)stat.getAccumulator(mMeasurementsFloat).getSum(); + return (F64)(*mMeasurementsFloat)[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType >& stat ) const { - return (S64)stat.getAccumulator(mMeasurements).getSum(); + return (S64)(*mMeasurements)[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const TraceType >& stat ) const { - F64 sum = stat.getAccumulator(mCountsFloat).getSum(); + F64 sum = (*mCountsFloat)[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -147,15 +147,26 @@ F64 Recording::getPerSec( const TraceType >& stat ) const F64 Recording::getPerSec( const TraceType >& stat ) const { - S64 sum = stat.getAccumulator(mCounts).getSum(); + S64 sum = (*mCounts)[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; } +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return (*mCountsFloat)[stat.getIndex()].getSampleCount(); +} + +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); +} + + F64 Recording::getPerSec( const TraceType >& stat ) const { - F64 sum = stat.getAccumulator(mMeasurementsFloat).getSum(); + F64 sum = (*mMeasurementsFloat)[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -163,7 +174,7 @@ F64 Recording::getPerSec( const TraceType >& stat ) F64 Recording::getPerSec( const TraceType >& stat ) const { - S64 sum = stat.getAccumulator(mMeasurements).getSum(); + S64 sum = (*mMeasurements)[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; @@ -171,62 +182,62 @@ F64 Recording::getPerSec( const TraceType >& stat ) F64 Recording::getMin( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMin(); + return (*mMeasurementsFloat)[stat.getIndex()].getMin(); } S64 Recording::getMin( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getMin(); + return (*mMeasurements)[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMax(); + return (*mMeasurementsFloat)[stat.getIndex()].getMax(); } S64 Recording::getMax( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getMax(); + return (*mMeasurements)[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMean(); + return (*mMeasurementsFloat)[stat.getIndex()].getMean(); } F64 Recording::getMean( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getMean(); + return (*mMeasurements)[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getStandardDeviation(); + return (*mMeasurementsFloat)[stat.getIndex()].getStandardDeviation(); } F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getStandardDeviation(); + return (*mMeasurements)[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getLastValue(); + return (*mMeasurementsFloat)[stat.getIndex()].getLastValue(); } S64 Recording::getLastValue( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getLastValue(); + return (*mMeasurements)[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getSampleCount(); + return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType >& stat ) const { - return stat.getAccumulator(mMeasurements).getSampleCount(); + return (*mMeasurements)[stat.getIndex()].getSampleCount(); } @@ -235,13 +246,14 @@ U32 Recording::getSampleCount( const TraceType >& st // PeriodicRecording /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( S32 num_periods ) +PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state) : mNumPeriods(num_periods), mCurPeriod(0), mTotalValid(false), mRecordingPeriods( new Recording[num_periods]) { llassert(mNumPeriods > 0); + initTo(state); } PeriodicRecording::~PeriodicRecording() @@ -252,7 +264,7 @@ PeriodicRecording::~PeriodicRecording() void PeriodicRecording::nextPeriod() { - EPlayState play_state = getPlayState(); + EStopWatchState play_state = getPlayState(); Recording& old_recording = getCurRecordingPeriod(); mCurPeriod = (mCurPeriod + 1) % mNumPeriods; old_recording.splitTo(getCurRecordingPeriod()); @@ -286,24 +298,44 @@ Recording& PeriodicRecording::getTotalRecording() return mTotalRecording; } -void PeriodicRecording::handleStart() +void PeriodicRecording::start() +{ + getCurRecordingPeriod().start(); +} + +void PeriodicRecording::stop() +{ + getCurRecordingPeriod().stop(); +} + +void PeriodicRecording::pause() { - getCurRecordingPeriod().handleStart(); + getCurRecordingPeriod().pause(); } -void PeriodicRecording::handleStop() +void PeriodicRecording::resume() { - getCurRecordingPeriod().handleStop(); + getCurRecordingPeriod().resume(); } -void PeriodicRecording::handleReset() +void PeriodicRecording::restart() { - getCurRecordingPeriod().handleReset(); + getCurRecordingPeriod().restart(); } -void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) +void PeriodicRecording::reset() { - getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); + getCurRecordingPeriod().reset(); +} + +void PeriodicRecording::splitTo(PeriodicRecording& other) +{ + getCurRecordingPeriod().splitTo(other.getCurRecordingPeriod()); +} + +void PeriodicRecording::splitFrom(PeriodicRecording& other) +{ + getCurRecordingPeriod().splitFrom(other.getCurRecordingPeriod()); } @@ -317,38 +349,59 @@ void ExtendableRecording::extend() mPotentialRecording.reset(); } -void ExtendableRecording::handleStart() +void ExtendableRecording::start() { - mPotentialRecording.handleStart(); + mPotentialRecording.start(); } -void ExtendableRecording::handleStop() +void ExtendableRecording::stop() { - mPotentialRecording.handleStop(); + mPotentialRecording.stop(); } -void ExtendableRecording::handleReset() +void ExtendableRecording::pause() { - mAcceptedRecording.handleReset(); - mPotentialRecording.handleReset(); + mPotentialRecording.pause(); } -void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) +void ExtendableRecording::resume() { - mPotentialRecording.handleSplitTo(other.mPotentialRecording); + mPotentialRecording.resume(); +} + +void ExtendableRecording::restart() +{ + mAcceptedRecording.reset(); + mPotentialRecording.restart(); +} + +void ExtendableRecording::reset() +{ + mAcceptedRecording.reset(); + mPotentialRecording.reset(); +} + +void ExtendableRecording::splitTo(ExtendableRecording& other) +{ + mPotentialRecording.splitTo(other.mPotentialRecording); +} + +void ExtendableRecording::splitFrom(ExtendableRecording& other) +{ + mPotentialRecording.splitFrom(other.mPotentialRecording); } PeriodicRecording& get_frame_recording() { - static PeriodicRecording sRecording(64); - return sRecording; + static LLThreadLocalPointer sRecording(new PeriodicRecording(64, PeriodicRecording::STARTED)); + return *sRecording; } } void LLStopWatchControlsMixinCommon::start() { - switch (mPlayState) + switch (mState) { case STOPPED: handleReset(); @@ -360,13 +413,16 @@ void LLStopWatchControlsMixinCommon::start() case STARTED: handleReset(); break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::stop() { - switch (mPlayState) + switch (mState) { case STOPPED: break; @@ -376,13 +432,16 @@ void LLStopWatchControlsMixinCommon::stop() case STARTED: handleStop(); break; + default: + llassert(false); + break; } - mPlayState = STOPPED; + mState = STOPPED; } void LLStopWatchControlsMixinCommon::pause() { - switch (mPlayState) + switch (mState) { case STOPPED: break; @@ -391,13 +450,16 @@ void LLStopWatchControlsMixinCommon::pause() case STARTED: handleStop(); break; + default: + llassert(false); + break; } - mPlayState = PAUSED; + mState = PAUSED; } void LLStopWatchControlsMixinCommon::resume() { - switch (mPlayState) + switch (mState) { case STOPPED: handleStart(); @@ -407,13 +469,16 @@ void LLStopWatchControlsMixinCommon::resume() break; case STARTED: break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::restart() { - switch (mPlayState) + switch (mState) { case STOPPED: handleReset(); @@ -426,11 +491,33 @@ void LLStopWatchControlsMixinCommon::restart() case STARTED: handleReset(); break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::reset() { handleReset(); } + +void LLStopWatchControlsMixinCommon::initTo( EStopWatchState state ) +{ + switch(state) + { + case STOPPED: + break; + case PAUSED: + break; + case STARTED: + handleStart(); + break; + default: + llassert(false); + break; + } + + mState = state; +} -- cgit v1.2.3 From ed17c181dd37f56b808838748d289ee7bb5567ec Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 7 Nov 2012 15:32:12 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct further fixes to implicit conversion of unit types --- indra/llcommon/lltracerecording.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 435c49106f..4252ed57dc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,25 @@ Recording::Recording() mStackTimers(new AccumulatorBuffer()) {} +Recording::Recording( const Recording& other ) +{ + llassert(other.mCountsFloat.get() != NULL); + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; + mMeasurementsFloat = other.mMeasurementsFloat; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + + LLStopWatchControlsMixin::initTo(other.getPlayState()); + if (other.isStarted()) + { + handleStart(); + } +} + + Recording::~Recording() {} -- cgit v1.2.3 From 1c894c05c10ef37be6507ee4bc4e9173506adfb6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Nov 2012 17:26:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system hunting down bad values and crashes --- indra/llcommon/lltracerecording.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 4252ed57dc..e7ed55e8ae 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -66,7 +66,10 @@ Recording::Recording( const Recording& other ) Recording::~Recording() -{} +{ + stop(); + llassert(isStopped()); +} void Recording::update() { -- cgit v1.2.3 From ca37317a1473bb79ef8de4f683231700cb9e062c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 30 Nov 2012 15:48:22 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed crash when sending viewer asset stats --- indra/llcommon/lltracerecording.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e7ed55e8ae..e31e36cb27 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -58,10 +58,6 @@ Recording::Recording( const Recording& other ) mStackTimers = other.mStackTimers; LLStopWatchControlsMixin::initTo(other.getPlayState()); - if (other.isStarted()) - { - handleStart(); - } } @@ -127,6 +123,15 @@ bool Recording::isPrimary() const return mCounts->isPrimary(); } +void Recording::makeUnique() +{ + mCountsFloat.makeUnique(); + mMeasurementsFloat.makeUnique(); + mCounts.makeUnique(); + mMeasurements.makeUnique(); + mStackTimers.makeUnique(); +} + void Recording::appendRecording( const Recording& other ) { mCountsFloat.write()->addSamples(*other.mCountsFloat); -- cgit v1.2.3 From 13e4edf1cd664864afa585bc83bbe99d4f743326 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Dec 2012 23:00:36 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system started moving fast timer historical stats over to LLTrace periodic recording --- indra/llcommon/lltracerecording.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e31e36cb27..ff3ae1e553 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lltrace.h" +#include "llfasttimer.h" #include "lltracerecording.h" #include "lltracethreadrecorder.h" #include "llthread.h" @@ -142,6 +143,16 @@ void Recording::appendRecording( const Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } +LLUnit Recording::getSum(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond(); +} + +LLUnit Recording::getPerSec(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds); +} + F64 Recording::getSum( const TraceType >& stat ) const { return (*mCountsFloat)[stat.getIndex()].getSum(); -- cgit v1.2.3 From 407e5013f3845208e0a60e26e8f0a7fad997df5d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 3 Dec 2012 19:54:53 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system converted fast timer view over to new lltrace mechanisms --- indra/llcommon/lltracerecording.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ff3ae1e553..0d4d07faf6 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,7 +44,7 @@ Recording::Recording() mMeasurementsFloat(new AccumulatorBuffer >()), mCounts(new AccumulatorBuffer >()), mMeasurements(new AccumulatorBuffer >()), - mStackTimers(new AccumulatorBuffer()) + mStackTimers(new AccumulatorBuffer()) {} Recording::Recording( const Recording& other ) @@ -143,16 +143,27 @@ void Recording::appendRecording( const Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -LLUnit Recording::getSum(const TraceType& stat) const +LLUnit Recording::getSum(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond(); + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); } -LLUnit Recording::getPerSec(const TraceType& stat) const +U32 Recording::getSum(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds); + return (*mStackTimers)[stat.getIndex()].mCalls; } +LLUnit Recording::getPerSec(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); +} + +F32 Recording::getPerSec(const TraceType& stat) const +{ + return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; +} + + F64 Recording::getSum( const TraceType >& stat ) const { return (*mCountsFloat)[stat.getIndex()].getSum(); -- cgit v1.2.3 From 6c7825107f6ebb3dd8697a52aeb5d29a93060dc4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Dec 2012 19:10:02 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added copy constructor to periodic recording to allow snapshot generation in fast timer view fixed build errors --- indra/llcommon/lltracerecording.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0d4d07faf6..7ed7e57570 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -305,6 +305,20 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state) initTo(state); } +PeriodicRecording::PeriodicRecording(PeriodicRecording& other) +: mNumPeriods(other.mNumPeriods), + mCurPeriod(other.mCurPeriod), + mTotalValid(other.mTotalValid), + mTotalRecording(other.mTotalRecording) +{ + mRecordingPeriods = new Recording[mNumPeriods]; + for (S32 i = 0; i < mNumPeriods; i++) + { + mRecordingPeriods[i] = other.mRecordingPeriods[i]; + } +} + + PeriodicRecording::~PeriodicRecording() { delete[] mRecordingPeriods; -- cgit v1.2.3 From 60800dacdd7e9b66ed654af471f2b9e9680cd981 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Dec 2012 00:37:15 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed gcc compile error made LLCopyOnWritePointer contain an LLPointer, not derive from it added type trait to control periodicrecording mean value type --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 7ed7e57570..e9b3376dae 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -49,7 +49,7 @@ Recording::Recording() Recording::Recording( const Recording& other ) { - llassert(other.mCountsFloat.get() != NULL); + llassert(other.mCountsFloat.notNull()); mSamplingTimer = other.mSamplingTimer; mElapsedSeconds = other.mElapsedSeconds; mCountsFloat = other.mCountsFloat; -- cgit v1.2.3 From 8c2e3bea71ea15b805a9e2a288744f10d195d803 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 9 Dec 2012 23:19:11 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added ability to query self time of block timers indepedently --- indra/llcommon/lltracerecording.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e9b3376dae..3ea511ff3c 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -144,16 +144,27 @@ void Recording::appendRecording( const Recording& other ) } LLUnit Recording::getSum(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); +} + +LLUnit Recording::getSum(const TraceType& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); } + U32 Recording::getSum(const TraceType& stat) const { return (*mStackTimers)[stat.getIndex()].mCalls; } LLUnit Recording::getPerSec(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); +} + +LLUnit Recording::getPerSec(const TraceType& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } -- cgit v1.2.3 From c219282f5de753a044cecb53bd806145f68add9a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Dec 2012 20:07:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed some potential data races got memory stats recording in trace system --- indra/llcommon/lltracerecording.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 3ea511ff3c..40079f40f1 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,7 +44,8 @@ Recording::Recording() mMeasurementsFloat(new AccumulatorBuffer >()), mCounts(new AccumulatorBuffer >()), mMeasurements(new AccumulatorBuffer >()), - mStackTimers(new AccumulatorBuffer()) + mStackTimers(new AccumulatorBuffer()), + mMemStats(new AccumulatorBuffer()) {} Recording::Recording( const Recording& other ) @@ -57,6 +58,7 @@ Recording::Recording( const Recording& other ) mCounts = other.mCounts; mMeasurements = other.mMeasurements; mStackTimers = other.mStackTimers; + mMemStats = other.mMemStats; LLStopWatchControlsMixin::initTo(other.getPlayState()); } @@ -84,6 +86,7 @@ void Recording::handleReset() mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); + mMemStats.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -98,6 +101,7 @@ void Recording::handleStart() void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::TimeBlock::processTimes(); LLTrace::get_thread_recorder()->deactivate(this); } @@ -107,9 +111,9 @@ void Recording::handleSplitTo(Recording& other) other.restart(); other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); other.mMeasurements.write()->reset(mMeasurements); + //TODO: figure out how to get seamless handoff of timing stats } - void Recording::makePrimary() { mCountsFloat.write()->makePrimary(); @@ -117,6 +121,7 @@ void Recording::makePrimary() mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); + mMemStats.write()->makePrimary(); } bool Recording::isPrimary() const @@ -131,6 +136,7 @@ void Recording::makeUnique() mCounts.makeUnique(); mMeasurements.makeUnique(); mStackTimers.makeUnique(); + mMemStats.makeUnique(); } void Recording::appendRecording( const Recording& other ) @@ -140,6 +146,7 @@ void Recording::appendRecording( const Recording& other ) mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); + mMemStats.write()->addSamples(*other.mMemStats); mElapsedSeconds += other.mElapsedSeconds; } @@ -174,6 +181,16 @@ F32 Recording::getPerSec(const TraceType& return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; } +LLUnit Recording::getSum(const TraceType& stat) const +{ + return (*mMemStats)[stat.getIndex()].mAllocatedCount; +} + +LLUnit Recording::getPerSec(const TraceType& stat) const +{ + return (F32)(*mMemStats)[stat.getIndex()].mAllocatedCount / mElapsedSeconds; +} + F64 Recording::getSum( const TraceType >& stat ) const { -- cgit v1.2.3 From 013f04cabec8e110ee659d9b3f75a4d25f114b7b Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Dec 2012 00:13:21 -0800 Subject: SH-3468 WIP add memory tracking base class improvements on lifetime of lltrace core data structures tweaks to thread local pointer handling so that static constructors/destructors can safely call functions that use lltrace --- indra/llcommon/lltracerecording.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 40079f40f1..9dbafc4e82 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -122,6 +122,18 @@ void Recording::makePrimary() mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); mMemStats.write()->makePrimary(); + + ThreadRecorder* thread_recorder = get_thread_recorder().get(); + AccumulatorBuffer& timer_accumulator_buffer = *mStackTimers.write(); + // update stacktimer parent pointers + for (S32 i = 0, end_i = mStackTimers->size(); i < end_i; i++) + { + TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); + if (tree_node) + { + timer_accumulator_buffer[i].mParent = tree_node->mParent; + } + } } bool Recording::isPrimary() const @@ -145,11 +157,21 @@ void Recording::appendRecording( const Recording& other ) mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); - mStackTimers.write()->addSamples(*other.mStackTimers); mMemStats.write()->addSamples(*other.mMemStats); + + mStackTimers.write()->addSamples(*other.mStackTimers); mElapsedSeconds += other.mElapsedSeconds; } +void Recording::mergeRecording( const Recording& 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); +} + LLUnit Recording::getSum(const TraceType& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); -- cgit v1.2.3 From 7dbb8860373769dfca7d6c6588284866a1bf86a3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 4 Jan 2013 16:19:20 -0800 Subject: SH-3468 WIP add memory tracking base class further compile error fixes --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9dbafc4e82..c110e64380 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -60,7 +60,7 @@ Recording::Recording( const Recording& other ) mStackTimers = other.mStackTimers; mMemStats = other.mMemStats; - LLStopWatchControlsMixin::initTo(other.getPlayState()); + LLStopWatchControlsMixin::initTo(other.getPlayState()); } -- cgit v1.2.3 From 20b2fa4052ae6789ec8894f33f4764a1f7233b24 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Jan 2013 23:08:01 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved performance of fast timer stat gathering --- indra/llcommon/lltracerecording.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c110e64380..ddd25bfe87 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -179,7 +179,7 @@ LLUnit Recording::getSum(const TraceType Recording::getSum(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); + return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } @@ -195,7 +195,7 @@ LLUnit Recording::getPerSec(const TraceType Recording::getPerSec(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } F32 Recording::getPerSec(const TraceType& stat) const -- cgit v1.2.3 From 670d03ceb83b92c9bb98d10bb37fba6f75971a2f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Jan 2013 14:28:32 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed LLExtendableRecording to actually accumulator recording time period renamed and updated LLStopWatchControlsMixin::initTo to setPlayState --- indra/llcommon/lltracerecording.cpp | 42 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ddd25bfe87..f45226eb9a 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -60,7 +60,7 @@ Recording::Recording( const Recording& other ) mStackTimers = other.mStackTimers; mMemStats = other.mMemStats; - LLStopWatchControlsMixin::initTo(other.getPlayState()); + LLStopWatchControlsMixin::setPlayState(other.getPlayState()); } @@ -345,14 +345,14 @@ U32 Recording::getSampleCount( const TraceType >& st // PeriodicRecording /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state) +PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) : mNumPeriods(num_periods), mCurPeriod(0), mTotalValid(false), mRecordingPeriods( new Recording[num_periods]) { llassert(mNumPeriods > 0); - initTo(state); + setPlayState(state); } PeriodicRecording::PeriodicRecording(PeriodicRecording& other) @@ -377,7 +377,7 @@ PeriodicRecording::~PeriodicRecording() void PeriodicRecording::nextPeriod() { - EStopWatchState play_state = getPlayState(); + EPlayState play_state = getPlayState(); Recording& old_recording = getCurRecordingPeriod(); mCurPeriod = (mCurPeriod + 1) % mNumPeriods; old_recording.splitTo(getCurRecordingPeriod()); @@ -458,8 +458,14 @@ void PeriodicRecording::splitFrom(PeriodicRecording& other) void ExtendableRecording::extend() { + // stop recording to get latest data + mPotentialRecording.stop(); + // push the data back to accepted recording mAcceptedRecording.appendRecording(mPotentialRecording); + // flush data, so we can start from scratch mPotentialRecording.reset(); + // go back to play state we were in initially + mPotentialRecording.setPlayState(getPlayState()); } void ExtendableRecording::start() @@ -514,7 +520,7 @@ PeriodicRecording& get_frame_recording() void LLStopWatchControlsMixinCommon::start() { - switch (mState) + switch (mPlayState) { case STOPPED: handleReset(); @@ -530,12 +536,12 @@ void LLStopWatchControlsMixinCommon::start() llassert(false); break; } - mState = STARTED; + mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::stop() { - switch (mState) + switch (mPlayState) { case STOPPED: break; @@ -549,12 +555,12 @@ void LLStopWatchControlsMixinCommon::stop() llassert(false); break; } - mState = STOPPED; + mPlayState = STOPPED; } void LLStopWatchControlsMixinCommon::pause() { - switch (mState) + switch (mPlayState) { case STOPPED: break; @@ -567,12 +573,12 @@ void LLStopWatchControlsMixinCommon::pause() llassert(false); break; } - mState = PAUSED; + mPlayState = PAUSED; } void LLStopWatchControlsMixinCommon::resume() { - switch (mState) + switch (mPlayState) { case STOPPED: handleStart(); @@ -586,12 +592,12 @@ void LLStopWatchControlsMixinCommon::resume() llassert(false); break; } - mState = STARTED; + mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::restart() { - switch (mState) + switch (mPlayState) { case STOPPED: handleReset(); @@ -608,7 +614,7 @@ void LLStopWatchControlsMixinCommon::restart() llassert(false); break; } - mState = STARTED; + mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::reset() @@ -616,21 +622,23 @@ void LLStopWatchControlsMixinCommon::reset() handleReset(); } -void LLStopWatchControlsMixinCommon::initTo( EStopWatchState state ) +void LLStopWatchControlsMixinCommon::setPlayState( EPlayState state ) { switch(state) { case STOPPED: + stop(); break; case PAUSED: + pause(); break; case STARTED: - handleStart(); + start(); break; default: llassert(false); break; } - mState = state; + mPlayState = state; } -- cgit v1.2.3 From 09ee16c61d372c1eb620bc3ef3dbfeb798c0a82e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 25 Jan 2013 16:15:19 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fix for extendablerecording not having right state --- indra/llcommon/lltracerecording.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f45226eb9a..913c4cbdad 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -470,43 +470,51 @@ void ExtendableRecording::extend() void ExtendableRecording::start() { + LLStopWatchControlsMixin::start(); mPotentialRecording.start(); } void ExtendableRecording::stop() { + LLStopWatchControlsMixin::stop(); mPotentialRecording.stop(); } void ExtendableRecording::pause() { + LLStopWatchControlsMixin::pause(); mPotentialRecording.pause(); } void ExtendableRecording::resume() { + LLStopWatchControlsMixin::resume(); mPotentialRecording.resume(); } void ExtendableRecording::restart() { + LLStopWatchControlsMixin::restart(); mAcceptedRecording.reset(); mPotentialRecording.restart(); } void ExtendableRecording::reset() { + LLStopWatchControlsMixin::reset(); mAcceptedRecording.reset(); mPotentialRecording.reset(); } void ExtendableRecording::splitTo(ExtendableRecording& other) { + LLStopWatchControlsMixin::splitTo(other); mPotentialRecording.splitTo(other.mPotentialRecording); } void ExtendableRecording::splitFrom(ExtendableRecording& other) { + LLStopWatchControlsMixin::splitFrom(other); mPotentialRecording.splitFrom(other.mPotentialRecording); } -- cgit v1.2.3 From 2c68d5367c5c44aceb4ff23d9672c35642e030f7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 27 Jan 2013 21:35:20 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fixed memory leak fixed glitching of fast timer display --- indra/llcommon/lltracerecording.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 913c4cbdad..737b95cdd5 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -109,8 +109,18 @@ void Recording::handleSplitTo(Recording& other) { stop(); other.restart(); + syncTo(other); +} + +void Recording::syncTo(Recording& 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); + //TODO: figure out how to get seamless handoff of timing stats } -- cgit v1.2.3 From eb6c8959ca5b8b3c100114d4d659a48bb4d56b2c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 2 Feb 2013 01:09:52 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fixed most fast timer display and interaction issues --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 737b95cdd5..29604f7155 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -530,7 +530,7 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other) PeriodicRecording& get_frame_recording() { - static LLThreadLocalPointer sRecording(new PeriodicRecording(64, PeriodicRecording::STARTED)); + static LLThreadLocalPointer sRecording(new PeriodicRecording(200, PeriodicRecording::STARTED)); return *sRecording; } -- cgit v1.2.3 From 438cbfe489cc34261ac600bbb22983164e59b1d9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 7 Feb 2013 20:07:31 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fix for timings for recursive fast timers not being correct --- indra/llcommon/lltracerecording.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 29604f7155..69085ddcc2 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -184,12 +184,12 @@ void Recording::mergeRecording( const Recording& other) LLUnit Recording::getSum(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); + return ((F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter + (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } LLUnit Recording::getSum(const TraceType& stat) const { - return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); } @@ -200,12 +200,12 @@ U32 Recording::getSum(const TraceType& st LLUnit Recording::getPerSec(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + return ((F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter + (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } LLUnit Recording::getPerSec(const TraceType& stat) const { - return ((F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter - (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } F32 Recording::getPerSec(const TraceType& stat) const -- cgit v1.2.3 From 2e15e8fd4ba62204c76f6e2a91d3e50f62e6c1fc Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 9 Feb 2013 00:34:59 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible fixed anamolous LLFastTimer timings --- indra/llcommon/lltracerecording.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 69085ddcc2..2af9041863 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -120,8 +120,6 @@ void Recording::syncTo(Recording& other) other.mMeasurements.write()->reset(mMeasurements); other.mStackTimers.write()->reset(mStackTimers); other.mMemStats.write()->reset(mMemStats); - - //TODO: figure out how to get seamless handoff of timing stats } void Recording::makePrimary() @@ -184,12 +182,15 @@ void Recording::mergeRecording( const Recording& other) LLUnit Recording::getSum(const TraceType& stat) const { - return ((F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter + (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); + const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter + accumulator.mChildTimeCounter - accumulator.mStartChildTimeCounter) + / (F64)LLTrace::TimeBlock::countsPerSecond(); } LLUnit Recording::getSum(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); + const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } @@ -200,12 +201,18 @@ U32 Recording::getSum(const TraceType& st LLUnit Recording::getPerSec(const TraceType& stat) const { - return ((F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter + (F64)(*mStackTimers)[stat.getIndex()].mChildTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + + return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter + accumulator.mChildTimeCounter - accumulator.mStartChildTimeCounter) + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } LLUnit Recording::getPerSec(const TraceType& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + + return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter) + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } F32 Recording::getPerSec(const TraceType& stat) const -- cgit v1.2.3 From 67ac6e7a294bd7401c55ed1d7423166dda1c0ee6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 10 Feb 2013 23:53:45 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible streamlined fast timer delta tracking --- indra/llcommon/lltracerecording.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2af9041863..ab8dbce2ce 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -183,14 +183,14 @@ void Recording::mergeRecording( const Recording& other) LLUnit Recording::getSum(const TraceType& stat) const { const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; - return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter + accumulator.mChildTimeCounter - accumulator.mStartChildTimeCounter) + return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } LLUnit Recording::getSum(const TraceType& stat) const { const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; - return (F64)(accumulator.mSelfTimeCounter - accumulator.mStartSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); + return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } @@ -203,7 +203,7 @@ LLUnit Recording::getPerSec(const TraceType Recording::getPerSec(const TraceType Date: Mon, 11 Mar 2013 00:37:50 -0700 Subject: renamed some variables/methods in LLTrace to make things clearer --- indra/llcommon/lltracerecording.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ab8dbce2ce..3df06c5172 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -109,10 +109,10 @@ void Recording::handleSplitTo(Recording& other) { stop(); other.restart(); - syncTo(other); + handOffTo(other); } -void Recording::syncTo(Recording& other) +void Recording::handOffTo(Recording& other) { other.mCountsFloat.write()->reset(mCountsFloat); other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); -- cgit v1.2.3 From 24a1ceb25de2b9573eb369a6e0d1811fe594aabb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 11 Mar 2013 01:08:51 -0700 Subject: separated RecordingBuffers from Recording to make active recording stack more safe --- indra/llcommon/lltracerecording.cpp | 166 +++++++++++++++++++----------------- 1 file changed, 88 insertions(+), 78 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 3df06c5172..ef0a633c9c 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -34,13 +34,13 @@ namespace LLTrace { + /////////////////////////////////////////////////////////////////////// -// Recording +// RecordingBuffers /////////////////////////////////////////////////////////////////////// -Recording::Recording() -: mElapsedSeconds(0), - mCountsFloat(new AccumulatorBuffer >()), +RecordingBuffers::RecordingBuffers() +: mCountsFloat(new AccumulatorBuffer >()), mMeasurementsFloat(new AccumulatorBuffer >()), mCounts(new AccumulatorBuffer >()), mMeasurements(new AccumulatorBuffer >()), @@ -48,71 +48,7 @@ Recording::Recording() mMemStats(new AccumulatorBuffer()) {} -Recording::Recording( const Recording& other ) -{ - llassert(other.mCountsFloat.notNull()); - mSamplingTimer = other.mSamplingTimer; - mElapsedSeconds = other.mElapsedSeconds; - mCountsFloat = other.mCountsFloat; - mMeasurementsFloat = other.mMeasurementsFloat; - mCounts = other.mCounts; - mMeasurements = other.mMeasurements; - mStackTimers = other.mStackTimers; - mMemStats = other.mMemStats; - - LLStopWatchControlsMixin::setPlayState(other.getPlayState()); -} - - -Recording::~Recording() -{ - stop(); - llassert(isStopped()); -} - -void Recording::update() -{ - if (isStarted()) - { - LLTrace::get_thread_recorder()->update(this); - mSamplingTimer.reset(); - } -} - -void Recording::handleReset() -{ - mCountsFloat.write()->reset(); - mMeasurementsFloat.write()->reset(); - mCounts.write()->reset(); - mMeasurements.write()->reset(); - mStackTimers.write()->reset(); - mMemStats.write()->reset(); - - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); -} - -void Recording::handleStart() -{ - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); -} - -void Recording::handleStop() -{ - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::TimeBlock::processTimes(); - LLTrace::get_thread_recorder()->deactivate(this); -} - -void Recording::handleSplitTo(Recording& other) -{ - stop(); - other.restart(); - handOffTo(other); -} - -void Recording::handOffTo(Recording& other) +void RecordingBuffers::handOffTo(RecordingBuffers& other) { other.mCountsFloat.write()->reset(mCountsFloat); other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); @@ -122,7 +58,7 @@ void Recording::handOffTo(Recording& other) other.mMemStats.write()->reset(mMemStats); } -void Recording::makePrimary() +void RecordingBuffers::makePrimary() { mCountsFloat.write()->makePrimary(); mMeasurementsFloat.write()->makePrimary(); @@ -144,12 +80,12 @@ void Recording::makePrimary() } } -bool Recording::isPrimary() const +bool RecordingBuffers::isPrimary() const { return mCounts->isPrimary(); } -void Recording::makeUnique() +void RecordingBuffers::makeUnique() { mCountsFloat.makeUnique(); mMeasurementsFloat.makeUnique(); @@ -159,19 +95,17 @@ void Recording::makeUnique() mMemStats.makeUnique(); } -void Recording::appendRecording( const Recording& other ) +void RecordingBuffers::appendBuffers( 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); - mElapsedSeconds += other.mElapsedSeconds; } -void Recording::mergeRecording( const Recording& other) +void RecordingBuffers::mergeBuffers( const RecordingBuffers& other) { mCountsFloat.write()->addSamples(*other.mCountsFloat); mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); @@ -180,6 +114,84 @@ void Recording::mergeRecording( const Recording& other) mMemStats.write()->addSamples(*other.mMemStats); } +void RecordingBuffers::resetBuffers(RecordingBuffers* other) +{ + mCountsFloat.write()->reset(other ? other->mCountsFloat : NULL); + mMeasurementsFloat.write()->reset(other ? other->mMeasurementsFloat : NULL); + mCounts.write()->reset(other ? other->mCounts : NULL); + mMeasurements.write()->reset(other ? other->mMeasurements : NULL); + mStackTimers.write()->reset(other ? other->mStackTimers : NULL); + mMemStats.write()->reset(other ? other->mMemStats : NULL); +} + +/////////////////////////////////////////////////////////////////////// +// Recording +/////////////////////////////////////////////////////////////////////// + +Recording::Recording() +: mElapsedSeconds(0) +{} + +Recording::Recording( const Recording& other ) +{ + LLStopWatchControlsMixin::setPlayState(other.getPlayState()); +} + + +Recording::~Recording() +{ + stop(); + llassert(isStopped()); +} + +void Recording::update() +{ + if (isStarted()) + { + LLTrace::get_thread_recorder()->update(this); + mSamplingTimer.reset(); + } +} + +void Recording::handleReset() +{ + resetBuffers(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + +void Recording::handleStart() +{ + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); +} + +void Recording::handleStop() +{ + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::TimeBlock::processTimes(); + LLTrace::get_thread_recorder()->deactivate(this); +} + +void Recording::handleSplitTo(Recording& other) +{ + stop(); + other.restart(); + handOffTo(other); +} + +void Recording::appendRecording( const Recording& other ) +{ + appendBuffers(other); + mElapsedSeconds += other.mElapsedSeconds; +} + +void Recording::mergeRecording( const Recording& other) +{ + mergeBuffers(other); +} + LLUnit Recording::getSum(const TraceType& stat) const { const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; @@ -356,8 +368,6 @@ U32 Recording::getSampleCount( const TraceType >& st return (*mMeasurements)[stat.getIndex()].getSampleCount(); } - - /////////////////////////////////////////////////////////////////////// // PeriodicRecording /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 7b4d27ecbcb5ac702459be97cbf6b81354850658 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 14 Mar 2013 19:36:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics collapsed Orientation enums to all use LLView::EOrientation added ability to display stat bar horizontally --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ef0a633c9c..6695ebeaca 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -547,7 +547,7 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other) PeriodicRecording& get_frame_recording() { - static LLThreadLocalPointer sRecording(new PeriodicRecording(200, PeriodicRecording::STARTED)); + static LLThreadLocalPointer sRecording(new PeriodicRecording(1000, PeriodicRecording::STARTED)); return *sRecording; } -- cgit v1.2.3 From 8de397b19ec9e2f6206fd5ae57dba96c70e78b74 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 18 Mar 2013 08:43:03 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed LLCriticalDamp to LLSmoothInterpolation and sped up interpolator lookup improvements to stats display of llstatbar added scene load stats floater accessed with ctrl|shift|2 --- indra/llcommon/lltracerecording.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 6695ebeaca..259f5a7a27 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -291,23 +291,6 @@ U32 Recording::getSampleCount( const TraceType >& stat ) c return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); } - -F64 Recording::getPerSec( const TraceType >& stat ) const -{ - F64 sum = (*mMeasurementsFloat)[stat.getIndex()].getSum(); - return (sum != 0.0) - ? (sum / mElapsedSeconds) - : 0.0; -} - -F64 Recording::getPerSec( const TraceType >& stat ) const -{ - S64 sum = (*mMeasurements)[stat.getIndex()].getSum(); - return (sum != 0) - ? ((F64)sum / mElapsedSeconds) - : 0.0; -} - F64 Recording::getMin( const TraceType >& stat ) const { return (*mMeasurementsFloat)[stat.getIndex()].getMin(); -- cgit v1.2.3 From 1f507c3cfca0c7722ebeaf71883fbaa83988e1a9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Mar 2013 00:37:20 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics copied over scene load frame differencing changes from viewer-interesting made periodicrecording flexible enough to allow for indefinite number of periods added scene loading stats floater fixed collapsing behavior of container views --- indra/llcommon/lltracerecording.cpp | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 259f5a7a27..5d74ea32df 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -355,41 +355,30 @@ U32 Recording::getSampleCount( const TraceType >& st // PeriodicRecording /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) -: mNumPeriods(num_periods), +PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) +: mAutoResize(num_periods == 0), mCurPeriod(0), - mTotalValid(false), - mRecordingPeriods( new Recording[num_periods]) + mTotalValid(false) { - llassert(mNumPeriods > 0); - setPlayState(state); -} - -PeriodicRecording::PeriodicRecording(PeriodicRecording& other) -: mNumPeriods(other.mNumPeriods), - mCurPeriod(other.mCurPeriod), - mTotalValid(other.mTotalValid), - mTotalRecording(other.mTotalRecording) -{ - mRecordingPeriods = new Recording[mNumPeriods]; - for (S32 i = 0; i < mNumPeriods; i++) + if (num_periods) { - mRecordingPeriods[i] = other.mRecordingPeriods[i]; + mRecordingPeriods.resize(num_periods); } + setPlayState(state); } - -PeriodicRecording::~PeriodicRecording() -{ - delete[] mRecordingPeriods; -} - - void PeriodicRecording::nextPeriod() { EPlayState play_state = getPlayState(); Recording& old_recording = getCurRecordingPeriod(); - mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + if (mAutoResize) + { + mRecordingPeriods.push_back(Recording()); + } + U32 num_periods = mRecordingPeriods.size(); + mCurPeriod = (num_periods > 0) + ? (mCurPeriod + 1) % num_periods + : mCurPeriod + 1; old_recording.splitTo(getCurRecordingPeriod()); switch(play_state) @@ -412,9 +401,21 @@ Recording& PeriodicRecording::getTotalRecording() if (!mTotalValid) { mTotalRecording.reset(); - for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + + if (num_periods) + { + for (S32 i = mCurPeriod + 1; i < mCurPeriod + num_periods; i++) + { + mTotalRecording.appendRecording(mRecordingPeriods[i % num_periods]); + } + } + else { - mTotalRecording.appendRecording(mRecordingPeriods[i % mNumPeriods]); + for (S32 i = 0; i < mCurPeriod; i++) + { + mTotalRecording.appendRecording(mRecordingPeriods[i]); + } } } mTotalValid = true; -- cgit v1.2.3 From 368dd542bec7c31e14673b83d3342c35717d2920 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Mar 2013 19:07:48 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fix for broken pause button on fast timer view --- indra/llcommon/lltracerecording.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5d74ea32df..b70d42b082 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -133,6 +133,9 @@ Recording::Recording() {} Recording::Recording( const Recording& other ) +: RecordingBuffers(other), + mElapsedSeconds(other.mElapsedSeconds), + mSamplingTimer(other.mSamplingTimer) { LLStopWatchControlsMixin::setPlayState(other.getPlayState()); } -- cgit v1.2.3 From 935dce7d6b0a343cef5b13f53d6da5d0c2dc6a73 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 25 Mar 2013 00:18:06 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed some compile errors made label spacing automatic on stat bars fixed infinite values coming from stats --- indra/llcommon/lltracerecording.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index b70d42b082..f78b7942a7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -116,12 +116,12 @@ void RecordingBuffers::mergeBuffers( const RecordingBuffers& other) void RecordingBuffers::resetBuffers(RecordingBuffers* other) { - mCountsFloat.write()->reset(other ? other->mCountsFloat : NULL); - mMeasurementsFloat.write()->reset(other ? other->mMeasurementsFloat : NULL); - mCounts.write()->reset(other ? other->mCounts : NULL); - mMeasurements.write()->reset(other ? other->mMeasurements : NULL); - mStackTimers.write()->reset(other ? other->mStackTimers : NULL); - mMemStats.write()->reset(other ? other->mMemStats : NULL); + 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 >()); } /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 07ca6fce7c9cffe1b8f215f25bb826fedf57a5b7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 10 Apr 2013 21:51:56 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed PeriodicRecording::getTotalRecording as it was showing up at the top on the profiler renamed getPrevRecordingPeriod, etc. to getPrevRecording --- indra/llcommon/lltracerecording.cpp | 55 +++++++++---------------------------- 1 file changed, 13 insertions(+), 42 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f78b7942a7..21156b4d61 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -360,8 +360,7 @@ U32 Recording::getSampleCount( const TraceType >& st PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), - mCurPeriod(0), - mTotalValid(false) + mCurPeriod(0) { if (num_periods) { @@ -373,7 +372,7 @@ PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) void PeriodicRecording::nextPeriod() { EPlayState play_state = getPlayState(); - Recording& old_recording = getCurRecordingPeriod(); + Recording& old_recording = getCurRecording(); if (mAutoResize) { mRecordingPeriods.push_back(Recording()); @@ -382,87 +381,59 @@ void PeriodicRecording::nextPeriod() mCurPeriod = (num_periods > 0) ? (mCurPeriod + 1) % num_periods : mCurPeriod + 1; - old_recording.splitTo(getCurRecordingPeriod()); + old_recording.splitTo(getCurRecording()); switch(play_state) { case STOPPED: - getCurRecordingPeriod().stop(); + getCurRecording().stop(); break; case PAUSED: - getCurRecordingPeriod().pause(); + getCurRecording().pause(); break; case STARTED: break; } - // new period, need to recalculate total - mTotalValid = false; -} - -Recording& PeriodicRecording::getTotalRecording() -{ - if (!mTotalValid) - { - mTotalRecording.reset(); - U32 num_periods = mRecordingPeriods.size(); - - if (num_periods) - { - for (S32 i = mCurPeriod + 1; i < mCurPeriod + num_periods; i++) - { - mTotalRecording.appendRecording(mRecordingPeriods[i % num_periods]); - } - } - else - { - for (S32 i = 0; i < mCurPeriod; i++) - { - mTotalRecording.appendRecording(mRecordingPeriods[i]); - } - } - } - mTotalValid = true; - return mTotalRecording; } void PeriodicRecording::start() { - getCurRecordingPeriod().start(); + getCurRecording().start(); } void PeriodicRecording::stop() { - getCurRecordingPeriod().stop(); + getCurRecording().stop(); } void PeriodicRecording::pause() { - getCurRecordingPeriod().pause(); + getCurRecording().pause(); } void PeriodicRecording::resume() { - getCurRecordingPeriod().resume(); + getCurRecording().resume(); } void PeriodicRecording::restart() { - getCurRecordingPeriod().restart(); + getCurRecording().restart(); } void PeriodicRecording::reset() { - getCurRecordingPeriod().reset(); + getCurRecording().reset(); } void PeriodicRecording::splitTo(PeriodicRecording& other) { - getCurRecordingPeriod().splitTo(other.getCurRecordingPeriod()); + getCurRecording().splitTo(other.getCurRecording()); } void PeriodicRecording::splitFrom(PeriodicRecording& other) { - getCurRecordingPeriod().splitFrom(other.getCurRecordingPeriod()); + getCurRecording().splitFrom(other.getCurRecording()); } -- cgit v1.2.3 From 62c8844414b84ee9e8cc488f4e02cbaed5f67a14 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 21 Apr 2013 23:10:03 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added ExtendablePeriodicRecording and ability to append periodic recordings to each other --- indra/llcommon/lltracerecording.cpp | 136 ++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 21156b4d61..2917c217d7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -396,6 +396,76 @@ void PeriodicRecording::nextPeriod() } } + +void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) +{ + if (other.mRecordingPeriods.size() < 2) return; + + EPlayState play_state = getPlayState(); + pause(); + + EPlayState other_play_state = other.getPlayState(); + other.pause(); + + if (mAutoResize) + { + // copy everything after current period of other recording to end of buffer + // this will only apply if other recording is using a fixed circular buffer + if (other.mCurPeriod < other.mRecordingPeriods.size() - 1) + { + std::copy( other.mRecordingPeriods.begin() + other.mCurPeriod + 1, + other.mRecordingPeriods.end(), + std::back_inserter(mRecordingPeriods)); + } + + // copy everything from beginning of other recording's buffer up to, but not including + // current period + std::copy( other.mRecordingPeriods.begin(), + other.mRecordingPeriods.begin() + other.mCurPeriod, + std::back_inserter(mRecordingPeriods)); + + mCurPeriod = mRecordingPeriods.size() - 1; + } + else + { + size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() ); + std::vector::iterator src_it = other.mRecordingPeriods.begin() + + ( (other.mCurPeriod + 1) // cur period + + (other.mRecordingPeriods.size() - num_to_copy) // minus room for copy + % other.mRecordingPeriods.size()); + std::vector::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); + + for(S32 i = 0; i < num_to_copy; i++) + { + *dest_it = *src_it; + + if (++src_it == other.mRecordingPeriods.end()) + { + src_it = other.mRecordingPeriods.begin(); + } + + if (++dest_it == mRecordingPeriods.end()) + { + dest_it = mRecordingPeriods.begin(); + } + } + + mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); + } + + // if copying from periodic recording that wasn't active advance our period to the next available one + // otherwise continue recording on top of the last period of data received from the other recording + if (other_play_state != STARTED) + { + nextPeriod(); + } + + setPlayState(play_state); + other.setPlayState(other_play_state); +} + + + void PeriodicRecording::start() { getCurRecording().start(); @@ -503,6 +573,72 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other) mPotentialRecording.splitFrom(other.mPotentialRecording); } +/////////////////////////////////////////////////////////////////////// +// ExtendablePeriodicRecording +/////////////////////////////////////////////////////////////////////// + +void ExtendablePeriodicRecording::extend() +{ + // stop recording to get latest data + mPotentialRecording.stop(); + // push the data back to accepted recording + mAcceptedRecording.appendPeriodicRecording(mPotentialRecording); + // flush data, so we can start from scratch + mPotentialRecording.reset(); + // go back to play state we were in initially + mPotentialRecording.setPlayState(getPlayState()); +} + +void ExtendablePeriodicRecording::start() +{ + LLStopWatchControlsMixin::start(); + mPotentialRecording.start(); +} + +void ExtendablePeriodicRecording::stop() +{ + LLStopWatchControlsMixin::stop(); + mPotentialRecording.stop(); +} + +void ExtendablePeriodicRecording::pause() +{ + LLStopWatchControlsMixin::pause(); + mPotentialRecording.pause(); +} + +void ExtendablePeriodicRecording::resume() +{ + LLStopWatchControlsMixin::resume(); + mPotentialRecording.resume(); +} + +void ExtendablePeriodicRecording::restart() +{ + LLStopWatchControlsMixin::restart(); + mAcceptedRecording.reset(); + mPotentialRecording.restart(); +} + +void ExtendablePeriodicRecording::reset() +{ + LLStopWatchControlsMixin::reset(); + mAcceptedRecording.reset(); + mPotentialRecording.reset(); +} + +void ExtendablePeriodicRecording::splitTo(ExtendablePeriodicRecording& other) +{ + LLStopWatchControlsMixin::splitTo(other); + mPotentialRecording.splitTo(other.mPotentialRecording); +} + +void ExtendablePeriodicRecording::splitFrom(ExtendablePeriodicRecording& other) +{ + LLStopWatchControlsMixin::splitFrom(other); + mPotentialRecording.splitFrom(other.mPotentialRecording); +} + PeriodicRecording& get_frame_recording() { static LLThreadLocalPointer sRecording(new PeriodicRecording(1000, PeriodicRecording::STARTED)); -- cgit v1.2.3 From c6737163854981d94fde8bdd440eaf4bbc816b4f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Apr 2013 18:52:34 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics convert scene monitor to use extendable periodic recording --- indra/llcommon/lltracerecording.cpp | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2917c217d7..af7b61dd4e 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -464,8 +464,62 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) other.setPlayState(other_play_state); } +LLUnit PeriodicRecording::getDuration() +{ + LLUnit duration; + size_t num_periods = mRecordingPeriods.size(); + for (size_t i = 1; i <= num_periods; i++) + { + size_t index = (mCurPeriod + num_periods - i) % num_periods; + duration += mRecordingPeriods[index].getDuration(); + } + return duration; +} +LLTrace::Recording PeriodicRecording::snapshotCurRecording() const +{ + Recording recording_copy(getCurRecording()); + recording_copy.stop(); + return recording_copy; +} + + +Recording& PeriodicRecording::getLastRecording() +{ + U32 num_periods = mRecordingPeriods.size(); + return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; +} + +const Recording& PeriodicRecording::getLastRecording() const +{ + return getPrevRecording(1); +} + +Recording& PeriodicRecording::getCurRecording() +{ + return mRecordingPeriods[mCurPeriod]; +} + +const Recording& PeriodicRecording::getCurRecording() const +{ + return mRecordingPeriods[mCurPeriod]; +} + +Recording& PeriodicRecording::getPrevRecording( U32 offset ) +{ + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; +} + +const Recording& PeriodicRecording::getPrevRecording( U32 offset ) const +{ + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; +} + void PeriodicRecording::start() { getCurRecording().start(); @@ -577,6 +631,13 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other) // ExtendablePeriodicRecording /////////////////////////////////////////////////////////////////////// + +ExtendablePeriodicRecording::ExtendablePeriodicRecording() +: mAcceptedRecording(0), + mPotentialRecording(0) +{ +} + void ExtendablePeriodicRecording::extend() { // stop recording to get latest data -- cgit v1.2.3 From 84af0e9852486231b5ef0cde7ad1704d41689a3a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 24 Apr 2013 14:13:45 -0700 Subject: SH-4080 WIP interesting: random crash on Mac potential fix for crasher cleaned up llsingleton --- indra/llcommon/lltracerecording.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index af7b61dd4e..e562f2bce2 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -362,6 +362,10 @@ PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), mCurPeriod(0) { + if (mAutoResize) + { + num_periods = 1; + } if (num_periods) { mRecordingPeriods.resize(num_periods); -- cgit v1.2.3 From 12c34dc30f0cb6270c11e100fcaceb3fa6b27e81 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 May 2013 00:53:01 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics renamed LLView::handleVisibilityChange to onVisibilityChange to reflect cleaned up scene monitor stats recording, now all trace stats dumped to csv also fixed extendablerecording, periodicrecording, etc. to properly implement start/stop/etc --- indra/llcommon/lltracerecording.cpp | 228 ++++++++++++------------------------ 1 file changed, 72 insertions(+), 156 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e562f2bce2..6b5c6c7d3e 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -179,8 +179,6 @@ void Recording::handleStop() void Recording::handleSplitTo(Recording& other) { - stop(); - other.restart(); handOffTo(other); } @@ -375,94 +373,86 @@ PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) void PeriodicRecording::nextPeriod() { - EPlayState play_state = getPlayState(); - Recording& old_recording = getCurRecording(); if (mAutoResize) { mRecordingPeriods.push_back(Recording()); } - U32 num_periods = mRecordingPeriods.size(); - mCurPeriod = (num_periods > 0) - ? (mCurPeriod + 1) % num_periods - : mCurPeriod + 1; - old_recording.splitTo(getCurRecording()); - switch(play_state) - { - case STOPPED: - getCurRecording().stop(); - break; - case PAUSED: - getCurRecording().pause(); - break; - case STARTED: - break; - } + Recording& old_recording = getCurRecording(); + + mCurPeriod = mRecordingPeriods.empty() + ? mCurPeriod + 1 + : (mCurPeriod + 1) % mRecordingPeriods.size(); + old_recording.splitTo(getCurRecording()); } void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) { - if (other.mRecordingPeriods.size() < 2) return; + if (other.mRecordingPeriods.empty()) return; EPlayState play_state = getPlayState(); - pause(); + stop(); EPlayState other_play_state = other.getPlayState(); other.pause(); - if (mAutoResize) - { - // copy everything after current period of other recording to end of buffer - // this will only apply if other recording is using a fixed circular buffer - if (other.mCurPeriod < other.mRecordingPeriods.size() - 1) - { - std::copy( other.mRecordingPeriods.begin() + other.mCurPeriod + 1, - other.mRecordingPeriods.end(), - std::back_inserter(mRecordingPeriods)); - } + U32 other_recording_count = other.mRecordingPeriods.size(); - // copy everything from beginning of other recording's buffer up to, but not including - // current period - std::copy( other.mRecordingPeriods.begin(), - other.mRecordingPeriods.begin() + other.mCurPeriod, - std::back_inserter(mRecordingPeriods)); + Recording& other_oldest_recording = other.mRecordingPeriods[(other.mCurPeriod + 1) % other.mRecordingPeriods.size()]; - mCurPeriod = mRecordingPeriods.size() - 1; + // if I have a recording of any length, then close it off and start a fresh one + if (getCurRecording().getDuration().value()) + { + nextPeriod(); } - else + getCurRecording().appendRecording(other_oldest_recording); + + if (other_recording_count > 1) { - size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() ); - std::vector::iterator src_it = other.mRecordingPeriods.begin() - + ( (other.mCurPeriod + 1) // cur period - + (other.mRecordingPeriods.size() - num_to_copy) // minus room for copy - % other.mRecordingPeriods.size()); - std::vector::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); - - for(S32 i = 0; i < num_to_copy; i++) + if (mAutoResize) { - *dest_it = *src_it; - - if (++src_it == other.mRecordingPeriods.end()) + for (S32 other_index = (other.mCurPeriod + 2) % other_recording_count; + other_index != other.mCurPeriod; + other_index = (other_index + 1) % other_recording_count) { - src_it = other.mRecordingPeriods.begin(); + llassert(other.mRecordingPeriods[other_index].getDuration() != 0.f + && (mRecordingPeriods.empty() + || other.mRecordingPeriods[other_index].getDuration() != mRecordingPeriods.back().getDuration())); + mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); } - if (++dest_it == mRecordingPeriods.end()) + mCurPeriod = mRecordingPeriods.size() - 1; + } + else + { + size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() - 1); + std::vector::iterator src_it = other.mRecordingPeriods.begin() + + ( (other.mCurPeriod + 1 // oldest period + + (other.mRecordingPeriods.size() - num_to_copy)) // minus room for copy + % other.mRecordingPeriods.size()); + std::vector::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); + + for(S32 i = 0; i < num_to_copy; i++) { - dest_it = mRecordingPeriods.begin(); + *dest_it = *src_it; + + if (++src_it == other.mRecordingPeriods.end()) + { + src_it = other.mRecordingPeriods.begin(); + } + + if (++dest_it == mRecordingPeriods.end()) + { + dest_it = mRecordingPeriods.begin(); + } } - } - mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); + mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); + } } - // if copying from periodic recording that wasn't active advance our period to the next available one - // otherwise continue recording on top of the last period of data received from the other recording - if (other_play_state != STARTED) - { - nextPeriod(); - } + nextPeriod(); setPlayState(play_state); other.setPlayState(other_play_state); @@ -524,47 +514,28 @@ const Recording& PeriodicRecording::getPrevRecording( U32 offset ) const return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } -void PeriodicRecording::start() +void PeriodicRecording::handleStart() { getCurRecording().start(); } -void PeriodicRecording::stop() -{ - getCurRecording().stop(); -} - -void PeriodicRecording::pause() +void PeriodicRecording::handleStop() { getCurRecording().pause(); } -void PeriodicRecording::resume() -{ - getCurRecording().resume(); -} - -void PeriodicRecording::restart() +void PeriodicRecording::handleReset() { - getCurRecording().restart(); + mRecordingPeriods.clear(); + mRecordingPeriods.push_back(Recording()); + mCurPeriod = 0; } -void PeriodicRecording::reset() +void PeriodicRecording::handleSplitTo(PeriodicRecording& other) { - getCurRecording().reset(); + getCurRecording().handOffTo(other.getCurRecording()); } -void PeriodicRecording::splitTo(PeriodicRecording& other) -{ - getCurRecording().splitTo(other.getCurRecording()); -} - -void PeriodicRecording::splitFrom(PeriodicRecording& other) -{ - getCurRecording().splitFrom(other.getCurRecording()); -} - - /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// @@ -581,55 +552,27 @@ void ExtendableRecording::extend() mPotentialRecording.setPlayState(getPlayState()); } -void ExtendableRecording::start() +void ExtendableRecording::handleStart() { - LLStopWatchControlsMixin::start(); mPotentialRecording.start(); } -void ExtendableRecording::stop() -{ - LLStopWatchControlsMixin::stop(); - mPotentialRecording.stop(); -} - -void ExtendableRecording::pause() +void ExtendableRecording::handleStop() { - LLStopWatchControlsMixin::pause(); mPotentialRecording.pause(); } -void ExtendableRecording::resume() -{ - LLStopWatchControlsMixin::resume(); - mPotentialRecording.resume(); -} - -void ExtendableRecording::restart() -{ - LLStopWatchControlsMixin::restart(); - mAcceptedRecording.reset(); - mPotentialRecording.restart(); -} - -void ExtendableRecording::reset() +void ExtendableRecording::handleReset() { - LLStopWatchControlsMixin::reset(); mAcceptedRecording.reset(); mPotentialRecording.reset(); } -void ExtendableRecording::splitTo(ExtendableRecording& other) +void ExtendableRecording::handleSplitTo(ExtendableRecording& other) { - LLStopWatchControlsMixin::splitTo(other); - mPotentialRecording.splitTo(other.mPotentialRecording); + mPotentialRecording.handOffTo(other.mPotentialRecording); } -void ExtendableRecording::splitFrom(ExtendableRecording& other) -{ - LLStopWatchControlsMixin::splitFrom(other); - mPotentialRecording.splitFrom(other.mPotentialRecording); -} /////////////////////////////////////////////////////////////////////// // ExtendablePeriodicRecording @@ -639,13 +582,13 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other) ExtendablePeriodicRecording::ExtendablePeriodicRecording() : mAcceptedRecording(0), mPotentialRecording(0) -{ -} +{} void ExtendablePeriodicRecording::extend() { + llassert(mPotentialRecording.getPlayState() == getPlayState()); // stop recording to get latest data - mPotentialRecording.stop(); + mPotentialRecording.pause(); // push the data back to accepted recording mAcceptedRecording.appendPeriodicRecording(mPotentialRecording); // flush data, so we can start from scratch @@ -654,55 +597,28 @@ void ExtendablePeriodicRecording::extend() mPotentialRecording.setPlayState(getPlayState()); } -void ExtendablePeriodicRecording::start() -{ - LLStopWatchControlsMixin::start(); - mPotentialRecording.start(); -} -void ExtendablePeriodicRecording::stop() +void ExtendablePeriodicRecording::handleStart() { - LLStopWatchControlsMixin::stop(); - mPotentialRecording.stop(); + mPotentialRecording.start(); } -void ExtendablePeriodicRecording::pause() +void ExtendablePeriodicRecording::handleStop() { - LLStopWatchControlsMixin::pause(); mPotentialRecording.pause(); } -void ExtendablePeriodicRecording::resume() -{ - LLStopWatchControlsMixin::resume(); - mPotentialRecording.resume(); -} - -void ExtendablePeriodicRecording::restart() -{ - LLStopWatchControlsMixin::restart(); - mAcceptedRecording.reset(); - mPotentialRecording.restart(); -} - -void ExtendablePeriodicRecording::reset() +void ExtendablePeriodicRecording::handleReset() { - LLStopWatchControlsMixin::reset(); mAcceptedRecording.reset(); mPotentialRecording.reset(); } -void ExtendablePeriodicRecording::splitTo(ExtendablePeriodicRecording& other) +void ExtendablePeriodicRecording::handleSplitTo(ExtendablePeriodicRecording& other) { - LLStopWatchControlsMixin::splitTo(other); mPotentialRecording.splitTo(other.mPotentialRecording); } -void ExtendablePeriodicRecording::splitFrom(ExtendablePeriodicRecording& other) -{ - LLStopWatchControlsMixin::splitFrom(other); - mPotentialRecording.splitFrom(other.mPotentialRecording); -} PeriodicRecording& get_frame_recording() { -- cgit v1.2.3 From f850ae03b399a5cc7aa32f82b8ed996518a86a2a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 00:01:57 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed copy construction of Recorders, eliminated most zero-length frames fixed reset behavior of periodic recordings and extendable recordings to clear entire history removed busy-loop recording of stats from worker threads...stats reported only when work is done --- indra/llcommon/lltracerecording.cpp | 38 +++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 6b5c6c7d3e..4aa3a5a0f7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -133,11 +133,19 @@ Recording::Recording() {} Recording::Recording( const Recording& other ) -: RecordingBuffers(other), - mElapsedSeconds(other.mElapsedSeconds), - mSamplingTimer(other.mSamplingTimer) +: mSamplingTimer(other.mSamplingTimer) { - LLStopWatchControlsMixin::setPlayState(other.getPlayState()); + Recording& mutable_other = const_cast(other); + EPlayState other_play_state = other.getPlayState(); + mutable_other.pause(); + + appendBuffers(other); + + 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; } @@ -380,9 +388,7 @@ void PeriodicRecording::nextPeriod() Recording& old_recording = getCurRecording(); - mCurPeriod = mRecordingPeriods.empty() - ? mCurPeriod + 1 - : (mCurPeriod + 1) % mRecordingPeriods.size(); + mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); old_recording.splitTo(getCurRecording()); } @@ -526,9 +532,22 @@ void PeriodicRecording::handleStop() void PeriodicRecording::handleReset() { - mRecordingPeriods.clear(); - mRecordingPeriods.push_back(Recording()); + if (mAutoResize) + { + mRecordingPeriods.clear(); + mRecordingPeriods.push_back(Recording()); + } + else + { + for (std::vector::iterator it = mRecordingPeriods.begin(), end_it = mRecordingPeriods.end(); + it != end_it; + ++it) + { + it->reset(); + } + } mCurPeriod = 0; + getCurRecording().setPlayState(getPlayState()); } void PeriodicRecording::handleSplitTo(PeriodicRecording& other) @@ -656,7 +675,6 @@ void LLStopWatchControlsMixinCommon::stop() case STOPPED: break; case PAUSED: - handleStop(); break; case STARTED: handleStop(); -- cgit v1.2.3 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 From 9ae76d12157641033431381959ef4f798a119b8d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 29 May 2013 17:00:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed copy construction behavior of Recordings to not zero out data split measurement into event and sample, with sample representing a continuous function --- indra/llcommon/lltracerecording.cpp | 188 +++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 48 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index cced6546ba..5b0b74524f 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -45,9 +45,11 @@ RecordingBuffers::RecordingBuffers() void RecordingBuffers::handOffTo(RecordingBuffers& other) { other.mCountsFloat.reset(&mCountsFloat); - other.mMeasurementsFloat.reset(&mMeasurementsFloat); other.mCounts.reset(&mCounts); - other.mMeasurements.reset(&mMeasurements); + other.mSamplesFloat.reset(&mSamplesFloat); + other.mSamples.reset(&mSamples); + other.mEventsFloat.reset(&mEventsFloat); + other.mEvents.reset(&mEvents); other.mStackTimers.reset(&mStackTimers); other.mMemStats.reset(&mMemStats); } @@ -55,9 +57,11 @@ void RecordingBuffers::handOffTo(RecordingBuffers& other) void RecordingBuffers::makePrimary() { mCountsFloat.makePrimary(); - mMeasurementsFloat.makePrimary(); mCounts.makePrimary(); - mMeasurements.makePrimary(); + mSamplesFloat.makePrimary(); + mSamples.makePrimary(); + mEventsFloat.makePrimary(); + mEvents.makePrimary(); mStackTimers.makePrimary(); mMemStats.makePrimary(); @@ -82,9 +86,11 @@ bool RecordingBuffers::isPrimary() const void RecordingBuffers::append( const RecordingBuffers& other ) { mCountsFloat.addSamples(other.mCountsFloat); - mMeasurementsFloat.addSamples(other.mMeasurementsFloat); mCounts.addSamples(other.mCounts); - mMeasurements.addSamples(other.mMeasurements); + mSamplesFloat.addSamples(other.mSamplesFloat); + mSamples.addSamples(other.mSamples); + mEventsFloat.addSamples(other.mEventsFloat); + mEvents.addSamples(other.mEvents); mMemStats.addSamples(other.mMemStats); mStackTimers.addSamples(other.mStackTimers); } @@ -92,22 +98,32 @@ void RecordingBuffers::append( const RecordingBuffers& other ) void RecordingBuffers::merge( const RecordingBuffers& other) { mCountsFloat.addSamples(other.mCountsFloat); - mMeasurementsFloat.addSamples(other.mMeasurementsFloat); mCounts.addSamples(other.mCounts); - mMeasurements.addSamples(other.mMeasurements); + mSamplesFloat.addSamples(other.mSamplesFloat); + mSamples.addSamples(other.mSamples); + mEventsFloat.addSamples(other.mEventsFloat); + mEvents.addSamples(other.mEvents); mMemStats.addSamples(other.mMemStats); } void RecordingBuffers::reset(RecordingBuffers* other) { mCountsFloat.reset(other ? &other->mCountsFloat : NULL); - mMeasurementsFloat.reset(other ? &other->mMeasurementsFloat : NULL); mCounts.reset(other ? &other->mCounts : NULL); - mMeasurements.reset(other ? &other->mMeasurements : NULL); + mSamplesFloat.reset(other ? &other->mSamplesFloat : NULL); + mSamples.reset(other ? &other->mSamples : NULL); + mEventsFloat.reset(other ? &other->mEventsFloat : NULL); + mEvents.reset(other ? &other->mEvents : NULL); mStackTimers.reset(other ? &other->mStackTimers : NULL); mMemStats.reset(other ? &other->mMemStats : NULL); } +void RecordingBuffers::flush() +{ + mSamplesFloat.flush(); + mSamples.flush(); +} + /////////////////////////////////////////////////////////////////////// // Recording /////////////////////////////////////////////////////////////////////// @@ -120,6 +136,9 @@ Recording::Recording() Recording::Recording( const Recording& other ) { + // this will allow us to seamlessly start without affecting any data we've acquired from other + setPlayState(PAUSED); + Recording& mutable_other = const_cast(other); EPlayState other_play_state = other.getPlayState(); mutable_other.pause(); @@ -137,15 +156,18 @@ Recording::Recording( const Recording& other ) Recording::~Recording() { - stop(); - llassert(isStopped()); + if (isStarted() && LLTrace::get_thread_recorder().notNull()) + { + LLTrace::get_thread_recorder()->deactivate(this); + } } void Recording::update() { if (isStarted()) { - LLTrace::get_thread_recorder()->update(this); + mBuffers.write()->flush(); + LLTrace::get_thread_recorder()->bringUpToDate(this); mSamplingTimer.reset(); } } @@ -167,6 +189,7 @@ void Recording::handleStart() void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + mBuffers.write()->flush(); LLTrace::TimeBlock::processTimes(); LLTrace::get_thread_recorder()->deactivate(this); } @@ -178,13 +201,23 @@ void Recording::handleSplitTo(Recording& other) void Recording::appendRecording( const Recording& other ) { - mBuffers.write()->append(*other.mBuffers); - mElapsedSeconds += other.mElapsedSeconds; + EPlayState play_state = getPlayState(); + { + pause(); + mBuffers.write()->append(*other.mBuffers); + mElapsedSeconds += other.mElapsedSeconds; + } + setPlayState(play_state); } void Recording::mergeRecording( const Recording& other) { - mBuffers.write()->merge(*other.mBuffers); + EPlayState play_state = getPlayState(); + { + pause(); + mBuffers.write()->merge(*other.mBuffers); + } + setPlayState(play_state); } LLUnit Recording::getSum(const TraceType& stat) const @@ -248,14 +281,14 @@ S64 Recording::getSum( const TraceType >& stat ) const return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType >& stat ) const +F64 Recording::getSum( const TraceType >& stat ) const { - return (F64)mBuffers->mMeasurementsFloat[stat.getIndex()].getSum(); + return (F64)mBuffers->mEventsFloat[stat.getIndex()].getSum(); } -S64 Recording::getSum( const TraceType >& stat ) const +S64 Recording::getSum( const TraceType >& stat ) const { - return (S64)mBuffers->mMeasurements[stat.getIndex()].getSum(); + return (S64)mBuffers->mEvents[stat.getIndex()].getSum(); } @@ -283,67 +316,127 @@ U32 Recording::getSampleCount( const TraceType >& stat ) c U32 Recording::getSampleCount( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); + return mBuffers->mCounts[stat.getIndex()].getSampleCount(); +} + +F64 Recording::getMin( const TraceType >& stat ) const +{ + return mBuffers->mSamplesFloat[stat.getIndex()].getMin(); +} + +S64 Recording::getMin( const TraceType >& stat ) const +{ + return mBuffers->mSamples[stat.getIndex()].getMin(); +} + +F64 Recording::getMax( const TraceType >& stat ) const +{ + return mBuffers->mSamplesFloat[stat.getIndex()].getMax(); +} + +S64 Recording::getMax( const TraceType >& stat ) const +{ + return mBuffers->mSamples[stat.getIndex()].getMax(); +} + +F64 Recording::getMean( const TraceType >& stat ) const +{ + return mBuffers->mSamplesFloat[stat.getIndex()].getMean(); +} + +F64 Recording::getMean( const TraceType >& stat ) const +{ + return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getMin( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getMin(); + return mBuffers->mSamplesFloat[stat.getIndex()].getStandardDeviation(); } -S64 Recording::getMin( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getMin(); + return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getMax( const TraceType >& stat ) const +F64 Recording::getLastValue( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getMax(); + return mBuffers->mSamplesFloat[stat.getIndex()].getLastValue(); } -S64 Recording::getMax( const TraceType >& stat ) const +S64 Recording::getLastValue( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getMax(); + return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -F64 Recording::getMean( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getMean(); + return mBuffers->mSamplesFloat[stat.getIndex()].getSampleCount(); } -F64 Recording::getMean( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getMean(); + return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +F64 Recording::getMin( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getStandardDeviation(); + return mBuffers->mEventsFloat[stat.getIndex()].getMin(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +S64 Recording::getMin( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getStandardDeviation(); + return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getLastValue( const TraceType >& stat ) const +F64 Recording::getMax( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getLastValue(); + return mBuffers->mEventsFloat[stat.getIndex()].getMax(); } -S64 Recording::getLastValue( const TraceType >& stat ) const +S64 Recording::getMax( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getLastValue(); + return mBuffers->mEvents[stat.getIndex()].getMax(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) const { - return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); + return mBuffers->mEventsFloat[stat.getIndex()].getMean(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) const { - return mBuffers->mMeasurements[stat.getIndex()].getSampleCount(); + return mBuffers->mEvents[stat.getIndex()].getMean(); +} + +F64 Recording::getStandardDeviation( const TraceType >& stat ) const +{ + return mBuffers->mEventsFloat[stat.getIndex()].getStandardDeviation(); +} + +F64 Recording::getStandardDeviation( const TraceType >& stat ) const +{ + return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); +} + +F64 Recording::getLastValue( const TraceType >& stat ) const +{ + return mBuffers->mEventsFloat[stat.getIndex()].getLastValue(); +} + +S64 Recording::getLastValue( const TraceType >& stat ) const +{ + return mBuffers->mEvents[stat.getIndex()].getLastValue(); +} + +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return mBuffers->mEventsFloat[stat.getIndex()].getSampleCount(); +} + +U32 Recording::getSampleCount( const TraceType >& stat ) const +{ + return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } /////////////////////////////////////////////////////////////////////// @@ -377,7 +470,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) if (other.mRecordingPeriods.empty()) return; EPlayState play_state = getPlayState(); - stop(); + pause(); EPlayState other_play_state = other.getPlayState(); other.pause(); @@ -466,8 +559,7 @@ LLTrace::Recording PeriodicRecording::snapshotCurRecording() const Recording& PeriodicRecording::getLastRecording() { - U32 num_periods = mRecordingPeriods.size(); - return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; + return getPrevRecording(1); } const Recording& PeriodicRecording::getLastRecording() const -- cgit v1.2.3 From ae355188327515d53b9c15c27ed576829fce3668 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 30 May 2013 18:30:11 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed LLTrace::ExtendablePeriodicRecording::extend() to include *all* frame extensions gated SlaveThreadRecorder pushing to master based on master update rate reverted changes to LLThreadLocalSingletonPointer to not use offset-from-default trick --- indra/llcommon/lltracerecording.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5b0b74524f..86cdca3e10 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -490,8 +490,9 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) { if (mAutoResize) { - for (S32 other_index = (other.mCurPeriod + 2) % other_recording_count; - other_index != other.mCurPeriod; + for (S32 other_index = (other.mCurPeriod + 2) % other_recording_count, + end_index = (other.mCurPeriod + 1) % other_recording_count; + other_index != end_index; other_index = (other_index + 1) % other_recording_count) { llassert(other.mRecordingPeriods[other_index].getDuration() != 0.f -- cgit v1.2.3 From e50e6004082223fdc0bfd78bc697d48a7f45b379 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 30 May 2013 20:15:48 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics reverted SlaveThreadRecorder update gating moved processTimes() outside of Recording, so it is called only once per frame refined sample merge logic so that multi-threaded samples do not stomp on linear history of a stat --- indra/llcommon/lltracerecording.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 86cdca3e10..3994e4f521 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -97,13 +97,15 @@ void RecordingBuffers::append( const RecordingBuffers& other ) void RecordingBuffers::merge( const RecordingBuffers& other) { - mCountsFloat.addSamples(other.mCountsFloat); - mCounts.addSamples(other.mCounts); - mSamplesFloat.addSamples(other.mSamplesFloat); - mSamples.addSamples(other.mSamples); - mEventsFloat.addSamples(other.mEventsFloat); - mEvents.addSamples(other.mEvents); - mMemStats.addSamples(other.mMemStats); + mCountsFloat.addSamples(other.mCountsFloat, false); + mCounts.addSamples(other.mCounts, false); + mSamplesFloat.addSamples(other.mSamplesFloat, false); + mSamples.addSamples(other.mSamples, false); + mEventsFloat.addSamples(other.mEventsFloat, false); + mEvents.addSamples(other.mEvents, false); + mMemStats.addSamples(other.mMemStats, false); + // for now, hold out timers from merge, need to be displayed per thread + //mStackTimers.addSamples(other.mStackTimers, false); } void RecordingBuffers::reset(RecordingBuffers* other) @@ -190,7 +192,6 @@ void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); mBuffers.write()->flush(); - LLTrace::TimeBlock::processTimes(); LLTrace::get_thread_recorder()->deactivate(this); } -- cgit v1.2.3 From 9def3590f41dee3cba7760e4443fdc71f5fb2db6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 31 May 2013 16:01:46 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed multithreading lltrace causing values to be interpolated towards 0 added Radians unit improved sceneloadmonitor restart heuristic to use accumulated camera motion --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 3994e4f521..e45639a034 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -538,7 +538,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) other.setPlayState(other_play_state); } -LLUnit PeriodicRecording::getDuration() +LLUnit PeriodicRecording::getDuration() const { LLUnit duration; size_t num_periods = mRecordingPeriods.size(); -- cgit v1.2.3 From fd21ddd9d0adf7342fe89d371868c3f7f7ca9f5f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 31 May 2013 23:40:10 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics made recordings auto-update when executing query while active --- indra/llcommon/lltracerecording.cpp | 119 ++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 40 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e45639a034..aedb9c7542 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -221,88 +221,101 @@ void Recording::mergeRecording( const Recording& other) setPlayState(play_state); } -LLUnit Recording::getSum(const TraceType& stat) const +LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + update(); return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } -LLUnit Recording::getSum(const TraceType& stat) const +LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + update(); return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } -U32 Recording::getSum(const TraceType& stat) const +U32 Recording::getSum(const TraceType& stat) { + update(); return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -LLUnit Recording::getPerSec(const TraceType& stat) const +LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + update(); return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } -LLUnit Recording::getPerSec(const TraceType& stat) const +LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + update(); return (F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } -F32 Recording::getPerSec(const TraceType& stat) const +F32 Recording::getPerSec(const TraceType& stat) { + update(); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds; } -LLUnit Recording::getSum(const TraceType& stat) const +LLUnit Recording::getSum(const TraceType& stat) { + update(); return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } -LLUnit Recording::getPerSec(const TraceType& stat) const +LLUnit Recording::getPerSec(const TraceType& stat) { + update(); return (F32)mBuffers->mMemStats[stat.getIndex()].mAllocatedCount / mElapsedSeconds; } -F64 Recording::getSum( const TraceType >& stat ) const +F64 Recording::getSum( const TraceType >& stat ) { + update(); return mBuffers->mCountsFloat[stat.getIndex()].getSum(); } -S64 Recording::getSum( const TraceType >& stat ) const +S64 Recording::getSum( const TraceType >& stat ) { + update(); return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType >& stat ) const +F64 Recording::getSum( const TraceType >& stat ) { + update(); return (F64)mBuffers->mEventsFloat[stat.getIndex()].getSum(); } -S64 Recording::getSum( const TraceType >& stat ) const +S64 Recording::getSum( const TraceType >& stat ) { + update(); return (S64)mBuffers->mEvents[stat.getIndex()].getSum(); } -F64 Recording::getPerSec( const TraceType >& stat ) const +F64 Recording::getPerSec( const TraceType >& stat ) { + update(); F64 sum = mBuffers->mCountsFloat[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; } -F64 Recording::getPerSec( const TraceType >& stat ) const +F64 Recording::getPerSec( const TraceType >& stat ) { S64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0) @@ -310,133 +323,159 @@ F64 Recording::getPerSec( const TraceType >& stat ) const : 0.0; } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) const +F64 Recording::getMin( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getMin(); } -S64 Recording::getMin( const TraceType >& stat ) const +S64 Recording::getMin( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) const +F64 Recording::getMax( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getMax(); } -S64 Recording::getMax( const TraceType >& stat ) const +S64 Recording::getMax( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getMean(); } -F64 Recording::getMean( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) const +F64 Recording::getLastValue( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getLastValue(); } -S64 Recording::getLastValue( const TraceType >& stat ) const +S64 Recording::getLastValue( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mSamplesFloat[stat.getIndex()].getSampleCount(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) const +F64 Recording::getMin( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getMin(); } -S64 Recording::getMin( const TraceType >& stat ) const +S64 Recording::getMin( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) const +F64 Recording::getMax( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getMax(); } -S64 Recording::getMax( const TraceType >& stat ) const +S64 Recording::getMax( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getMean(); } -F64 Recording::getMean( const TraceType >& stat ) const +F64 Recording::getMean( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) const +F64 Recording::getStandardDeviation( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) const +F64 Recording::getLastValue( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getLastValue(); } -S64 Recording::getLastValue( const TraceType >& stat ) const +S64 Recording::getLastValue( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mEventsFloat[stat.getIndex()].getSampleCount(); } -U32 Recording::getSampleCount( const TraceType >& stat ) const +U32 Recording::getSampleCount( const TraceType >& stat ) { + update(); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } -- cgit v1.2.3 From 233201f8227f92e93061d3e2393a17b42dfa3dd1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Jun 2013 22:49:17 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed unnecessary templates from accumulator types...now always track data in double precision floating point, using templated accessors to convert to and from arbitrary types --- indra/llcommon/lltracerecording.cpp | 268 ++++++++++++++++++------------------ 1 file changed, 134 insertions(+), 134 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index aedb9c7542..61ba21a365 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,11 +44,8 @@ RecordingBuffers::RecordingBuffers() void RecordingBuffers::handOffTo(RecordingBuffers& other) { - other.mCountsFloat.reset(&mCountsFloat); other.mCounts.reset(&mCounts); - other.mSamplesFloat.reset(&mSamplesFloat); other.mSamples.reset(&mSamples); - other.mEventsFloat.reset(&mEventsFloat); other.mEvents.reset(&mEvents); other.mStackTimers.reset(&mStackTimers); other.mMemStats.reset(&mMemStats); @@ -56,11 +53,8 @@ void RecordingBuffers::handOffTo(RecordingBuffers& other) void RecordingBuffers::makePrimary() { - mCountsFloat.makePrimary(); mCounts.makePrimary(); - mSamplesFloat.makePrimary(); mSamples.makePrimary(); - mEventsFloat.makePrimary(); mEvents.makePrimary(); mStackTimers.makePrimary(); mMemStats.makePrimary(); @@ -85,11 +79,8 @@ bool RecordingBuffers::isPrimary() const void RecordingBuffers::append( const RecordingBuffers& other ) { - mCountsFloat.addSamples(other.mCountsFloat); mCounts.addSamples(other.mCounts); - mSamplesFloat.addSamples(other.mSamplesFloat); mSamples.addSamples(other.mSamples); - mEventsFloat.addSamples(other.mEventsFloat); mEvents.addSamples(other.mEvents); mMemStats.addSamples(other.mMemStats); mStackTimers.addSamples(other.mStackTimers); @@ -97,11 +88,8 @@ void RecordingBuffers::append( const RecordingBuffers& other ) void RecordingBuffers::merge( const RecordingBuffers& other) { - mCountsFloat.addSamples(other.mCountsFloat, false); mCounts.addSamples(other.mCounts, false); - mSamplesFloat.addSamples(other.mSamplesFloat, false); mSamples.addSamples(other.mSamples, false); - mEventsFloat.addSamples(other.mEventsFloat, false); mEvents.addSamples(other.mEvents, false); mMemStats.addSamples(other.mMemStats, false); // for now, hold out timers from merge, need to be displayed per thread @@ -110,11 +98,8 @@ void RecordingBuffers::merge( const RecordingBuffers& other) void RecordingBuffers::reset(RecordingBuffers* other) { - mCountsFloat.reset(other ? &other->mCountsFloat : NULL); mCounts.reset(other ? &other->mCounts : NULL); - mSamplesFloat.reset(other ? &other->mSamplesFloat : NULL); mSamples.reset(other ? &other->mSamples : NULL); - mEventsFloat.reset(other ? &other->mEventsFloat : NULL); mEvents.reset(other ? &other->mEvents : NULL); mStackTimers.reset(other ? &other->mStackTimers : NULL); mMemStats.reset(other ? &other->mMemStats : NULL); @@ -122,7 +107,6 @@ void RecordingBuffers::reset(RecordingBuffers* other) void RecordingBuffers::flush() { - mSamplesFloat.flush(); mSamples.flush(); } @@ -280,200 +264,100 @@ LLUnit Recording::getPerSec(const TraceType >& stat ) -{ - update(); - return mBuffers->mCountsFloat[stat.getIndex()].getSum(); -} - -S64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getSum( const TraceType& stat ) { update(); return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getSum( const TraceType& stat ) { update(); - return (F64)mBuffers->mEventsFloat[stat.getIndex()].getSum(); + return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } -S64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getPerSec( const TraceType& stat ) { update(); - return (S64)mBuffers->mEvents[stat.getIndex()].getSum(); -} - - - -F64 Recording::getPerSec( const TraceType >& stat ) -{ - update(); - F64 sum = mBuffers->mCountsFloat[stat.getIndex()].getSum(); + F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; } -F64 Recording::getPerSec( const TraceType >& stat ) -{ - S64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return (sum != 0) - ? ((F64)sum / mElapsedSeconds) - : 0.0; -} - -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMin(); -} - -S64 Recording::getMin( const TraceType >& stat ) +F64 Recording::getMin( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMax(); -} - -S64 Recording::getMax( const TraceType >& stat ) +F64 Recording::getMax( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMean(); -} - -F64 Recording::getMean( const TraceType >& stat ) +F64 Recording::getMean( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getStandardDeviation(); -} - -F64 Recording::getStandardDeviation( const TraceType >& stat ) +F64 Recording::getStandardDeviation( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getLastValue(); -} - -S64 Recording::getLastValue( const TraceType >& stat ) +F64 Recording::getLastValue( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMin(); -} - -S64 Recording::getMin( const TraceType >& stat ) +F64 Recording::getMin( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMax(); -} - -S64 Recording::getMax( const TraceType >& stat ) +F64 Recording::getMax( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMean(); -} - -F64 Recording::getMean( const TraceType >& stat ) +F64 Recording::getMean( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getStandardDeviation(); -} - -F64 Recording::getStandardDeviation( const TraceType >& stat ) +F64 Recording::getStandardDeviation( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getLastValue(); -} - -S64 Recording::getLastValue( const TraceType >& stat ) +F64 Recording::getLastValue( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); @@ -667,6 +551,122 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } + +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 mean = 0; + if (num_periods <= 0) { return mean; } + + S32 total_sample_count = 0; + + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) + { + S32 period_sample_count = mRecordingPeriods[index].getSampleCount(stat); + mean += mRecordingPeriods[index].getMean(stat) * period_sample_count; + total_sample_count += period_sample_count; + } + } + + if (total_sample_count) + { + mean = mean / total_sample_count; + } + return mean; +} + +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 min_val = std::numeric_limits::max(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } + return min_val; +} + +F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 max_val = std::numeric_limits::min(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + } + return max_val; +} + +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 min_val = std::numeric_limits::max(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } + return min_val; +} + +F64 PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 max_val = std::numeric_limits::min(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + } + return max_val; +} + + +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + LLUnit total_duration = 0.f; + + F64 mean = 0; + if (num_periods <= 0) { return mean; } + + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) + { + LLUnit recording_duration = mRecordingPeriods[index].getDuration(); + mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); + total_duration += recording_duration; + } + } + + if (total_duration.value()) + { + mean = mean / total_duration; + } + return mean; +} + + + /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From a74b5dfa923f8eeccc9b786143f0f832de3ad450 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Jun 2013 19:45:33 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed mem stat tracking...now properly tracks memory footprint with floating point precision cleaned up macros for unit declaration renamed units to SI standard for 1024 multiples (kibibytes, etc) fixed units output for scene monitor dump --- indra/llcommon/lltracerecording.cpp | 74 +++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 7 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 61ba21a365..d32504b014 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -213,7 +213,7 @@ LLUnit Recording::getSum(const TraceType Recording::getSum(const TraceType& stat) +LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; update(); @@ -221,7 +221,7 @@ LLUnit Recording::getSum(const TraceType& stat) +U32 Recording::getSum(const TraceType& stat) { update(); return mBuffers->mStackTimers[stat.getIndex()].mCalls; @@ -236,7 +236,7 @@ LLUnit Recording::getPerSec(const TraceType Recording::getPerSec(const TraceType& stat) +LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -245,22 +245,82 @@ LLUnit Recording::getPerSec(const TraceType& stat) +F32 Recording::getPerSec(const TraceType& stat) { update(); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds; } -LLUnit Recording::getSum(const TraceType& stat) +LLUnit Recording::getMin(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mSize.getMin(); +} + +LLUnit Recording::getMean(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mSize.getMean(); +} + +LLUnit Recording::getMax(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mSize.getMax(); +} + +LLUnit Recording::getStandardDeviation(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation(); +} + +LLUnit Recording::getLastValue(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue(); +} + +LLUnit Recording::getMin(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin(); +} + +LLUnit Recording::getMean(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean(); +} + +LLUnit Recording::getMax(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax(); +} + +LLUnit Recording::getStandardDeviation(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation(); +} + +LLUnit Recording::getLastValue(const TraceType& stat) +{ + update(); + return mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue(); +} + +U32 Recording::getSum(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } -LLUnit Recording::getPerSec(const TraceType& stat) +U32 Recording::getSum(const TraceType& stat) { update(); - return (F32)mBuffers->mMemStats[stat.getIndex()].mAllocatedCount / mElapsedSeconds; + return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } -- cgit v1.2.3 From 9fd3af3c389ed491b515cbb5136b344b069913e4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 13 Jun 2013 15:29:15 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed Units macros and argument order to make it more clear optimized units for integer types fixed merging of periodicrecordings...should eliminate duplicate entries in sceneloadmonitor history --- indra/llcommon/lltracerecording.cpp | 189 ++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 96 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index d32504b014..ff90da3822 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -186,26 +186,18 @@ void Recording::handleSplitTo(Recording& other) void Recording::appendRecording( const Recording& other ) { - EPlayState play_state = getPlayState(); - { - pause(); - mBuffers.write()->append(*other.mBuffers); - mElapsedSeconds += other.mElapsedSeconds; - } - setPlayState(play_state); + update(); + mBuffers.write()->append(*other.mBuffers); + mElapsedSeconds += other.mElapsedSeconds; } void Recording::mergeRecording( const Recording& other) { - EPlayState play_state = getPlayState(); - { - pause(); - mBuffers.write()->merge(*other.mBuffers); - } - setPlayState(play_state); + update(); + mBuffers.write()->merge(*other.mBuffers); } -LLUnit Recording::getSum(const TraceType& stat) +LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; update(); @@ -213,7 +205,7 @@ LLUnit Recording::getSum(const TraceType Recording::getSum(const TraceType& stat) +LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; update(); @@ -227,85 +219,85 @@ U32 Recording::getSum(const TraceType& sta return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -LLUnit Recording::getPerSec(const TraceType& stat) +LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; update(); return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); } -LLUnit Recording::getPerSec(const TraceType& stat) +LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; update(); return (F64)(accumulator.mSelfTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); } F32 Recording::getPerSec(const TraceType& stat) { update(); - return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds; + return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -LLUnit Recording::getMin(const TraceType& stat) +LLUnit Recording::getMin(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMin(); } -LLUnit Recording::getMean(const TraceType& stat) +LLUnit Recording::getMean(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMean(); } -LLUnit Recording::getMax(const TraceType& stat) +LLUnit Recording::getMax(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMax(); } -LLUnit Recording::getStandardDeviation(const TraceType& stat) +LLUnit Recording::getStandardDeviation(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation(); } -LLUnit Recording::getLastValue(const TraceType& stat) +LLUnit Recording::getLastValue(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue(); } -LLUnit Recording::getMin(const TraceType& stat) +LLUnit Recording::getMin(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin(); } -LLUnit Recording::getMean(const TraceType& stat) +LLUnit Recording::getMean(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean(); } -LLUnit Recording::getMax(const TraceType& stat) +LLUnit Recording::getMax(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax(); } -LLUnit Recording::getStandardDeviation(const TraceType& stat) +LLUnit Recording::getStandardDeviation(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation(); } -LLUnit Recording::getLastValue(const TraceType& stat) +LLUnit Recording::getLastValue(const TraceType& stat) { update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue(); @@ -341,7 +333,7 @@ F64 Recording::getPerSec( const TraceType& stat ) update(); F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0.0) - ? (sum / mElapsedSeconds) + ? (sum / mElapsedSeconds.value()) : 0.0; } @@ -430,6 +422,7 @@ U32 Recording::getSampleCount( const TraceType& stat ) PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), mCurPeriod(0), + mNumPeriods(0), mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); @@ -443,9 +436,20 @@ void PeriodicRecording::nextPeriod() } Recording& old_recording = getCurRecording(); - mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); old_recording.splitTo(getCurRecording()); + + mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + 1); +} + +void PeriodicRecording::appendRecording(Recording& recording) +{ + // if I have a recording of any length, then close it off and start a fresh one + if (getCurRecording().getDuration().value()) + { + nextPeriod(); + } + getCurRecording().appendRecording(recording); } @@ -453,77 +457,77 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) { if (other.mRecordingPeriods.empty()) return; - EPlayState play_state = getPlayState(); - pause(); - - EPlayState other_play_state = other.getPlayState(); - other.pause(); - - U32 other_recording_count = other.mRecordingPeriods.size(); - - Recording& other_oldest_recording = other.mRecordingPeriods[(other.mCurPeriod + 1) % other.mRecordingPeriods.size()]; + getCurRecording().update(); + other.getCurRecording().update(); // if I have a recording of any length, then close it off and start a fresh one if (getCurRecording().getDuration().value()) { nextPeriod(); } - getCurRecording().appendRecording(other_oldest_recording); - if (other_recording_count > 1) + if (mAutoResize) { - if (mAutoResize) + S32 other_index = (other.mCurPeriod + 1) % other.mRecordingPeriods.size(); + S32 end_index = (other.mCurPeriod) % other.mRecordingPeriods.size(); + + do { - for (S32 other_index = (other.mCurPeriod + 2) % other_recording_count, - end_index = (other.mCurPeriod + 1) % other_recording_count; - other_index != end_index; - other_index = (other_index + 1) % other_recording_count) + if (other.mRecordingPeriods[other_index].getDuration().value()) { - llassert(other.mRecordingPeriods[other_index].getDuration() != 0.f - && (mRecordingPeriods.empty() - || other.mRecordingPeriods[other_index].getDuration() != mRecordingPeriods.back().getDuration())); mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); } - - mCurPeriod = mRecordingPeriods.size() - 1; + other_index = (other_index + 1) % other.mRecordingPeriods.size(); } - else + while(other_index != end_index); + + mCurPeriod = mRecordingPeriods.size() - 1; + mNumPeriods = mRecordingPeriods.size(); + } + else + { + //FIXME: get proper number of recordings from other...might not have used all its slots + size_t num_to_copy = llmin( mRecordingPeriods.size(), other.getNumRecordedPeriods()); + std::vector::iterator src_it = other.mRecordingPeriods.begin() + + ( (other.mCurPeriod + 1 // oldest period + + (other.mRecordingPeriods.size() - num_to_copy)) // minus room for copy + % other.mRecordingPeriods.size()); + std::vector::iterator dest_it = mRecordingPeriods.begin() + mCurPeriod; + + for(size_t i = 0; i < num_to_copy; i++) { - size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() - 1); - std::vector::iterator src_it = other.mRecordingPeriods.begin() - + ( (other.mCurPeriod + 1 // oldest period - + (other.mRecordingPeriods.size() - num_to_copy)) // minus room for copy - % other.mRecordingPeriods.size()); - std::vector::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); - - for(S32 i = 0; i < num_to_copy; i++) - { - *dest_it = *src_it; + *dest_it = *src_it; - if (++src_it == other.mRecordingPeriods.end()) - { - src_it = other.mRecordingPeriods.begin(); - } + if (++src_it == other.mRecordingPeriods.end()) + { + src_it = other.mRecordingPeriods.begin(); + } - if (++dest_it == mRecordingPeriods.end()) - { - dest_it = mRecordingPeriods.begin(); - } + if (++dest_it == mRecordingPeriods.end()) + { + dest_it = mRecordingPeriods.begin(); } - - mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); } + + // want argument to % to be positive, otherwise result could be negative and thus out of bounds + llassert(num_to_copy >= 1); + // advance to last recording period copied, so we can check if the last period had actually carried any data, in which case we'll advance below + // using nextPeriod() which retains continuity (mLastValue, etc) + mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size(); + mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + num_to_copy); } - nextPeriod(); - - setPlayState(play_state); - other.setPlayState(other_play_state); + if (getCurRecording().getDuration().value()) + { + //call this to chain last period copied to new active period + nextPeriod(); + } + getCurRecording().setPlayState(getPlayState()); } -LLUnit PeriodicRecording::getDuration() const +LLUnit PeriodicRecording::getDuration() const { - LLUnit duration; + LLUnit duration; size_t num_periods = mRecordingPeriods.size(); for (size_t i = 1; i <= num_periods; i++) { @@ -615,7 +619,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 mean = 0; if (num_periods <= 0) { return mean; } @@ -643,7 +647,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, s F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) @@ -657,7 +661,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, si F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 max_val = std::numeric_limits::min(); for (S32 i = 1; i <= num_periods; i++) @@ -671,7 +675,7 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, si F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) @@ -685,7 +689,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s F64 PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 max_val = std::numeric_limits::min(); for (S32 i = 1; i <= num_periods; i++) @@ -700,9 +704,9 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - LLUnit total_duration = 0.f; + LLUnit total_duration = 0.f; F64 mean = 0; if (num_periods <= 0) { return mean; } @@ -712,7 +716,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 index = (mCurPeriod + total_periods - i) % total_periods; if (mRecordingPeriods[index].getDuration() > 0.f) { - LLUnit recording_duration = mRecordingPeriods[index].getDuration(); + LLUnit recording_duration = mRecordingPeriods[index].getDuration(); mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); total_duration += recording_duration; } @@ -734,13 +738,11 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, void ExtendableRecording::extend() { // stop recording to get latest data - mPotentialRecording.stop(); + mPotentialRecording.update(); // push the data back to accepted recording mAcceptedRecording.appendRecording(mPotentialRecording); // flush data, so we can start from scratch mPotentialRecording.reset(); - // go back to play state we were in initially - mPotentialRecording.setPlayState(getPlayState()); } void ExtendableRecording::handleStart() @@ -777,15 +779,10 @@ ExtendablePeriodicRecording::ExtendablePeriodicRecording() void ExtendablePeriodicRecording::extend() { - llassert(mPotentialRecording.getPlayState() == getPlayState()); - // stop recording to get latest data - mPotentialRecording.pause(); // push the data back to accepted recording mAcceptedRecording.appendPeriodicRecording(mPotentialRecording); // flush data, so we can start from scratch mPotentialRecording.reset(); - // go back to play state we were in initially - mPotentialRecording.setPlayState(getPlayState()); } -- cgit v1.2.3 From 3f2de87340b1c831ea59e4a3ca960d49f343c9fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 17 Jun 2013 01:18:21 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added getAs and setAs to LLUnit to make it clearer how you specify units removed accidental 0-based indexing of periodicRecording history... should now be consistently 1-based, with 0 accessing current active recording removed per frame timer updates of all historical timer bars in fast timer display added missing assignment operator to recordings --- indra/llcommon/lltracerecording.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ff90da3822..f2c5941011 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -121,22 +121,27 @@ Recording::Recording() } Recording::Recording( const Recording& other ) +{ + *this = other; +} + +Recording& Recording::operator = (const Recording& other) { // this will allow us to seamlessly start without affecting any data we've acquired from other setPlayState(PAUSED); Recording& mutable_other = const_cast(other); + mutable_other.update(); EPlayState other_play_state = other.getPlayState(); - mutable_other.pause(); - mBuffers = other.mBuffers; + mBuffers = mutable_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; + return *this; } @@ -444,12 +449,8 @@ void PeriodicRecording::nextPeriod() void PeriodicRecording::appendRecording(Recording& recording) { - // if I have a recording of any length, then close it off and start a fresh one - if (getCurRecording().getDuration().value()) - { - nextPeriod(); - } getCurRecording().appendRecording(recording); + nextPeriod(); } @@ -460,12 +461,6 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) getCurRecording().update(); other.getCurRecording().update(); - // if I have a recording of any length, then close it off and start a fresh one - if (getCurRecording().getDuration().value()) - { - nextPeriod(); - } - if (mAutoResize) { S32 other_index = (other.mCurPeriod + 1) % other.mRecordingPeriods.size(); -- cgit v1.2.3 From d136c4c29686c565b5a46503aa67a9c958b4145d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Jun 2013 23:41:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate removed implicit flushes on reads from recorders for better performance made sure stack timers were updated on recorder deactivate faster rendering and better ui for fast timer view --- indra/llcommon/lltracerecording.cpp | 38 +++---------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f2c5941011..33002929ea 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -107,7 +107,9 @@ void RecordingBuffers::reset(RecordingBuffers* other) void RecordingBuffers::flush() { - mSamples.flush(); + LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + + mSamples.flush(time_stamp); } /////////////////////////////////////////////////////////////////////// @@ -205,7 +207,6 @@ void Recording::mergeRecording( const Recording& other) LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - update(); return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } @@ -213,14 +214,12 @@ LLUnit Recording::getSum(const TraceType Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - update(); return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } U32 Recording::getSum(const TraceType& stat) { - update(); return mBuffers->mStackTimers[stat.getIndex()].mCalls; } @@ -228,7 +227,6 @@ LLUnit Recording::getPerSec(const TraceTypemStackTimers[stat.getIndex()]; - update(); return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); } @@ -237,105 +235,88 @@ LLUnit Recording::getPerSec(const TraceTypemStackTimers[stat.getIndex()]; - update(); return (F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); } F32 Recording::getPerSec(const TraceType& stat) { - update(); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } LLUnit Recording::getMin(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMin(); } LLUnit Recording::getMean(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMean(); } LLUnit Recording::getMax(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getMax(); } LLUnit Recording::getStandardDeviation(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation(); } LLUnit Recording::getLastValue(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue(); } LLUnit Recording::getMin(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin(); } LLUnit Recording::getMean(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean(); } LLUnit Recording::getMax(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax(); } LLUnit Recording::getStandardDeviation(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation(); } LLUnit Recording::getLastValue(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue(); } U32 Recording::getSum(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } U32 Recording::getSum(const TraceType& stat) { - update(); return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } F64 Recording::getSum( const TraceType& stat ) { - update(); return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const TraceType& stat ) { - update(); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const TraceType& stat ) { - update(); F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds.value()) @@ -344,79 +325,66 @@ F64 Recording::getPerSec( const TraceType& stat ) U32 Recording::getSampleCount( const TraceType& stat ) { - update(); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } F64 Recording::getMin( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType& stat ) { - update(); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } F64 Recording::getMin( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType& stat ) { - update(); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } -- cgit v1.2.3 From 3fe19d883d2856cd7d104810b794eee82d642a3e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 19 Jun 2013 20:30:41 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics scene monitor output is cleaned up, no duplicate first frame, less scientific notation periodic recording extension now works more cleanly --- indra/llcommon/lltracerecording.cpp | 58 ++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 33002929ea..0fe95ee75f 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -428,36 +428,49 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) getCurRecording().update(); other.getCurRecording().update(); + + const U32 other_recording_slots = other.mRecordingPeriods.size(); + const U32 other_num_recordings = other.getNumRecordedPeriods(); + const U32 other_current_recording_index = other.mCurPeriod; + const U32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings + 1) % other_recording_slots; + + // append first recording into our current slot + getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); + + // from now on, add new recordings for everything after the first + U32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; if (mAutoResize) { - S32 other_index = (other.mCurPeriod + 1) % other.mRecordingPeriods.size(); - S32 end_index = (other.mCurPeriod) % other.mRecordingPeriods.size(); + // append first recording into our current slot + getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); - do + // push back recordings for everything in the middle + U32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; + while (other_index != other_current_recording_index) { - if (other.mRecordingPeriods[other_index].getDuration().value()) - { - mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); - } - other_index = (other_index + 1) % other.mRecordingPeriods.size(); + mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); + other_index = (other_index + 1) % other_recording_slots; + } + + // add final recording, if it wasn't already added as the first + if (other_num_recordings > 1) + { + mRecordingPeriods.push_back(other.mRecordingPeriods[other_current_recording_index]); } - while(other_index != end_index); mCurPeriod = mRecordingPeriods.size() - 1; mNumPeriods = mRecordingPeriods.size(); } else { - //FIXME: get proper number of recordings from other...might not have used all its slots - size_t num_to_copy = llmin( mRecordingPeriods.size(), other.getNumRecordedPeriods()); - std::vector::iterator src_it = other.mRecordingPeriods.begin() - + ( (other.mCurPeriod + 1 // oldest period - + (other.mRecordingPeriods.size() - num_to_copy)) // minus room for copy - % other.mRecordingPeriods.size()); + size_t num_to_copy = llmin( mRecordingPeriods.size(), other_num_recordings); + + std::vector::iterator src_it = other.mRecordingPeriods.begin() + other_index ; std::vector::iterator dest_it = mRecordingPeriods.begin() + mCurPeriod; - for(size_t i = 0; i < num_to_copy; i++) + // already consumed the first recording from other, so start counting at 1 + for(size_t i = 1; i < num_to_copy; i++) { *dest_it = *src_it; @@ -474,17 +487,14 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) // want argument to % to be positive, otherwise result could be negative and thus out of bounds llassert(num_to_copy >= 1); - // advance to last recording period copied, so we can check if the last period had actually carried any data, in which case we'll advance below - // using nextPeriod() which retains continuity (mLastValue, etc) + // advance to last recording period copied, and make that our current period mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size(); - mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + num_to_copy); + mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + num_to_copy - 1); } - if (getCurRecording().getDuration().value()) - { - //call this to chain last period copied to new active period - nextPeriod(); - } + // end with fresh period, otherwise next appendPeriodicRecording() will merge the first + // recording period with the last one appended here + nextPeriod(); getCurRecording().setPlayState(getPlayState()); } -- cgit v1.2.3 From 1c51938babfa8c55c61b6b4cda34a7d22c1a427a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 19 Jun 2013 20:35:13 -0700 Subject: BUILDFIX: size_t/u32 confusion --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0fe95ee75f..d34434f161 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -464,7 +464,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) } else { - size_t num_to_copy = llmin( mRecordingPeriods.size(), other_num_recordings); + size_t num_to_copy = llmin( mRecordingPeriods.size(), (size_t)other_num_recordings); std::vector::iterator src_it = other.mRecordingPeriods.begin() + other_index ; std::vector::iterator dest_it = mRecordingPeriods.begin() + mCurPeriod; -- cgit v1.2.3 From 5de2f0a8970244866dc8b511caa3c8626955264f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Jun 2013 10:58:44 -0700 Subject: SH-3931 FIX Interesting: Add graphs to visualize scene load metrics - potential fix for bad times --- indra/llcommon/lltracerecording.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 33002929ea..52ecb463be 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -161,6 +161,7 @@ void Recording::update() { mBuffers.write()->flush(); LLTrace::get_thread_recorder()->bringUpToDate(this); + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); mSamplingTimer.reset(); } } -- cgit v1.2.3 From 8bddaeec6647e735415f9bd72a4e1313e11fe720 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 22 Jun 2013 12:00:18 -0700 Subject: 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 --- indra/llcommon/lltracerecording.cpp | 113 +++++------------------------------- 1 file changed, 15 insertions(+), 98 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ff1589d12d..c30f204fa4 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -33,85 +33,7 @@ namespace LLTrace { - - -/////////////////////////////////////////////////////////////////////// -// RecordingBuffers -/////////////////////////////////////////////////////////////////////// - -RecordingBuffers::RecordingBuffers() -{} - -void RecordingBuffers::handOffTo(RecordingBuffers& other) -{ - other.mCounts.reset(&mCounts); - other.mSamples.reset(&mSamples); - other.mEvents.reset(&mEvents); - other.mStackTimers.reset(&mStackTimers); - other.mMemStats.reset(&mMemStats); -} - -void RecordingBuffers::makePrimary() -{ - mCounts.makePrimary(); - mSamples.makePrimary(); - mEvents.makePrimary(); - mStackTimers.makePrimary(); - mMemStats.makePrimary(); - - ThreadRecorder* thread_recorder = get_thread_recorder().get(); - AccumulatorBuffer& timer_accumulator_buffer = mStackTimers; - // update stacktimer parent pointers - for (S32 i = 0, end_i = mStackTimers.size(); i < end_i; i++) - { - TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); - if (tree_node) - { - timer_accumulator_buffer[i].mParent = tree_node->mParent; - } - } -} - -bool RecordingBuffers::isPrimary() const -{ - return mCounts.isPrimary(); -} - -void RecordingBuffers::append( const RecordingBuffers& other ) -{ - mCounts.addSamples(other.mCounts); - mSamples.addSamples(other.mSamples); - mEvents.addSamples(other.mEvents); - mMemStats.addSamples(other.mMemStats); - mStackTimers.addSamples(other.mStackTimers); -} - -void RecordingBuffers::merge( const RecordingBuffers& other) -{ - mCounts.addSamples(other.mCounts, false); - mSamples.addSamples(other.mSamples, false); - mEvents.addSamples(other.mEvents, false); - mMemStats.addSamples(other.mMemStats, false); - // for now, hold out timers from merge, need to be displayed per thread - //mStackTimers.addSamples(other.mStackTimers, false); -} - -void RecordingBuffers::reset(RecordingBuffers* other) -{ - mCounts.reset(other ? &other->mCounts : NULL); - mSamples.reset(other ? &other->mSamples : NULL); - mEvents.reset(other ? &other->mEvents : NULL); - mStackTimers.reset(other ? &other->mStackTimers : NULL); - mMemStats.reset(other ? &other->mMemStats : NULL); -} - -void RecordingBuffers::flush() -{ - LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); - - mSamples.flush(time_stamp); -} - + /////////////////////////////////////////////////////////////////////// // Recording /////////////////////////////////////////////////////////////////////// @@ -119,7 +41,7 @@ void RecordingBuffers::flush() Recording::Recording() : mElapsedSeconds(0) { - mBuffers = new RecordingBuffers(); + mBuffers = new AccumulatorBufferGroup(); } Recording::Recording( const Recording& other ) @@ -132,11 +54,10 @@ Recording& Recording::operator = (const Recording& other) // this will allow us to seamlessly start without affecting any data we've acquired from other setPlayState(PAUSED); - Recording& mutable_other = const_cast(other); - mutable_other.update(); + const_cast(other).update(); EPlayState other_play_state = other.getPlayState(); - mBuffers = mutable_other.mBuffers; + mBuffers = other.mBuffers; LLStopWatchControlsMixin::setPlayState(other_play_state); @@ -151,7 +72,7 @@ Recording::~Recording() { if (isStarted() && LLTrace::get_thread_recorder().notNull()) { - LLTrace::get_thread_recorder()->deactivate(this); + LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); } } @@ -159,9 +80,11 @@ void Recording::update() { if (isStarted()) { - mBuffers.write()->flush(); - LLTrace::get_thread_recorder()->bringUpToDate(this); mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + AccumulatorBufferGroup* buffers = mBuffers.write(); + buffers->flush(); + LLTrace::get_thread_recorder()->bringUpToDate(buffers); + mSamplingTimer.reset(); } } @@ -177,14 +100,15 @@ void Recording::handleReset() void Recording::handleStart() { mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); + LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - mBuffers.write()->flush(); - LLTrace::get_thread_recorder()->deactivate(this); + AccumulatorBufferGroup* buffers = mBuffers.write(); + buffers->flush(); + LLTrace::get_thread_recorder()->deactivate(buffers); } void Recording::handleSplitTo(Recording& other) @@ -192,19 +116,14 @@ void Recording::handleSplitTo(Recording& other) mBuffers.write()->handOffTo(*other.mBuffers.write()); } -void Recording::appendRecording( const Recording& other ) +void Recording::appendRecording( Recording& other ) { update(); + other.update(); mBuffers.write()->append(*other.mBuffers); mElapsedSeconds += other.mElapsedSeconds; } -void Recording::mergeRecording( const Recording& other) -{ - update(); - mBuffers.write()->merge(*other.mBuffers); -} - LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -711,8 +630,6 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, void ExtendableRecording::extend() { - // stop recording to get latest data - mPotentialRecording.update(); // push the data back to accepted recording mAcceptedRecording.appendRecording(mPotentialRecording); // flush data, so we can start from scratch -- cgit v1.2.3 From 808d3eff198d65e5a870abb670786935fc8356bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 27 Jun 2013 00:07:21 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console fixed some lltrace logic errors more consistent syncing of timestamps of sample values in recording stack selection of primary buffers was completely incorrect assignment of recordings got wrong play state due to implicit operator = defined in base class fixed asset stats only working up to the first send --- indra/llcommon/lltracerecording.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c30f204fa4..0938317eaa 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -59,11 +59,12 @@ Recording& Recording::operator = (const Recording& other) mBuffers = other.mBuffers; - LLStopWatchControlsMixin::setPlayState(other_play_state); - // above call will clear mElapsedSeconds as a side effect, so copy it here mElapsedSeconds = other.mElapsedSeconds; mSamplingTimer = other.mSamplingTimer; + + setPlayState(other_play_state); + return *this; } @@ -82,7 +83,6 @@ void Recording::update() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); AccumulatorBufferGroup* buffers = mBuffers.write(); - buffers->flush(); LLTrace::get_thread_recorder()->bringUpToDate(buffers); mSamplingTimer.reset(); @@ -107,7 +107,6 @@ void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); AccumulatorBufferGroup* buffers = mBuffers.write(); - buffers->flush(); LLTrace::get_thread_recorder()->deactivate(buffers); } -- cgit v1.2.3 From ffa7123bb5187e1da491a8f475d696053d9c9ee4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Jun 2013 20:45:20 -0700 Subject: SH-4299 FIX Interesting: High fps shown temporarily off scale in statistics console added ability to force uniqueness of LLCopyOnWritePointer converted more variables to units added convenience function for unit constants --- indra/llcommon/lltracerecording.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0938317eaa..f1388e7935 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -100,14 +100,15 @@ void Recording::handleReset() void Recording::handleStart() { mSamplingTimer.reset(); + mBuffers.setStayUnique(true); LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - AccumulatorBufferGroup* buffers = mBuffers.write(); - LLTrace::get_thread_recorder()->deactivate(buffers); + LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); + mBuffers.setStayUnique(false); } void Recording::handleSplitTo(Recording& other) -- cgit v1.2.3 From 11e14cd3b0f58225a96b9b7a9839a7f030fe4045 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 15 Jul 2013 11:05:57 -0700 Subject: SH-4299Interesting: High fps shown temporarily off scale in statistics console various fixes to lltrace start() on started recording no longer resets fixed various instances of unit forgetfullness in lltrace recording split now has gapless timing scene monitor now guarantees min sample time renamed a bunch of stats added names to debug thread view on windows --- indra/llcommon/lltracerecording.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f1388e7935..875c371068 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -38,10 +38,13 @@ namespace LLTrace // Recording /////////////////////////////////////////////////////////////////////// -Recording::Recording() -: mElapsedSeconds(0) +Recording::Recording(EPlayState state) +: mElapsedSeconds(0), + mInHandOff(false) + { mBuffers = new AccumulatorBufferGroup(); + setPlayState(state); } Recording::Recording( const Recording& other ) @@ -101,7 +104,8 @@ void Recording::handleStart() { mSamplingTimer.reset(); mBuffers.setStayUnique(true); - LLTrace::get_thread_recorder()->activate(mBuffers.write()); + LLTrace::get_thread_recorder()->activate(mBuffers.write(), mInHandOff); + mInHandOff = false; } void Recording::handleStop() @@ -113,6 +117,7 @@ void Recording::handleStop() void Recording::handleSplitTo(Recording& other) { + other.mInHandOff = true; mBuffers.write()->handOffTo(*other.mBuffers.write()); } @@ -485,6 +490,8 @@ void PeriodicRecording::handleStop() void PeriodicRecording::handleReset() { + getCurRecording().stop(); + if (mAutoResize) { mRecordingPeriods.clear(); @@ -500,6 +507,7 @@ void PeriodicRecording::handleReset() } } mCurPeriod = 0; + mNumPeriods = 0; getCurRecording().setPlayState(getPlayState()); } @@ -719,7 +727,6 @@ void LLStopWatchControlsMixinCommon::start() handleStart(); break; case STARTED: - handleReset(); break; default: llassert(false); -- cgit v1.2.3 From bd078122e3a87e958fb6b0ea9caeef885298d527 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 15 Jul 2013 21:00:19 -0700 Subject: SH-4299 FIX: Interesting: High fps shown temporarily off scale in statistics console timing of scene load recording extension now guaranteed > requested time step removed double add of recorded data removed spam --- indra/llcommon/lltracerecording.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 875c371068..5d43771cb2 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -367,9 +367,6 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) if (mAutoResize) { - // append first recording into our current slot - getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); - // push back recordings for everything in the middle U32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; while (other_index != other_current_recording_index) -- cgit v1.2.3 From 29930baf23fbd8cd147cd78f60d01496479ae78e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 17 Jul 2013 10:56:47 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console made unit types work with ostreams fixed timing of scene monitor recordings to better respect requested time diff --- indra/llcommon/lltracerecording.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5d43771cb2..48b5a7c3fa 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -41,7 +41,6 @@ namespace LLTrace Recording::Recording(EPlayState state) : mElapsedSeconds(0), mInHandOff(false) - { mBuffers = new AccumulatorBufferGroup(); setPlayState(state); -- cgit v1.2.3 From e40065f82c797eab41006a448c838f4f1089a2e8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 19 Jul 2013 15:03:05 -0700 Subject: BUILDFIX: #include and dependency cleanup --- indra/llcommon/lltracerecording.cpp | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 48b5a7c3fa..2150a44f12 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -95,7 +95,7 @@ void Recording::handleReset() { mBuffers.write()->reset(); - mElapsedSeconds = 0.0; + mElapsedSeconds = LLUnits::Seconds::fromValue(0.0); mSamplingTimer.reset(); } @@ -131,14 +131,14 @@ void Recording::appendRecording( Recording& other ) LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) - / (F64)LLTrace::TimeBlock::countsPerSecond(); + return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + / (F64)LLTrace::TimeBlock::countsPerSecond()); } LLUnit Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); + return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } @@ -151,16 +151,16 @@ LLUnit Recording::getPerSec(const TraceTypemStackTimers[stat.getIndex()]; - return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); + return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } LLUnit Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return (F64)(accumulator.mSelfTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()); + return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter) + / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const TraceType& stat) @@ -170,52 +170,52 @@ F32 Recording::getPerSec(const TraceType& LLUnit Recording::getMin(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.getMin(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } LLUnit Recording::getMean(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.getMean(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } LLUnit Recording::getMax(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.getMax(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } LLUnit Recording::getStandardDeviation(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } LLUnit Recording::getLastValue(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } LLUnit Recording::getMin(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); } LLUnit Recording::getMean(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); } LLUnit Recording::getMax(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); } LLUnit Recording::getStandardDeviation(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); } LLUnit Recording::getLastValue(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue(); + return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); } U32 Recording::getSum(const TraceType& stat) @@ -603,7 +603,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - LLUnit total_duration = 0.f; + LLUnit total_duration(0.f); F64 mean = 0; if (num_periods <= 0) { return mean; } -- cgit v1.2.3 From f58eb60b1e0bbdf2148255c61100cbc20d1ba1b0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Aug 2013 08:17:21 -0700 Subject: SH-4374 WIP Interesting: Statistics Object cache hit rate is always 100% --- indra/llcommon/lltracerecording.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2150a44f12..9fce6c11cc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -252,6 +252,11 @@ U32 Recording::getSampleCount( const TraceType& stat ) return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } +bool Recording::hasValue(const TraceType& stat) +{ + return mBuffers->mSamples[stat.getIndex()].hasValue(); +} + F64 Recording::getMin( const TraceType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMin(); @@ -578,7 +583,10 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + if (mRecordingPeriods[index].hasValue(stat)) + { + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } } return min_val; } @@ -592,7 +600,10 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + if (mRecordingPeriods[index].hasValue(stat)) + { + max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + } } return max_val; } @@ -611,7 +622,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f) + if (mRecordingPeriods[index].getDuration() > 0.f && mRecordingPeriods[index].hasValue(stat)) { LLUnit recording_duration = mRecordingPeriods[index].getDuration(); mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); -- cgit v1.2.3 From 8d3daa141e9ea14f533559843d77ab5c0f715421 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 16:14:19 -0700 Subject: SH-4374 FIX Interesting: Statistics Object cache hit rate is always 100% moved object cache sampling code so that it actually gets executed default values for stats are NaN instead of 0 in many cases --- indra/llcommon/lltracerecording.cpp | 42 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9fce6c11cc..a4d58d8ab1 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -287,6 +287,11 @@ U32 Recording::getSampleCount( const TraceType& stat ) return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } +bool Recording::hasValue(const TraceType& stat) +{ + return mBuffers->mEvents[stat.getIndex()].hasValue(); +} + F64 Recording::getMin( const TraceType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); @@ -531,10 +536,12 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, s for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f) + Recording& recording = mRecordingPeriods[index]; + + if (recording.hasValue(stat)) { - S32 period_sample_count = mRecordingPeriods[index].getSampleCount(stat); - mean += mRecordingPeriods[index].getMean(stat) * period_sample_count; + S32 period_sample_count = recording.getSampleCount(stat); + mean += recording.getMean(stat) * period_sample_count; total_sample_count += period_sample_count; } } @@ -555,7 +562,11 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) + { + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } } return min_val; } @@ -569,7 +580,11 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getMax(stat)); + } } return max_val; } @@ -583,9 +598,10 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + min_val = llmin(min_val, recording.getMin(stat)); } } return min_val; @@ -600,9 +616,10 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + max_val = llmax(max_val, recording.getMax(stat)); } } return max_val; @@ -622,10 +639,11 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f && mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - LLUnit recording_duration = mRecordingPeriods[index].getDuration(); - mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); + LLUnit recording_duration = recording.getDuration(); + mean += recording.getMean(stat) * recording_duration.value(); total_duration += recording_duration; } } -- cgit v1.2.3 From cc31b4ae7934010762b8aaaa7e190c74a1cd7820 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Aug 2013 20:05:16 -0700 Subject: SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture queue bounces once per second SH-4346 FIX: Interesting: some integer Statistics are displayed as floating point after crossing region boundary made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C") works, for example fixed unit tests remove llsimplestat --- indra/llcommon/lltracerecording.cpp | 150 ++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 50 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a4d58d8ab1..42d97ce314 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -242,9 +242,7 @@ F64 Recording::getSum( const TraceType& stat ) F64 Recording::getPerSec( const TraceType& stat ) { F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return (sum != 0.0) - ? (sum / mElapsedSeconds.value()) - : 0.0; + return sum / mElapsedSeconds.value(); } U32 Recording::getSampleCount( const TraceType& stat ) @@ -522,71 +520,98 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } - -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 mean = 0; - if (num_periods <= 0) { return mean; } - - S32 total_sample_count = 0; - + bool has_value = false; + F64 min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; - + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { - S32 period_sample_count = recording.getSampleCount(stat); - mean += recording.getMean(stat) * period_sample_count; - total_sample_count += period_sample_count; + min_val = llmin(min_val, recording.getMin(stat)); + has_value = true; } } - if (total_sample_count) + return has_value + ? min_val + : NaN; +} + +F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + bool has_value = false; + F64 max_val = std::numeric_limits::min(); + for (S32 i = 1; i <= num_periods; i++) { - mean = mean / total_sample_count; + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getMax(stat)); + has_value = true; + } } - return mean; + + return has_value + ? max_val + : NaN; } -F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +// calculates means using aggregates per period +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 min_val = std::numeric_limits::max(); + F64 mean = 0; + S32 valid_period_count = 0; + for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + mean += recording.getMean(stat); + valid_period_count++; } } - return min_val; + + return valid_period_count + ? mean / (F64)valid_period_count + : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) + +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 max_val = std::numeric_limits::min(); + F64 period_mean = getPeriodMean(stat, num_periods); + F64 sum_of_squares = 0; + S32 valid_period_count = 0; + for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { - max_val = llmax(max_val, recording.getMax(stat)); + F64 delta = recording.getMean(stat) - period_mean; + sum_of_squares += delta * delta; + valid_period_count++; } } - return max_val; + + return valid_period_count + ? sqrt((F64)sum_of_squares / (F64)valid_period_count) + : NaN; } F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) @@ -594,17 +619,21 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + bool has_value = false; F64 min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { min_val = llmin(min_val, recording.getMin(stat)); + has_value = true; } } - return min_val; + + return has_value + ? min_val + : NaN; } F64 PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) @@ -612,17 +641,21 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + bool has_value = false; F64 max_val = std::numeric_limits::min(); for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { max_val = llmax(max_val, recording.getMax(stat)); + has_value = true; } } - return max_val; + + return has_value + ? max_val + : NaN; } @@ -631,31 +664,48 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - LLUnit total_duration(0.f); - + S32 valid_period_count = 0; F64 mean = 0; - if (num_periods <= 0) { return mean; } for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - Recording& recording = mRecordingPeriods[index]; + Recording& recording = getPrevRecording(i); if (recording.hasValue(stat)) { - LLUnit recording_duration = recording.getDuration(); - mean += recording.getMean(stat) * recording_duration.value(); - total_duration += recording_duration; + mean += recording.getMean(stat); + valid_period_count++; } } - if (total_duration.value()) - { - mean = mean / total_duration; - } - return mean; + return valid_period_count + ? mean / F64(valid_period_count) + : NaN; } +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + F64 period_mean = getPeriodMean(stat, num_periods); + S32 valid_period_count = 0; + F64 sum_of_squares = 0; + + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + F64 delta = recording.getMean(stat) - period_mean; + sum_of_squares += delta * delta; + valid_period_count++; + } + } + + return valid_period_count + ? sqrt(sum_of_squares / (F64)valid_period_count) + : NaN; +} /////////////////////////////////////////////////////////////////////// // ExtendableRecording -- cgit v1.2.3 From 26581404e426b00cd0a07c38b5cb858d5d5faa28 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Aug 2013 11:51:49 -0700 Subject: BUILDFIX: added header for numeric_limits support on gcc added convenience types for units F32Seconds, etc. --- indra/llcommon/lltracerecording.cpp | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 42d97ce314..963f0cd174 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -95,7 +95,7 @@ void Recording::handleReset() { mBuffers.write()->reset(); - mElapsedSeconds = LLUnits::Seconds::fromValue(0.0); + mElapsedSeconds = LLUnits::F64Seconds(0.0); mSamplingTimer.reset(); } @@ -128,17 +128,17 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -LLUnit Recording::getSum(const TraceType& stat) +LLUnits::F64Seconds Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return LLUnits::F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -LLUnit Recording::getSum(const TraceType& stat) +LLUnits::F64Seconds Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); + return LLUnits::F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } @@ -147,19 +147,19 @@ U32 Recording::getSum(const TraceType& sta return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -LLUnit Recording::getPerSec(const TraceType& stat) +LLUnits::F64Seconds Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::Seconds::fromValue((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return LLUnits::F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } -LLUnit Recording::getPerSec(const TraceType& stat) +LLUnits::F64Seconds Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::Seconds::fromValue((F64)(accumulator.mSelfTimeCounter) + return LLUnits::F64Seconds((F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } @@ -168,54 +168,54 @@ F32 Recording::getPerSec(const TraceType& return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -LLUnit Recording::getMin(const TraceType& stat) +LLUnits::F64Bytes Recording::getMin(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -LLUnit Recording::getMean(const TraceType& stat) +LLUnits::F64Bytes Recording::getMean(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -LLUnit Recording::getMax(const TraceType& stat) +LLUnits::F64Bytes Recording::getMax(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -LLUnit Recording::getStandardDeviation(const TraceType& stat) +LLUnits::F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -LLUnit Recording::getLastValue(const TraceType& stat) +LLUnits::F64Bytes Recording::getLastValue(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -LLUnit Recording::getMin(const TraceType& stat) +LLUnits::F64Bytes Recording::getMin(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); } -LLUnit Recording::getMean(const TraceType& stat) +LLUnits::F64Bytes Recording::getMean(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); } -LLUnit Recording::getMax(const TraceType& stat) +LLUnits::F64Bytes Recording::getMax(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); } -LLUnit Recording::getStandardDeviation(const TraceType& stat) +LLUnits::F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); } -LLUnit Recording::getLastValue(const TraceType& stat) +LLUnits::F64Bytes Recording::getLastValue(const TraceType& stat) { - return LLUnits::Bytes::fromValue(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); + return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); } U32 Recording::getSum(const TraceType& stat) @@ -427,9 +427,9 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) getCurRecording().setPlayState(getPlayState()); } -LLUnit PeriodicRecording::getDuration() const +LLUnits::F64Seconds PeriodicRecording::getDuration() const { - LLUnit duration; + LLUnits::F64Seconds duration; size_t num_periods = mRecordingPeriods.size(); for (size_t i = 1; i <= num_periods; i++) { -- cgit v1.2.3 From 9f7bfa1c3710856cd2b0a0a8a429d6c45b0fcd09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Aug 2013 00:02:23 -0700 Subject: moved unit types out of LLUnits namespace, since they are prefixed --- indra/llcommon/lltracerecording.cpp | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 963f0cd174..bc98eebf31 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -95,7 +95,7 @@ void Recording::handleReset() { mBuffers.write()->reset(); - mElapsedSeconds = LLUnits::F64Seconds(0.0); + mElapsedSeconds = F64Seconds(0.0); mSamplingTimer.reset(); } @@ -128,17 +128,17 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -LLUnits::F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -LLUnits::F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); + return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } @@ -147,19 +147,19 @@ U32 Recording::getSum(const TraceType& sta return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -LLUnits::F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } -LLUnits::F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return LLUnits::F64Seconds((F64)(accumulator.mSelfTimeCounter) + return F64Seconds((F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } @@ -168,54 +168,54 @@ F32 Recording::getPerSec(const TraceType& return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -LLUnits::F64Bytes Recording::getMin(const TraceType& stat) +F64Bytes Recording::getMin(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -LLUnits::F64Bytes Recording::getMean(const TraceType& stat) +F64Bytes Recording::getMean(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -LLUnits::F64Bytes Recording::getMax(const TraceType& stat) +F64Bytes Recording::getMax(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -LLUnits::F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -LLUnits::F64Bytes Recording::getLastValue(const TraceType& stat) +F64Bytes Recording::getLastValue(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -LLUnits::F64Bytes Recording::getMin(const TraceType& stat) +F64Bytes Recording::getMin(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); } -LLUnits::F64Bytes Recording::getMean(const TraceType& stat) +F64Bytes Recording::getMean(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); } -LLUnits::F64Bytes Recording::getMax(const TraceType& stat) +F64Bytes Recording::getMax(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); } -LLUnits::F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); } -LLUnits::F64Bytes Recording::getLastValue(const TraceType& stat) +F64Bytes Recording::getLastValue(const TraceType& stat) { - return LLUnits::F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); } U32 Recording::getSum(const TraceType& stat) @@ -427,9 +427,9 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) getCurRecording().setPlayState(getPlayState()); } -LLUnits::F64Seconds PeriodicRecording::getDuration() const +F64Seconds PeriodicRecording::getDuration() const { - LLUnits::F64Seconds duration; + F64Seconds duration; size_t num_periods = mRecordingPeriods.size(); for (size_t i = 1; i <= num_periods; i++) { -- cgit v1.2.3 From 72f979135b3497d16c2635babf057900ddbc42fe Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 18 Sep 2013 14:20:30 -0700 Subject: merge --- indra/llcommon/lltracerecording.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index bc98eebf31..c278901bc0 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -193,29 +193,29 @@ F64Bytes Recording::getLastValue(const TraceType& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Bytes Recording::getMin(const TraceType& stat) +F64Bytes Recording::getMin(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); } -F64Bytes Recording::getMean(const TraceType& stat) +F64Bytes Recording::getMean(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); } -F64Bytes Recording::getMax(const TraceType& stat) +F64Bytes Recording::getMax(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); } -F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); } -F64Bytes Recording::getLastValue(const TraceType& stat) +F64Bytes Recording::getLastValue(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); } U32 Recording::getSum(const TraceType& stat) -- cgit v1.2.3 From 0dfc08d22a21728ec670bd75e6fd0ed60c97bf06 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 19 Sep 2013 15:21:46 -0700 Subject: BUILDFIX: more bad merge stuff also added ability for statbar to show memtrackable info --- indra/llcommon/lltracerecording.cpp | 102 ++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c278901bc0..7155cfa40a 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -168,6 +168,16 @@ F32 Recording::getPerSec(const TraceType& return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } +bool Recording::hasValue(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); +} + +bool Recording::hasValue(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue(); +} + F64Bytes Recording::getMin(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); @@ -707,6 +717,98 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + F64Bytes min_val(std::numeric_limits::max()); + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + min_val = llmin(min_val, recording.getMin(stat)); + } + + return min_val; +} + +F64Bytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, size_t num_periods) +{ + return getPeriodMin(static_cast&>(stat), num_periods); +} + +F64Bytes PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + F64Bytes max_val(0.0); + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + max_val = llmax(max_val, recording.getMax(stat)); + } + + return max_val; +} + +F64Bytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, size_t num_periods) +{ + return getPeriodMax(static_cast&>(stat), num_periods); +} + +F64Bytes PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + F64Bytes mean(0); + + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + mean += recording.getMean(stat); + } + + return mean / F64(num_periods); +} + +F64Bytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, size_t num_periods) +{ + return getPeriodMean(static_cast&>(stat), num_periods); +} + +F64Bytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + F64Bytes period_mean = getPeriodMean(stat, num_periods); + S32 valid_period_count = 0; + F64 sum_of_squares = 0; + + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + F64Bytes delta = recording.getMean(stat) - period_mean; + sum_of_squares += delta.value() * delta.value(); + valid_period_count++; + } + } + + return F64Bytes(valid_period_count + ? sqrt(sum_of_squares / (F64)valid_period_count) + : NaN); +} + +F64Bytes PeriodicRecording::getPeriodStandardDeviation(const MemStatHandle& stat, size_t num_periods) +{ + return getPeriodStandardDeviation(static_cast&>(stat), num_periods); +} + /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From e25b5a359faaf4bb51186235567fcb1fea15e440 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 23 Sep 2013 16:07:32 -0700 Subject: refactored lltrace mem tracking to store allocation and deallocation sizes at the same time and work better with threads --- indra/llcommon/lltracerecording.cpp | 57 ++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 7155cfa40a..5728997676 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -228,16 +228,65 @@ F64Bytes Recording::getLastValue(const TraceTypemMemStats[stat.getIndex()].mShadowSize.getLastValue()); } -U32 Recording::getSum(const TraceType& stat) +F64Bytes Recording::getSum(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum()); } -U32 Recording::getSum(const TraceType& stat) +F64Bytes Recording::getPerSec(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum() / mElapsedSeconds.value()); } +U32 Recording::getSampleCount(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mAllocated.getSampleCount(); +} + +F64Bytes Recording::getSum(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum()); +} + +F64Bytes Recording::getPerSec(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum() / mElapsedSeconds.value()); +} + +U32 Recording::getSampleCount(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSampleCount(); +} + +F64Bytes Recording::getSum(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum()); +} + +F64Bytes Recording::getPerSec(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum() / mElapsedSeconds.value()); +} + +U32 Recording::getSampleCount(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSampleCount(); +} + +F64Bytes Recording::getSum(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum()); +} + +F64Bytes Recording::getPerSec(const TraceType& stat) +{ + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum() / mElapsedSeconds.value()); +} + +U32 Recording::getSampleCount(const TraceType& stat) +{ + return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSampleCount(); +} F64 Recording::getSum( const TraceType& stat ) { -- cgit v1.2.3 From ab8f64a96754edaa68dd1ff97b9519eff4496aa6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 24 Sep 2013 00:05:43 -0700 Subject: converted memory tracking units to KB from B added more memory tracking to LLFolderView and kin --- indra/llcommon/lltracerecording.cpp | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5728997676..c606007d89 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -178,62 +178,62 @@ bool Recording::hasValue(const TraceType& st return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue(); } -F64Bytes Recording::getMin(const TraceType& stat) +F64Kilobytes Recording::getMin(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -F64Bytes Recording::getMean(const TraceType& stat) +F64Kilobytes Recording::getMean(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -F64Bytes Recording::getMax(const TraceType& stat) +F64Kilobytes Recording::getMax(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -F64Bytes Recording::getLastValue(const TraceType& stat) +F64Kilobytes Recording::getLastValue(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Bytes Recording::getMin(const TraceType& stat) +F64Kilobytes Recording::getMin(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); } -F64Bytes Recording::getMean(const TraceType& stat) +F64Kilobytes Recording::getMean(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); } -F64Bytes Recording::getMax(const TraceType& stat) +F64Kilobytes Recording::getMax(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); } -F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); } -F64Bytes Recording::getLastValue(const TraceType& stat) +F64Kilobytes Recording::getLastValue(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); } -F64Bytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum()); } -F64Bytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum() / mElapsedSeconds.value()); } @@ -243,12 +243,12 @@ U32 Recording::getSampleCount(const TraceTypemMemStats[stat.getIndex()].mAllocated.getSampleCount(); } -F64Bytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum()); } -F64Bytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum() / mElapsedSeconds.value()); } @@ -258,12 +258,12 @@ U32 Recording::getSampleCount(const TraceTypemMemStats[stat.getIndex()].mDeallocated.getSampleCount(); } -F64Bytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum()); } -F64Bytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum() / mElapsedSeconds.value()); } @@ -273,12 +273,12 @@ U32 Recording::getSampleCount(const TraceTypemMemStats[stat.getIndex()].mShadowAllocated.getSampleCount(); } -F64Bytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum()); } -F64Bytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum() / mElapsedSeconds.value()); } @@ -767,12 +767,12 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64Bytes min_val(std::numeric_limits::max()); + F64Kilobytes min_val(std::numeric_limits::max()); for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); @@ -782,17 +782,17 @@ F64Bytes PeriodicRecording::getPeriodMin( const TraceType& s return min_val; } -F64Bytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, size_t num_periods) +F64Kilobytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, size_t num_periods) { return getPeriodMin(static_cast&>(stat), num_periods); } -F64Bytes PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64Bytes max_val(0.0); + F64Kilobytes max_val(0.0); for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); @@ -802,17 +802,17 @@ F64Bytes PeriodicRecording::getPeriodMax(const TraceType& st return max_val; } -F64Bytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, size_t num_periods) +F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, size_t num_periods) { return getPeriodMax(static_cast&>(stat), num_periods); } -F64Bytes PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64Bytes mean(0); + F64Kilobytes mean(0); for (S32 i = 1; i <= num_periods; i++) { @@ -823,17 +823,17 @@ F64Bytes PeriodicRecording::getPeriodMean( const TraceType& return mean / F64(num_periods); } -F64Bytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, size_t num_periods) +F64Kilobytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, size_t num_periods) { return getPeriodMean(static_cast&>(stat), num_periods); } -F64Bytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64Bytes period_mean = getPeriodMean(stat, num_periods); + F64Kilobytes period_mean = getPeriodMean(stat, num_periods); S32 valid_period_count = 0; F64 sum_of_squares = 0; @@ -842,18 +842,18 @@ F64Bytes PeriodicRecording::getPeriodStandardDeviation( const TraceType&>(stat), num_periods); } -- cgit v1.2.3 From 053d97db1b283ca2548dc1f64756ddfc5166158f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 25 Sep 2013 19:12:35 -0700 Subject: better memory usage for LLTrace (tighter packing of recording arrays) removed complicated and unnecessary fast timer gapless handoff logic (it should be gapless anyway) improved MemTrackable API, better separation of shadow and footprint added memory usage stats to floater_stats.xml --- indra/llcommon/lltracerecording.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c606007d89..c16d02216d 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -131,7 +131,7 @@ void Recording::appendRecording( Recording& other ) F64Seconds Recording::getSum(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } @@ -151,7 +151,7 @@ F64Seconds Recording::getPerSec(const TraceType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } @@ -935,7 +935,7 @@ void ExtendablePeriodicRecording::handleSplitTo(ExtendablePeriodicRecording& oth PeriodicRecording& get_frame_recording() { - static LLThreadLocalPointer sRecording(new PeriodicRecording(1000, PeriodicRecording::STARTED)); + static LLThreadLocalPointer sRecording(new PeriodicRecording(200, PeriodicRecording::STARTED)); return *sRecording; } -- cgit v1.2.3 From e0a443f5a6b76fd1ab5ffaa8e7a1941d47c80f4f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Sep 2013 11:18:39 -0700 Subject: BUILDFIX: fix for mac builds also, fixed alignment of tick labels on stat bars --- indra/llcommon/lltracerecording.cpp | 112 ++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c16d02216d..ddf62845a0 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -142,7 +142,7 @@ F64Seconds Recording::getSum(const TraceType& stat) +S32 Recording::getSum(const TraceType& stat) { return mBuffers->mStackTimers[stat.getIndex()].mCalls; } @@ -238,7 +238,7 @@ F64Kilobytes Recording::getPerSec(const TraceTypemMemStats[stat.getIndex()].mAllocated.getSum() / mElapsedSeconds.value()); } -U32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const TraceType& stat) { return mBuffers->mMemStats[stat.getIndex()].mAllocated.getSampleCount(); } @@ -253,7 +253,7 @@ F64Kilobytes Recording::getPerSec(const TraceTypemMemStats[stat.getIndex()].mDeallocated.getSum() / mElapsedSeconds.value()); } -U32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const TraceType& stat) { return mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSampleCount(); } @@ -268,7 +268,7 @@ F64Kilobytes Recording::getPerSec(const TraceTypemMemStats[stat.getIndex()].mShadowAllocated.getSum() / mElapsedSeconds.value()); } -U32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const TraceType& stat) { return mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSampleCount(); } @@ -283,7 +283,7 @@ F64Kilobytes Recording::getPerSec(const TraceTypemMemStats[stat.getIndex()].mShadowDeallocated.getSum() / mElapsedSeconds.value()); } -U32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const TraceType& stat) { return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSampleCount(); } @@ -304,7 +304,7 @@ F64 Recording::getPerSec( const TraceType& stat ) return sum / mElapsedSeconds.value(); } -U32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const TraceType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } @@ -339,7 +339,7 @@ F64 Recording::getLastValue( const TraceType& stat ) return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const TraceType& stat ) { return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } @@ -374,7 +374,7 @@ F64 Recording::getLastValue( const TraceType& stat ) return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const TraceType& stat ) { return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } @@ -383,7 +383,7 @@ U32 Recording::getSampleCount( const TraceType& stat ) // PeriodicRecording /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) +PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), mCurPeriod(0), mNumPeriods(0), @@ -403,7 +403,7 @@ void PeriodicRecording::nextPeriod() mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); old_recording.splitTo(getCurRecording()); - mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + 1); + mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + 1); } void PeriodicRecording::appendRecording(Recording& recording) @@ -420,21 +420,21 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) getCurRecording().update(); other.getCurRecording().update(); - const U32 other_recording_slots = other.mRecordingPeriods.size(); - const U32 other_num_recordings = other.getNumRecordedPeriods(); - const U32 other_current_recording_index = other.mCurPeriod; - const U32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings + 1) % other_recording_slots; + const S32 other_recording_slots = other.mRecordingPeriods.size(); + const S32 other_num_recordings = other.getNumRecordedPeriods(); + const S32 other_current_recording_index = other.mCurPeriod; + const S32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings + 1) % other_recording_slots; // append first recording into our current slot getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); // from now on, add new recordings for everything after the first - U32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; + S32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; if (mAutoResize) { // push back recordings for everything in the middle - U32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; + S32 other_index = (other_oldest_recording_index + 1) % other_recording_slots; while (other_index != other_current_recording_index) { mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); @@ -452,13 +452,13 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) } else { - size_t num_to_copy = llmin( mRecordingPeriods.size(), (size_t)other_num_recordings); + S32 num_to_copy = llmin((S32)mRecordingPeriods.size(), (S32)other_num_recordings); std::vector::iterator src_it = other.mRecordingPeriods.begin() + other_index ; std::vector::iterator dest_it = mRecordingPeriods.begin() + mCurPeriod; // already consumed the first recording from other, so start counting at 1 - for(size_t i = 1; i < num_to_copy; i++) + for(S32 i = 1; i < num_to_copy; i++) { *dest_it = *src_it; @@ -477,7 +477,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) llassert(num_to_copy >= 1); // advance to last recording period copied, and make that our current period mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size(); - mNumPeriods = llmin(mRecordingPeriods.size(), mNumPeriods + num_to_copy - 1); + mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + num_to_copy - 1); } // end with fresh period, otherwise next appendPeriodicRecording() will merge the first @@ -489,10 +489,10 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) F64Seconds PeriodicRecording::getDuration() const { F64Seconds duration; - size_t num_periods = mRecordingPeriods.size(); - for (size_t i = 1; i <= num_periods; i++) + S32 num_periods = mRecordingPeriods.size(); + for (S32 i = 1; i <= num_periods; i++) { - size_t index = (mCurPeriod + num_periods - i) % num_periods; + S32 index = (mCurPeriod + num_periods - i) % num_periods; duration += mRecordingPeriods[index].getDuration(); } return duration; @@ -527,17 +527,17 @@ const Recording& PeriodicRecording::getCurRecording() const return mRecordingPeriods[mCurPeriod]; } -Recording& PeriodicRecording::getPrevRecording( U32 offset ) +Recording& PeriodicRecording::getPrevRecording( S32 offset ) { - U32 num_periods = mRecordingPeriods.size(); - offset = llclamp(offset, 0u, num_periods - 1); + S32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0, num_periods - 1); return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } -const Recording& PeriodicRecording::getPrevRecording( U32 offset ) const +const Recording& PeriodicRecording::getPrevRecording( S32 offset ) const { - U32 num_periods = mRecordingPeriods.size(); - offset = llclamp(offset, 0u, num_periods - 1); + S32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0, num_periods - 1); return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } @@ -579,9 +579,9 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } -F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); bool has_value = false; @@ -601,9 +601,9 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, si : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); bool has_value = false; @@ -624,9 +624,9 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, si } // calculates means using aggregates per period -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 mean = 0; @@ -648,9 +648,9 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, s } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 period_mean = getPeriodMean(stat, num_periods); @@ -673,9 +673,9 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); bool has_value = false; @@ -695,9 +695,9 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s : NaN; } -F64 PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); bool has_value = false; @@ -718,9 +718,9 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si } -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); S32 valid_period_count = 0; @@ -741,9 +741,9 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, : NaN; } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64 period_mean = getPeriodMean(stat, num_periods); @@ -767,9 +767,9 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64Kilobytes min_val(std::numeric_limits::max()); @@ -782,14 +782,14 @@ F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64Kilobytes max_val(0.0); @@ -802,14 +802,14 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType return max_val; } -F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, size_t num_periods) +F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_periods) { return getPeriodMax(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64Kilobytes mean(0); @@ -823,14 +823,14 @@ F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) { - size_t total_periods = mRecordingPeriods.size(); + S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); F64Kilobytes period_mean = getPeriodMean(stat, num_periods); @@ -853,7 +853,7 @@ F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType&>(stat), num_periods); } -- cgit v1.2.3 From af6b6db264aaa02e9e6a01d88233d129cf960fdf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Sep 2013 21:24:27 -0700 Subject: fixed lltrace memory tracking image memory utilization now always non-negative --- indra/llcommon/lltracerecording.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ddf62845a0..fb2293844a 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -230,62 +230,62 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSampleCount(); } F64 Recording::getSum( const TraceType& stat ) -- cgit v1.2.3 From 12f0f8cb72f789e21b01b45063dcc5f1f5292087 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 1 Oct 2013 13:46:43 -0700 Subject: changed over to manual naming of MemTrackable stats changed claimMem and disclaimMem behavior to not pass through argument added more mem tracking stats to floater_stats --- indra/llcommon/lltracerecording.cpp | 60 ------------------------------------- 1 file changed, 60 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index fb2293844a..ce4a433cca 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -173,11 +173,6 @@ bool Recording::hasValue(const TraceType& stat) return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -bool Recording::hasValue(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue(); -} - F64Kilobytes Recording::getMin(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); @@ -203,31 +198,6 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getMin(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); -} - -F64Kilobytes Recording::getMean(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); -} - -F64Kilobytes Recording::getMax(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); -} - -F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); -} - -F64Kilobytes Recording::getLastValue(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); -} - F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); @@ -258,36 +228,6 @@ S32 Recording::getSampleCount(const TraceTypemMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSampleCount(); -} - -F64Kilobytes Recording::getSum(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSampleCount(); -} - F64 Recording::getSum( const TraceType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); -- cgit v1.2.3 From 754e8752a9b9a2e75d425a10cb8a0a6f85ad4bf5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 14:30:34 -0700 Subject: added initial memory usage tracking for lltrace --- indra/llcommon/lltracerecording.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ce4a433cca..c33d9aedcc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -25,15 +25,18 @@ #include "linden_common.h" +#include "lltracerecording.h" + #include "lltrace.h" #include "llfasttimer.h" -#include "lltracerecording.h" #include "lltracethreadrecorder.h" #include "llthread.h" namespace LLTrace { - + +extern MemStatHandle gTraceMemStat; + /////////////////////////////////////////////////////////////////////// // Recording /////////////////////////////////////////////////////////////////////// @@ -42,12 +45,15 @@ Recording::Recording(EPlayState state) : mElapsedSeconds(0), mInHandOff(false) { + claim_alloc(gTraceMemStat, sizeof(*this)); mBuffers = new AccumulatorBufferGroup(); + claim_alloc(gTraceMemStat, mBuffers); setPlayState(state); } Recording::Recording( const Recording& other ) { + claim_alloc(gTraceMemStat, sizeof(*this)); *this = other; } @@ -73,6 +79,9 @@ Recording& Recording::operator = (const Recording& other) Recording::~Recording() { + disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, mBuffers); + if (isStarted() && LLTrace::get_thread_recorder().notNull()) { LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); @@ -330,6 +339,12 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); + claim_alloc(gTraceMemStat, sizeof(*this)); +} + +PeriodicRecording::~PeriodicRecording() +{ + disclaim_alloc(gTraceMemStat, sizeof(*this)); } void PeriodicRecording::nextPeriod() -- cgit v1.2.3 From f8a85003ddd4bee1ae00fc329c1c1d66d6100cbd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 19:04:51 -0700 Subject: more memory optimizations of lltrace --- indra/llcommon/lltracerecording.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c33d9aedcc..06b4351339 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -45,7 +45,7 @@ Recording::Recording(EPlayState state) : mElapsedSeconds(0), mInHandOff(false) { - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); mBuffers = new AccumulatorBufferGroup(); claim_alloc(gTraceMemStat, mBuffers); setPlayState(state); @@ -53,7 +53,7 @@ Recording::Recording(EPlayState state) Recording::Recording( const Recording& other ) { - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); *this = other; } @@ -79,7 +79,7 @@ Recording& Recording::operator = (const Recording& other) Recording::~Recording() { - disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, this); disclaim_alloc(gTraceMemStat, mBuffers); if (isStarted() && LLTrace::get_thread_recorder().notNull()) @@ -209,32 +209,32 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } F64 Recording::getSum( const TraceType& stat ) @@ -339,12 +339,12 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); } PeriodicRecording::~PeriodicRecording() { - disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, this); } void PeriodicRecording::nextPeriod() -- cgit v1.2.3 From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/llcommon/lltracerecording.cpp | 104 ++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 06b4351339..87083eee96 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -137,26 +137,26 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -S32 Recording::getSum(const TraceType& stat) +S32 Recording::getSum(const StatType& stat) { return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -164,7 +164,7 @@ F64Seconds Recording::getPerSec(const TraceType& stat) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -172,158 +172,158 @@ F64Seconds Recording::getPerSec(const TraceType& stat) +F32 Recording::getPerSec(const StatType& stat) { return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -F64Kilobytes Recording::getMin(const TraceType& stat) +F64Kilobytes Recording::getMin(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -F64Kilobytes Recording::getMean(const TraceType& stat) +F64Kilobytes Recording::getMean(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -F64Kilobytes Recording::getMax(const TraceType& stat) +F64Kilobytes Recording::getMax(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) +F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -F64Kilobytes Recording::getLastValue(const TraceType& stat) +F64Kilobytes Recording::getLastValue(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } -F64 Recording::getPerSec( const TraceType& stat ) +F64 Recording::getPerSec( const StatType& stat ) { F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mSamples[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mEvents[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } @@ -534,7 +534,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } -F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -556,7 +556,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S3 : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMax( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -579,7 +579,7 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S3 } // calculates means using aggregates per period -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -603,7 +603,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -628,7 +628,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -650,7 +650,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S : NaN; } -F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64 PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -673,7 +673,7 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S3 } -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -696,7 +696,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, : NaN; } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -722,7 +722,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -739,10 +739,10 @@ F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType&>(stat), num_periods); + return getPeriodMin(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -759,10 +759,10 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_periods) { - return getPeriodMax(static_cast&>(stat), num_periods); + return getPeriodMax(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -780,10 +780,10 @@ F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType&>(stat), num_periods); + return getPeriodMean(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -810,7 +810,7 @@ F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType&>(stat), num_periods); + return getPeriodStandardDeviation(static_cast&>(stat), num_periods); } /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 697d2e720ba75e142a4d56ae8794bab8d7698dad Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Oct 2013 20:24:42 -0700 Subject: renamed TimeBlock to BlockTimerStatHandle --- indra/llcommon/lltracerecording.cpp | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 87083eee96..2b2b55f614 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -139,192 +139,228 @@ void Recording::appendRecording( Recording& other ) F64Seconds Recording::getSum(const StatType& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / (F64)LLTrace::TimeBlock::countsPerSecond()); + / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } F64Seconds Recording::getSum(const StatType& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); + return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } S32 Recording::getSum(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mStackTimers[stat.getIndex()].mCalls; } F64Seconds Recording::getPerSec(const StatType& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F64Seconds Recording::getPerSec(const StatType& stat) { + llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) - / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const StatType& stat) { + llassert(!isStarted()); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } bool Recording::hasValue(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } F64Kilobytes Recording::getMin(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } F64Kilobytes Recording::getMean(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } F64Kilobytes Recording::getMax(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } F64Kilobytes Recording::getLastValue(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } F64Kilobytes Recording::getSum(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType& stat) { + llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } F64 Recording::getSum( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const StatType& stat ) { + llassert(!isStarted()); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const StatType& stat ) { + llassert(!isStarted()); F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } S32 Recording::getSampleCount( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType& stat) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { + llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } -- cgit v1.2.3 From 18aedf0241ba893e12140c0a3855f328d2b4eded Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Oct 2013 19:18:53 -0700 Subject: fix for assert at runtime (reading stats from recording while it was active) fix for bad values returns from getPeriodMin and getPeriodMax on count stats when no counts recorded fix for gcc compile time error (typename ftw) --- indra/llcommon/lltracerecording.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2b2b55f614..6ad6bbe356 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -137,6 +137,12 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } +bool Recording::hasValue(const StatType& stat) +{ + llassert(!isStarted()); + return mBuffers->mStackTimers[stat.getIndex()].hasValue(); +} + F64Seconds Recording::getSum(const StatType& stat) { llassert(!isStarted()); @@ -219,6 +225,12 @@ F64Kilobytes Recording::getLastValue(const StatType& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } +bool Recording::hasValue(const StatType& stat) +{ + llassert(!isStarted()); + return mBuffers->mMemStats[stat.getIndex()].mAllocations.hasValue(); +} + F64Kilobytes Recording::getSum(const StatType& stat) { llassert(!isStarted()); @@ -237,6 +249,13 @@ S32 Recording::getSampleCount(const StatType& s return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } +bool Recording::hasValue(const StatType& stat) +{ + llassert(!isStarted()); + return mBuffers->mMemStats[stat.getIndex()].mDeallocations.hasValue(); +} + + F64Kilobytes Recording::getSum(const StatType& stat) { llassert(!isStarted()); @@ -255,13 +274,19 @@ S32 Recording::getSampleCount(const StatType& return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } -F64 Recording::getSum( const StatType& stat ) +bool Recording::hasValue(const StatType& stat) +{ + llassert(!isStarted()); + return mBuffers->mCounts[stat.getIndex()].hasValue(); +} + +F64 Recording::getSum(const StatType& stat) { llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const StatType& stat ) +F64 Recording::getSum( const StatType& stat) { llassert(!isStarted()); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); -- cgit v1.2.3 From 9f097380b85a307db472726175c3515fdeb5aed5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 18 Oct 2013 09:14:53 -0700 Subject: removed asserts in order to get testable builds again added unpause() behavior and changed pause() to do nothing when already stopped --- indra/llcommon/lltracerecording.cpp | 74 +++++++++++++++---------------------- 1 file changed, 29 insertions(+), 45 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 6ad6bbe356..5ec7ce56b9 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -139,13 +139,11 @@ void Recording::appendRecording( Recording& other ) bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mStackTimers[stat.getIndex()].hasValue(); } F64Seconds Recording::getSum(const StatType& stat) { - llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); @@ -153,7 +151,6 @@ F64Seconds Recording::getSum(const StatType& stat) F64Seconds Recording::getSum(const StatType& stat) { - llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } @@ -161,13 +158,11 @@ F64Seconds Recording::getSum(const StatType S32 Recording::getSum(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mStackTimers[stat.getIndex()].mCalls; } F64Seconds Recording::getPerSec(const StatType& stat) { - llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) @@ -176,7 +171,6 @@ F64Seconds Recording::getPerSec(const StatType& stat) F64Seconds Recording::getPerSec(const StatType& stat) { - llassert(!isStarted()); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) @@ -185,207 +179,173 @@ F64Seconds Recording::getPerSec(const StatType& stat) { - llassert(!isStarted()); return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } F64Kilobytes Recording::getMin(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } F64Kilobytes Recording::getMean(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } F64Kilobytes Recording::getMax(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } F64Kilobytes Recording::getLastValue(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mAllocations.hasValue(); } F64Kilobytes Recording::getSum(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mDeallocations.hasValue(); } F64Kilobytes Recording::getSum(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - llassert(!isStarted()); return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].hasValue(); } F64 Recording::getSum(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const StatType& stat) { - llassert(!isStarted()); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const StatType& stat ) { - llassert(!isStarted()); F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } S32 Recording::getSampleCount( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } bool Recording::hasValue(const StatType& stat) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].hasValue(); } F64 Recording::getMin( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMin(); } F64 Recording::getMax( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMax(); } F64 Recording::getMean( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { - llassert(!isStarted()); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } @@ -964,9 +924,11 @@ void LLStopWatchControlsMixinCommon::start() case STOPPED: handleReset(); handleStart(); + mPlayState = STARTED; break; case PAUSED: handleStart(); + mPlayState = STARTED; break; case STARTED: break; @@ -974,7 +936,6 @@ void LLStopWatchControlsMixinCommon::start() llassert(false); break; } - mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::stop() @@ -984,15 +945,16 @@ void LLStopWatchControlsMixinCommon::stop() case STOPPED: break; case PAUSED: + mPlayState = STOPPED; break; case STARTED: handleStop(); + mPlayState = STOPPED; break; default: llassert(false); break; } - mPlayState = STOPPED; } void LLStopWatchControlsMixinCommon::pause() @@ -1000,17 +962,37 @@ void LLStopWatchControlsMixinCommon::pause() switch (mPlayState) { case STOPPED: + // stay stopped, don't go to pause break; case PAUSED: break; case STARTED: handleStop(); + mPlayState = PAUSED; + break; + default: + llassert(false); + break; + } +} + +void LLStopWatchControlsMixinCommon::unpause() +{ + switch (mPlayState) + { + case STOPPED: + // stay stopped, don't start + break; + case PAUSED: + handleStart(); + mPlayState = STARTED; + break; + case STARTED: break; default: llassert(false); break; } - mPlayState = PAUSED; } void LLStopWatchControlsMixinCommon::resume() @@ -1019,9 +1001,11 @@ void LLStopWatchControlsMixinCommon::resume() { case STOPPED: handleStart(); + mPlayState = STARTED; break; case PAUSED: handleStart(); + mPlayState = STARTED; break; case STARTED: break; @@ -1029,7 +1013,6 @@ void LLStopWatchControlsMixinCommon::resume() llassert(false); break; } - mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::restart() @@ -1039,10 +1022,12 @@ void LLStopWatchControlsMixinCommon::restart() case STOPPED: handleReset(); handleStart(); + mPlayState = STARTED; break; case PAUSED: handleReset(); handleStart(); + mPlayState = STARTED; break; case STARTED: handleReset(); @@ -1051,7 +1036,6 @@ void LLStopWatchControlsMixinCommon::restart() llassert(false); break; } - mPlayState = STARTED; } void LLStopWatchControlsMixinCommon::reset() -- cgit v1.2.3 From 1dfba44b3dc14564c99333dedb7a380a160aee44 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 14:22:21 -0700 Subject: fixed things so that trace recordings can be read from even while active --- indra/llcommon/lltracerecording.cpp | 279 +++++++++++++++++++++++++++++------- 1 file changed, 227 insertions(+), 52 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5ec7ce56b9..0fd0053240 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -32,6 +32,11 @@ #include "lltracethreadrecorder.h" #include "llthread.h" +inline F64 lerp(F64 a, F64 b, F64 u) +{ + return a + ((b - a) * u); +} + namespace LLTrace { @@ -43,7 +48,7 @@ extern MemStatHandle gTraceMemStat; Recording::Recording(EPlayState state) : mElapsedSeconds(0), - mInHandOff(false) + mActiveBuffers(NULL) { claim_alloc(gTraceMemStat, this); mBuffers = new AccumulatorBufferGroup(); @@ -88,13 +93,20 @@ Recording::~Recording() } } +// brings recording to front of recorder stack, with up to date info void Recording::update() { if (isStarted()) { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - AccumulatorBufferGroup* buffers = mBuffers.write(); - LLTrace::get_thread_recorder()->bringUpToDate(buffers); + + llassert(mActiveBuffers); + if(!mActiveBuffers->isCurrent()) + { + AccumulatorBufferGroup* buffers = mBuffers.write(); + LLTrace::get_thread_recorder()->deactivate(buffers); + mActiveBuffers = LLTrace::get_thread_recorder()->activate(buffers); + } mSamplingTimer.reset(); } @@ -112,20 +124,19 @@ void Recording::handleStart() { mSamplingTimer.reset(); mBuffers.setStayUnique(true); - LLTrace::get_thread_recorder()->activate(mBuffers.write(), mInHandOff); - mInHandOff = false; + mActiveBuffers = LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); + mActiveBuffers = NULL; mBuffers.setStayUnique(false); } void Recording::handleSplitTo(Recording& other) { - other.mInHandOff = true; mBuffers.write()->handOffTo(*other.mBuffers.write()); } @@ -139,214 +150,378 @@ void Recording::appendRecording( Recording& other ) bool Recording::hasValue(const StatType& stat) { - return mBuffers->mStackTimers[stat.getIndex()].hasValue(); + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); } F64Seconds Recording::getSum(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return F64Seconds((F64)(accumulator.mTotalTimeCounter) + (F64)(active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) + / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond(); } F64Seconds Recording::getSum(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return F64Seconds((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } S32 Recording::getSum(const StatType& stat) { - return mBuffers->mStackTimers[stat.getIndex()].mCalls; + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0); } F64Seconds Recording::getPerSec(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter + (active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F64Seconds Recording::getPerSec(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) + return F64Seconds((F64)(accumulator.mSelfTimeCounter + (active_accumulator ? active_accumulator->mSelfTimeCounter : 0)) / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const StatType& stat) { - return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return (F32)(accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0)) / mElapsedSeconds.value(); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mSize.hasValue() || (active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.hasValue() : false); } F64Kilobytes Recording::getMin(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(llmin(accumulator.mSize.getMin(), (active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.getMin() : F32_MAX))); } F64Kilobytes Recording::getMean(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->mSize.hasValue()) + { + return F64Bytes(lerp(accumulator.mSize.getMean(), active_accumulator->mSize.getMean(), active_accumulator->mSize.getSampleCount() / (accumulator.mSize.getSampleCount() + active_accumulator->mSize.getSampleCount()))); + } + else + { + return F64Bytes(accumulator.mSize.getMean()); + } } F64Kilobytes Recording::getMax(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(llmax(accumulator.mSize.getMax(), active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.getMax() : F32_MIN)); } F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = SampleAccumulator::mergeSumsOfSquares(accumulator.mSize, active_accumulator->mSize); + return F64Bytes(sqrtf(sum_of_squares / (accumulator.mSize.getSamplingTime().value() + active_accumulator->mSize.getSamplingTime().value()))); + } + else + { + return F64Bytes(accumulator.mSize.getStandardDeviation()); + } } F64Kilobytes Recording::getLastValue(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(active_accumulator ? active_accumulator->mSize.getLastValue() : accumulator.mSize.getLastValue()); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocations.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mAllocations.hasValue() || (active_accumulator ? active_accumulator->mAllocations.hasValue() : false); } F64Kilobytes Recording::getSum(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(accumulator.mAllocations.getSum() + (active_accumulator ? active_accumulator->mAllocations.getSum() : 0)); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes((accumulator.mAllocations.getSum() + (active_accumulator ? active_accumulator->mAllocations.getSum() : 0)) / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mAllocations.getSampleCount() + (active_accumulator ? active_accumulator->mAllocations.getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocations.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mDeallocations.hasValue() || (active_accumulator ? active_accumulator->mDeallocations.hasValue() : false); } F64Kilobytes Recording::getSum(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(accumulator.mDeallocations.getSum() + (active_accumulator ? active_accumulator->mDeallocations.getSum() : 0)); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes((accumulator.mDeallocations.getSum() + (active_accumulator ? active_accumulator->mDeallocations.getSum() : 0)) / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mDeallocations.getSampleCount() + (active_accumulator ? active_accumulator->mDeallocations.getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mCounts[stat.getIndex()].hasValue(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator ? active_accumulator->hasValue() : false); } F64 Recording::getSum(const StatType& stat) { - return mBuffers->mCounts[stat.getIndex()].getSum(); -} - -F64 Recording::getSum( const StatType& stat) -{ - return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.getSum() + (active_accumulator ? active_accumulator->getSum() : 0); } F64 Recording::getPerSec( const StatType& stat ) { - F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return sum / mElapsedSeconds.value(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + F64 sum = accumulator.getSum() + (active_accumulator ? active_accumulator->getSum() : 0); + return sum / mElapsedSeconds.value(); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mCounts[stat.getIndex()].getSampleCount(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator ? active_accumulator->getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mSamples[stat.getIndex()].hasValue(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); } F64 Recording::getMin( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMin(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return llmin(accumulator.getMin(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMin() : F32_MAX); } F64 Recording::getMax( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMax(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return llmax(accumulator.getMax(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMax() : F32_MIN); } F64 Recording::getMean( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMean(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + return lerp(accumulator.getMean(), active_accumulator->getMean(), active_accumulator->getSampleCount() / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getMean(); + } } F64 Recording::getStandardDeviation( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = SampleAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); + return sqrtf(sum_of_squares / (accumulator.getSamplingTime() + active_accumulator->getSamplingTime())); + } + else + { + return accumulator.getStandardDeviation(); + } } F64 Recording::getLastValue( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getLastValue(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getLastValue() : accumulator.getLastValue()); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getSampleCount(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mEvents[stat.getIndex()].hasValue(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); +} + +F64 Recording::getSum( const StatType& stat) +{ + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return (F64)(accumulator.getSum() + (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getSum() : 0)); } F64 Recording::getMin( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMin(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return llmin(accumulator.getMin(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMin() : F32_MAX); } F64 Recording::getMax( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMax(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return llmax(accumulator.getMax(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMax() : F32_MIN); } F64 Recording::getMean( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMean(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + return lerp(accumulator.getMean(), active_accumulator->getMean(), active_accumulator->getSampleCount() / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getMean(); + } } F64 Recording::getStandardDeviation( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = EventAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); + return sqrtf(sum_of_squares / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getStandardDeviation(); + } } F64 Recording::getLastValue( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getLastValue(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return active_accumulator ? active_accumulator->getLastValue() : accumulator.getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getSampleCount(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator ? active_accumulator->getSampleCount() : 0); } /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From f4283778dd581801459c262d05b9f5d107505a7c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 14:50:53 -0700 Subject: fix for crash when copying trace recording --- indra/llcommon/lltracerecording.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0fd0053240..95d26f96c0 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -57,6 +57,7 @@ Recording::Recording(EPlayState state) } Recording::Recording( const Recording& other ) +: mActiveBuffers(NULL) { claim_alloc(gTraceMemStat, this); *this = other; -- cgit v1.2.3 From ab43be5ddb50198304de1ae0e82b641c7d343449 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 23 Oct 2013 13:24:47 -0700 Subject: moved some common functionality from LLTrace::BlockTimerStatHandle to BlockTimer updates appearance utility dependency --- indra/llcommon/lltracerecording.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 95d26f96c0..dbf6771e66 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -163,7 +163,7 @@ F64Seconds Recording::getSum(const StatType& stat) const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; return F64Seconds((F64)(accumulator.mTotalTimeCounter) + (F64)(active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) - / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond(); + / (F64)LLTrace::BlockTimer::countsPerSecond(); } F64Seconds Recording::getSum(const StatType& stat) @@ -171,7 +171,7 @@ F64Seconds Recording::getSum(const StatType update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); + return F64Seconds((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0) / (F64)LLTrace::BlockTimer::countsPerSecond()); } @@ -190,7 +190,7 @@ F64Seconds Recording::getPerSec(const StatType& stat) const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; return F64Seconds((F64)(accumulator.mTotalTimeCounter + (active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) - / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds.value())); } F64Seconds Recording::getPerSec(const StatType& stat) @@ -200,7 +200,7 @@ F64Seconds Recording::getPerSec(const StatTypemStackTimers[stat.getIndex()] : NULL; return F64Seconds((F64)(accumulator.mSelfTimeCounter + (active_accumulator ? active_accumulator->mSelfTimeCounter : 0)) - / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); + / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const StatType& stat) -- cgit v1.2.3 From 155ca2f926afcbfd86b42ce6db68684ed266ef67 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 29 Oct 2013 16:23:53 -0700 Subject: fixed timer bars not appearing in fast timer view fixed "bouncing" stat values when a value ended in zeroes --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index dbf6771e66..ce09c32db5 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -171,7 +171,7 @@ F64Seconds Recording::getSum(const StatType update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0) / (F64)LLTrace::BlockTimer::countsPerSecond()); + return F64Seconds(((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0)) / (F64)LLTrace::BlockTimer::countsPerSecond()); } -- cgit v1.2.3 From e6110bb1cc88c7d353caaeb698e4764e846d521f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 15 Nov 2013 22:06:41 -0800 Subject: fix for fast timer view having runaway time slot wasn't stopping recording when merging into fast timer view stream --- indra/llcommon/lltracerecording.cpp | 48 ++++++++++++++----------------------- 1 file changed, 18 insertions(+), 30 deletions(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ce09c32db5..cd837c0867 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -532,7 +532,7 @@ S32 Recording::getSampleCount( const StatType& stat ) PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), mCurPeriod(0), - mNumPeriods(0), + mNumRecordedPeriods(0), mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); @@ -555,7 +555,7 @@ void PeriodicRecording::nextPeriod() mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); old_recording.splitTo(getCurRecording()); - mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + 1); + mNumRecordedPeriods = llmin((S32)mRecordingPeriods.size() - 1, mNumRecordedPeriods + 1); } void PeriodicRecording::appendRecording(Recording& recording) @@ -575,7 +575,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) const S32 other_recording_slots = other.mRecordingPeriods.size(); const S32 other_num_recordings = other.getNumRecordedPeriods(); const S32 other_current_recording_index = other.mCurPeriod; - const S32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings + 1) % other_recording_slots; + const S32 other_oldest_recording_index = (other_current_recording_index + other_recording_slots - other_num_recordings) % other_recording_slots; // append first recording into our current slot getCurRecording().appendRecording(other.mRecordingPeriods[other_oldest_recording_index]); @@ -600,7 +600,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) } mCurPeriod = mRecordingPeriods.size() - 1; - mNumPeriods = mRecordingPeriods.size(); + mNumRecordedPeriods = mRecordingPeriods.size() - 1; } else { @@ -629,7 +629,7 @@ void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) llassert(num_to_copy >= 1); // advance to last recording period copied, and make that our current period mCurPeriod = (mCurPeriod + num_to_copy - 1) % mRecordingPeriods.size(); - mNumPeriods = llmin((S32)mRecordingPeriods.size(), mNumPeriods + num_to_copy - 1); + mNumRecordedPeriods = llmin((S32)mRecordingPeriods.size() - 1, mNumRecordedPeriods + num_to_copy - 1); } // end with fresh period, otherwise next appendPeriodicRecording() will merge the first @@ -722,7 +722,7 @@ void PeriodicRecording::handleReset() } } mCurPeriod = 0; - mNumPeriods = 0; + mNumRecordedPeriods = 0; getCurRecording().setPlayState(getPlayState()); } @@ -733,8 +733,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); bool has_value = false; F64 min_val = std::numeric_limits::max(); @@ -755,8 +754,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 F64 PeriodicRecording::getPeriodMax( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); bool has_value = false; F64 max_val = std::numeric_limits::min(); @@ -778,8 +776,7 @@ F64 PeriodicRecording::getPeriodMax( const StatType& stat, S32 // calculates means using aggregates per period F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64 mean = 0; S32 valid_period_count = 0; @@ -802,8 +799,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, S3 F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64 period_mean = getPeriodMean(stat, num_periods); F64 sum_of_squares = 0; @@ -827,8 +823,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); bool has_value = false; F64 min_val = std::numeric_limits::max(); @@ -849,8 +844,7 @@ F64 PeriodicRecording::getPeriodMin( const StatType& stat, S3 F64 PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); bool has_value = false; F64 max_val = std::numeric_limits::min(); @@ -872,8 +866,7 @@ F64 PeriodicRecording::getPeriodMax(const StatType& stat, S32 F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); S32 valid_period_count = 0; F64 mean = 0; @@ -895,8 +888,7 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, S F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64 period_mean = getPeriodMean(stat, num_periods); S32 valid_period_count = 0; @@ -921,8 +913,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64Kilobytes min_val(std::numeric_limits::max()); for (S32 i = 1; i <= num_periods; i++) @@ -941,8 +932,7 @@ F64Kilobytes PeriodicRecording::getPeriodMin(const MemStatHandle& stat, S32 num_ F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64Kilobytes max_val(0.0); for (S32 i = 1; i <= num_periods; i++) @@ -961,8 +951,7 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_ F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64Kilobytes mean(0); @@ -982,8 +971,7 @@ F64Kilobytes PeriodicRecording::getPeriodMean(const MemStatHandle& stat, S32 num F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { - S32 total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + num_periods = llmin(num_periods, getNumRecordedPeriods()); F64Kilobytes period_mean = getPeriodMean(stat, num_periods); S32 valid_period_count = 0; -- cgit v1.2.3 From a712aab616b13a9887e00b5d37714f02d7fde6a0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 10 Jan 2014 13:56:35 -0800 Subject: added some defensive asserts in lltrace to make cases of misuse more obvious when it crashes --- indra/llcommon/lltracerecording.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index cd837c0867..d6232d771d 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -88,6 +88,9 @@ Recording::~Recording() disclaim_alloc(gTraceMemStat, this); disclaim_alloc(gTraceMemStat, mBuffers); + // allow recording destruction without thread recorder running, + // otherwise thread shutdown could crash if a recording outlives the thread recorder + // besides, recording construction and destruction is fine without a recorder...just don't attempt to start one if (isStarted() && LLTrace::get_thread_recorder().notNull()) { LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); @@ -101,7 +104,10 @@ void Recording::update() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - llassert(mActiveBuffers); + // must have + llassert(mActiveBuffers != NULL + && LLTrace::get_thread_recorder().notNull()); + if(!mActiveBuffers->isCurrent()) { AccumulatorBufferGroup* buffers = mBuffers.write(); @@ -125,12 +131,16 @@ void Recording::handleStart() { mSamplingTimer.reset(); mBuffers.setStayUnique(true); + // must have thread recorder running on this thread + llassert(LLTrace::get_thread_recorder().notNull()); mActiveBuffers = LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + // must have thread recorder running on this thread + llassert(LLTrace::get_thread_recorder().notNull()); LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); mActiveBuffers = NULL; mBuffers.setStayUnique(false); -- cgit v1.2.3 From 3040b429a3b136b87ddb0ae88ccfa3a7aa71e232 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Feb 2014 11:27:16 -0800 Subject: added LL_TRACE_ENABLED to allow disabling of lltrace --- indra/llcommon/lltracerecording.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index d6232d771d..0b10438b9f 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -100,6 +100,7 @@ Recording::~Recording() // brings recording to front of recorder stack, with up to date info void Recording::update() { +#if LL_TRACE_ENABLED if (isStarted()) { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); @@ -117,46 +118,57 @@ void Recording::update() mSamplingTimer.reset(); } +#endif } void Recording::handleReset() { +#if LL_TRACE_ENABLED mBuffers.write()->reset(); mElapsedSeconds = F64Seconds(0.0); mSamplingTimer.reset(); +#endif } void Recording::handleStart() { +#if LL_TRACE_ENABLED mSamplingTimer.reset(); mBuffers.setStayUnique(true); // must have thread recorder running on this thread llassert(LLTrace::get_thread_recorder().notNull()); mActiveBuffers = LLTrace::get_thread_recorder()->activate(mBuffers.write()); +#endif } void Recording::handleStop() { +#if LL_TRACE_ENABLED mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); // must have thread recorder running on this thread llassert(LLTrace::get_thread_recorder().notNull()); LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); mActiveBuffers = NULL; mBuffers.setStayUnique(false); +#endif } void Recording::handleSplitTo(Recording& other) { +#if LL_TRACE_ENABLED mBuffers.write()->handOffTo(*other.mBuffers.write()); +#endif } void Recording::appendRecording( Recording& other ) { +#if LL_TRACE_ENABLED update(); other.update(); mBuffers.write()->append(*other.mBuffers); mElapsedSeconds += other.mElapsedSeconds; +#endif } bool Recording::hasValue(const StatType& stat) -- cgit v1.2.3