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/lltraceaccumulators.cpp | 112 +++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 indra/llcommon/lltraceaccumulators.cpp (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp new file mode 100644 index 0000000000..5948696418 --- /dev/null +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -0,0 +1,112 @@ +/** + * @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 "lltraceaccumulators.h" +#include "lltracethreadrecorder.h" + +namespace LLTrace +{ + + +/////////////////////////////////////////////////////////////////////// +// AccumulatorBufferGroup +/////////////////////////////////////////////////////////////////////// + +AccumulatorBufferGroup::AccumulatorBufferGroup() +{} + +void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) +{ + other.mCounts.reset(&mCounts); + other.mSamples.reset(&mSamples); + other.mEvents.reset(&mEvents); + other.mStackTimers.reset(&mStackTimers); + other.mMemStats.reset(&mMemStats); +} + +void AccumulatorBufferGroup::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 AccumulatorBufferGroup::isPrimary() const +{ + return mCounts.isPrimary(); +} + +void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) +{ + mCounts.addSamples(other.mCounts); + mSamples.addSamples(other.mSamples); + mEvents.addSamples(other.mEvents); + mMemStats.addSamples(other.mMemStats); + mStackTimers.addSamples(other.mStackTimers); +} + +void AccumulatorBufferGroup::merge( const AccumulatorBufferGroup& 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 AccumulatorBufferGroup::reset(AccumulatorBufferGroup* 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 AccumulatorBufferGroup::flush() +{ + LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + + mSamples.flush(time_stamp); +} + +} -- 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/lltraceaccumulators.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 5948696418..950c1d97d1 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -69,6 +69,16 @@ void AccumulatorBufferGroup::makePrimary() } } +//static +void AccumulatorBufferGroup::clearPrimary() +{ + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); +} + bool AccumulatorBufferGroup::isPrimary() const { return mCounts.isPrimary(); @@ -102,11 +112,12 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) mMemStats.reset(other ? &other->mMemStats : NULL); } -void AccumulatorBufferGroup::flush() +void AccumulatorBufferGroup::sync() { LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); - mSamples.flush(time_stamp); + mSamples.sync(time_stamp); + mMemStats.sync(time_stamp); } } -- 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/lltraceaccumulators.cpp | 146 ++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 950c1d97d1..a632f5634c 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -86,21 +86,21 @@ bool AccumulatorBufferGroup::isPrimary() const void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) { - mCounts.addSamples(other.mCounts); - mSamples.addSamples(other.mSamples); - mEvents.addSamples(other.mEvents); - mMemStats.addSamples(other.mMemStats); - mStackTimers.addSamples(other.mStackTimers); + mCounts.addSamples(other.mCounts, SEQUENTIAL); + mSamples.addSamples(other.mSamples, SEQUENTIAL); + mEvents.addSamples(other.mEvents, SEQUENTIAL); + mMemStats.addSamples(other.mMemStats, SEQUENTIAL); + mStackTimers.addSamples(other.mStackTimers, SEQUENTIAL); } void AccumulatorBufferGroup::merge( const AccumulatorBufferGroup& other) { - mCounts.addSamples(other.mCounts, false); - mSamples.addSamples(other.mSamples, false); - mEvents.addSamples(other.mEvents, false); - mMemStats.addSamples(other.mMemStats, false); + mCounts.addSamples(other.mCounts, NON_SEQUENTIAL); + mSamples.addSamples(other.mSamples, NON_SEQUENTIAL); + mEvents.addSamples(other.mEvents, NON_SEQUENTIAL); + mMemStats.addSamples(other.mMemStats, NON_SEQUENTIAL); // for now, hold out timers from merge, need to be displayed per thread - //mStackTimers.addSamples(other.mStackTimers, false); + //mStackTimers.addSamples(other.mStackTimers, NON_SEQUENTIAL); } void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) @@ -120,4 +120,130 @@ void AccumulatorBufferGroup::sync() mMemStats.sync(time_stamp); } +void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) +{ + if (!mHasValue) + { + *this = other; + + if (append_type == NON_SEQUENTIAL) + { + // restore own last value state + mLastValue = NaN; + mHasValue = false; + } + } + else if (other.mHasValue) + { + mSum += other.mSum; + + if (other.mMin < mMin) { mMin = other.mMin; } + if (other.mMax > mMax) { mMax = other.mMax; } + + F64 epsilon = 0.0000001; + + if (other.mTotalSamplingTime > epsilon) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = mTotalSamplingTime, + n_2 = other.mTotalSamplingTime; + F64 m_1 = mMean, + m_2 = other.mMean; + F64 v_1 = mSumOfSquares / mTotalSamplingTime, + v_2 = other.mSumOfSquares / other.mTotalSamplingTime; + if (n_1 < epsilon) + { + mSumOfSquares = other.mSumOfSquares; + } + else + { + mSumOfSquares = mTotalSamplingTime + * ((((n_1 - epsilon) * v_1) + + ((n_2 - epsilon) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - epsilon)); + } + + llassert(other.mTotalSamplingTime > 0); + F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); + mNumSamples += other.mNumSamples; + mTotalSamplingTime += other.mTotalSamplingTime; + mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); + } + if (append_type == SEQUENTIAL) + { + mLastValue = other.mLastValue; + mLastSampleTimeStamp = other.mLastSampleTimeStamp; + mHasValue = true; + } + } +} + +void SampleAccumulator::reset( const SampleAccumulator* other ) +{ + mLastValue = other ? other->mLastValue : NaN; + mHasValue = other ? other->mHasValue : false; + mNumSamples = 0; + mSum = 0; + mMin = mLastValue; + mMax = mLastValue; + mMean = mLastValue; + mSumOfSquares = 0; + mLastSampleTimeStamp = LLTimer::getTotalSeconds(); + mTotalSamplingTime = 0; +} + +void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendType append_type ) +{ + if (other.mNumSamples) + { + if (!mNumSamples) + { + *this = other; + } + else + { + mSum += other.mSum; + + // NOTE: both conditions will hold first time through + if (other.mMin < mMin) { mMin = other.mMin; } + if (other.mMax > mMax) { mMax = other.mMax; } + + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = (F64)mNumSamples, + n_2 = (F64)other.mNumSamples; + F64 m_1 = mMean, + m_2 = other.mMean; + F64 v_1 = mSumOfSquares / mNumSamples, + v_2 = other.mSumOfSquares / other.mNumSamples; + mSumOfSquares = (F64)mNumSamples + * ((((n_1 - 1.f) * v_1) + + ((n_2 - 1.f) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + + F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); + mNumSamples += other.mNumSamples; + mMean = mMean * weight + other.mMean * (1.f - weight); + if (append_type == SEQUENTIAL) mLastValue = other.mLastValue; + } + } +} + +void EventAccumulator::reset( const EventAccumulator* other ) +{ + mNumSamples = 0; + mSum = NaN; + mMin = NaN; + mMax = NaN; + mMean = NaN; + mSumOfSquares = 0; + mLastValue = other ? other->mLastValue : NaN; +} + + } -- cgit v1.2.3 From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 18 Aug 2013 22:30:27 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits --- indra/llcommon/lltraceaccumulators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index a632f5634c..1fb68c8158 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -114,7 +114,7 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); mSamples.sync(time_stamp); mMemStats.sync(time_stamp); -- cgit v1.2.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llcommon/lltraceaccumulators.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 1fb68c8158..c79c102afd 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -114,10 +114,13 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); + if (isPrimary()) + { + F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); - mSamples.sync(time_stamp); - mMemStats.sync(time_stamp); + mSamples.sync(time_stamp); + mMemStats.sync(time_stamp); + } } void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) @@ -144,6 +147,7 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mTotalSamplingTime > epsilon) { + llassert(mTotalSamplingTime > 0); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm F64 n_1 = mTotalSamplingTime, @@ -166,17 +170,16 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen / (n_1 + n_2 - epsilon)); } - llassert(other.mTotalSamplingTime > 0); F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); mNumSamples += other.mNumSamples; mTotalSamplingTime += other.mTotalSamplingTime; mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); + llassert(mMean < 0 || mMean >= 0); } if (append_type == SEQUENTIAL) { mLastValue = other.mLastValue; mLastSampleTimeStamp = other.mLastSampleTimeStamp; - mHasValue = true; } } } @@ -190,6 +193,7 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mMin = mLastValue; mMax = mLastValue; mMean = mLastValue; + LL_ERRS_IF(mHasValue && !(mMean < 0) && !(mMean >= 0)) << "Invalid mean after capturing value" << LL_ENDL; mSumOfSquares = 0; mLastSampleTimeStamp = LLTimer::getTotalSeconds(); mTotalSamplingTime = 0; -- cgit v1.2.3 From 049317fc6442e8b2c2d93309a9d759aa063d2010 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 23:51:46 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms added unit tests for lltrace --- indra/llcommon/lltraceaccumulators.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index c79c102afd..42f075a7cb 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -147,7 +147,6 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mTotalSamplingTime > epsilon) { - llassert(mTotalSamplingTime > 0); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm F64 n_1 = mTotalSamplingTime, @@ -193,7 +192,7 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mMin = mLastValue; mMax = mLastValue; mMean = mLastValue; - LL_ERRS_IF(mHasValue && !(mMean < 0) && !(mMean >= 0)) << "Invalid mean after capturing value" << LL_ENDL; + llassert(!mHasValue || mMean < 0 || mMean >= 0); mSumOfSquares = 0; mLastSampleTimeStamp = LLTimer::getTotalSeconds(); mTotalSamplingTime = 0; -- cgit v1.2.3 From f0a642898dad11f6519bad735857a58e1d83422e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 29 Aug 2013 15:25:48 -0700 Subject: SH-4377 FIX: Interesting: Windows viewer crashes when SceneLoadingMonitorEnabled is enabled --- indra/llcommon/lltraceaccumulators.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 42f075a7cb..ae769350b9 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -145,7 +145,7 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen F64 epsilon = 0.0000001; - if (other.mTotalSamplingTime > epsilon) + if (other.mTotalSamplingTime > epsilon && mTotalSamplingTime > epsilon) { // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm @@ -173,7 +173,6 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen mNumSamples += other.mNumSamples; mTotalSamplingTime += other.mTotalSamplingTime; mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); - llassert(mMean < 0 || mMean >= 0); } if (append_type == SEQUENTIAL) { -- cgit v1.2.3 From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 7 Sep 2013 21:16:39 -0700 Subject: added memory usage and occlusion events to traces renamed "current" to "primary" when referring to accumulators --- indra/llcommon/lltraceaccumulators.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index ae769350b9..b234f43337 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -48,13 +48,13 @@ void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) other.mMemStats.reset(&mMemStats); } -void AccumulatorBufferGroup::makePrimary() +void AccumulatorBufferGroup::makeCurrent() { - mCounts.makePrimary(); - mSamples.makePrimary(); - mEvents.makePrimary(); - mStackTimers.makePrimary(); - mMemStats.makePrimary(); + mCounts.makeCurrent(); + mSamples.makeCurrent(); + mEvents.makeCurrent(); + mStackTimers.makeCurrent(); + mMemStats.makeCurrent(); ThreadRecorder* thread_recorder = get_thread_recorder().get(); AccumulatorBuffer& timer_accumulator_buffer = mStackTimers; @@ -70,18 +70,18 @@ void AccumulatorBufferGroup::makePrimary() } //static -void AccumulatorBufferGroup::clearPrimary() +void AccumulatorBufferGroup::resetCurrent() { - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); } -bool AccumulatorBufferGroup::isPrimary() const +bool AccumulatorBufferGroup::isCurrent() const { - return mCounts.isPrimary(); + return mCounts.isCurrent(); } void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) @@ -114,7 +114,7 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - if (isPrimary()) + if (isCurrent()) { F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); -- 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/lltraceaccumulators.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index b234f43337..58d0b5b227 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -70,13 +70,13 @@ void AccumulatorBufferGroup::makeCurrent() } //static -void AccumulatorBufferGroup::resetCurrent() +void AccumulatorBufferGroup::clearCurrent() { - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); } bool AccumulatorBufferGroup::isCurrent() const -- 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/lltraceaccumulators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 58d0b5b227..a7bd04415e 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -239,7 +239,7 @@ void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendT void EventAccumulator::reset( const EventAccumulator* other ) { mNumSamples = 0; - mSum = NaN; + mSum = 0; mMin = NaN; mMax = NaN; mMean = NaN; -- 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/lltraceaccumulators.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index a7bd04415e..f5f2e7df1c 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -125,6 +125,11 @@ void AccumulatorBufferGroup::sync() void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) { + if (append_type == NON_SEQUENTIAL) + { + return; + } + if (!mHasValue) { *this = other; -- 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/lltraceaccumulators.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index f5f2e7df1c..9f270e60b9 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -26,18 +26,36 @@ #include "linden_common.h" #include "lltraceaccumulators.h" +#include "lltrace.h" #include "lltracethreadrecorder.h" namespace LLTrace { +extern MemStatHandle gTraceMemStat; + /////////////////////////////////////////////////////////////////////// // AccumulatorBufferGroup /////////////////////////////////////////////////////////////////////// AccumulatorBufferGroup::AccumulatorBufferGroup() -{} +{ + /*claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ +} + +AccumulatorBufferGroup::~AccumulatorBufferGroup() +{ + /*disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ +} void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) { -- cgit v1.2.3 From 1821fa12838974c4eb7de2b6e9f79bf8a4cf23f1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 16:57:15 -0700 Subject: fixed memory tracking of lltrace system --- indra/llcommon/lltraceaccumulators.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 9f270e60b9..6381281a56 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -41,20 +41,29 @@ extern MemStatHandle gTraceMemStat; AccumulatorBufferGroup::AccumulatorBufferGroup() { - /*claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); +} + +AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup&) +{ + claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } AccumulatorBufferGroup::~AccumulatorBufferGroup() { - /*disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) -- 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/lltraceaccumulators.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 6381281a56..c25bb704f5 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -48,7 +48,12 @@ AccumulatorBufferGroup::AccumulatorBufferGroup() claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } -AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup&) +AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other) +: mCounts(other.mCounts), + mSamples(other.mSamples), + mEvents(other.mEvents), + mStackTimers(other.mStackTimers), + mMemStats(other.mMemStats) { claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); -- 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/lltraceaccumulators.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index c25bb704f5..7d0e63e76a 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -45,7 +45,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup() claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other) @@ -59,7 +59,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& oth claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::~AccumulatorBufferGroup() @@ -68,7 +68,7 @@ AccumulatorBufferGroup::~AccumulatorBufferGroup() disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) @@ -108,7 +108,7 @@ void AccumulatorBufferGroup::clearCurrent() AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); - AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); } bool AccumulatorBufferGroup::isCurrent() const -- 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/lltraceaccumulators.cpp | 102 +++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 44 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 7d0e63e76a..385d31edd7 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -155,6 +155,39 @@ void AccumulatorBufferGroup::sync() } } +F64 SampleAccumulator::mergeSumsOfSquares(const SampleAccumulator& a, const SampleAccumulator& b) +{ + const F64 epsilon = 0.0000001; + + if (a.getSamplingTime() > epsilon && b.getSamplingTime() > epsilon) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = a.getSamplingTime(), + n_2 = b.getSamplingTime(); + F64 m_1 = a.getMean(), + m_2 = b.getMean(); + F64 v_1 = a.getSumOfSquares() / a.getSamplingTime(), + v_2 = b.getSumOfSquares() / b.getSamplingTime(); + if (n_1 < epsilon) + { + return b.getSumOfSquares(); + } + else + { + return a.getSamplingTime() + * ((((n_1 - epsilon) * v_1) + + ((n_2 - epsilon) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - epsilon)); + } + } + + return a.getSumOfSquares(); +} + + void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) { if (append_type == NON_SEQUENTIAL) @@ -180,37 +213,8 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mMin < mMin) { mMin = other.mMin; } if (other.mMax > mMax) { mMax = other.mMax; } - F64 epsilon = 0.0000001; + mSumOfSquares = mergeSumsOfSquares(*this, other); - if (other.mTotalSamplingTime > epsilon && mTotalSamplingTime > epsilon) - { - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = mTotalSamplingTime, - n_2 = other.mTotalSamplingTime; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mTotalSamplingTime, - v_2 = other.mSumOfSquares / other.mTotalSamplingTime; - if (n_1 < epsilon) - { - mSumOfSquares = other.mSumOfSquares; - } - else - { - mSumOfSquares = mTotalSamplingTime - * ((((n_1 - epsilon) * v_1) - + ((n_2 - epsilon) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - epsilon)); - } - - F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); - mNumSamples += other.mNumSamples; - mTotalSamplingTime += other.mTotalSamplingTime; - mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); - } if (append_type == SEQUENTIAL) { mLastValue = other.mLastValue; @@ -234,6 +238,29 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mTotalSamplingTime = 0; } +F64 EventAccumulator::mergeSumsOfSquares(const EventAccumulator& a, const EventAccumulator& b) +{ + if (a.mNumSamples && b.mNumSamples) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = a.mNumSamples, + n_2 = b.mNumSamples; + F64 m_1 = a.mMean, + m_2 = b.mMean; + F64 v_1 = a.mSumOfSquares / a.mNumSamples, + v_2 = b.mSumOfSquares / b.mNumSamples; + return (F64)a.mNumSamples + * ((((n_1 - 1.f) * v_1) + + ((n_2 - 1.f) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + } + + return a.mSumOfSquares; +} + void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendType append_type ) { if (other.mNumSamples) @@ -250,20 +277,7 @@ void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendT if (other.mMin < mMin) { mMin = other.mMin; } if (other.mMax > mMax) { mMax = other.mMax; } - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = (F64)mNumSamples, - n_2 = (F64)other.mNumSamples; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mNumSamples, - v_2 = other.mSumOfSquares / other.mNumSamples; - mSumOfSquares = (F64)mNumSamples - * ((((n_1 - 1.f) * v_1) - + ((n_2 - 1.f) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); + mSumOfSquares = mergeSumsOfSquares(*this, other); F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); mNumSamples += other.mNumSamples; -- cgit v1.2.3