summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-09-19 15:21:46 -0700
committerRichard Linden <none@none>2013-09-19 15:21:46 -0700
commit0dfc08d22a21728ec670bd75e6fd0ed60c97bf06 (patch)
tree96c67d4b22b00ac38104182e97d174efaee21e30
parent02dc270620bab6d3bd8035294af4be5b35894b1c (diff)
BUILDFIX: more bad merge stuff
also added ability for statbar to show memtrackable info
-rw-r--r--indra/llcommon/lltrace.h26
-rw-r--r--indra/llcommon/lltracerecording.cpp102
-rw-r--r--indra/llcommon/lltracerecording.h15
-rwxr-xr-xindra/llimage/llimage.cpp8
-rwxr-xr-xindra/llui/llstatbar.cpp195
-rwxr-xr-xindra/llui/llstatbar.h20
6 files changed, 280 insertions, 86 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 3b4370f947..f677e4349e 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -512,12 +512,17 @@ public:
return value;
}
+ const size_t& memClaim(const size_t& size)
+ {
+ claim_mem(sMemStat, size);
+ mMemFootprint += size;
+ return size;
+ }
- template<typename AMOUNT_T>
- AMOUNT_T& memClaimAmount(AMOUNT_T& size)
+ size_t& memClaim(size_t& size)
{
- MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
- mMemFootprint += (size_t)size;
+ claim_mem(sMemStat, size);
+ mMemFootprint += size;
return size;
}
@@ -536,10 +541,17 @@ public:
return value;
}
- template<typename AMOUNT_T>
- AMOUNT_T& memDisclaimAmount(AMOUNT_T& size)
+ const size_t& memDisclaim(const size_t& size)
+ {
+ disclaim_mem(sMemStat, size);
+ mMemFootprint -= size;
+ return size;
+ }
+
+ size_t& memDisclaim(size_t& size)
{
- disclaim_mem(size);
+ disclaim_mem(sMemStat, size);
+ mMemFootprint -= size;
return size;
}
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<TimeBlockAccumulator::CallCountFacet>&
return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value();
}
+bool Recording::hasValue(const TraceType<MemStatAccumulator>& stat)
+{
+ return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue();
+}
+
+bool Recording::hasValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat)
+{
+ return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue();
+}
+
F64Bytes Recording::getMin(const TraceType<MemStatAccumulator>& stat)
{
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin());
@@ -707,6 +717,98 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType<SampleAccumul
: NaN;
}
+
+F64Bytes PeriodicRecording::getPeriodMin( const TraceType<MemStatAccumulator>& 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<F64>::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<const TraceType<MemStatAccumulator>&>(stat), num_periods);
+}
+
+F64Bytes PeriodicRecording::getPeriodMax(const TraceType<MemStatAccumulator>& 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<const TraceType<MemStatAccumulator>&>(stat), num_periods);
+}
+
+F64Bytes PeriodicRecording::getPeriodMean( const TraceType<MemStatAccumulator>& 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<const TraceType<MemStatAccumulator>&>(stat), num_periods);
+}
+
+F64Bytes PeriodicRecording::getPeriodStandardDeviation( const TraceType<MemStatAccumulator>& 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<const TraceType<MemStatAccumulator>&>(stat), num_periods);
+}
+
///////////////////////////////////////////////////////////////////////
// ExtendableRecording
///////////////////////////////////////////////////////////////////////
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 9550838798..edda0f3a8c 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -175,6 +175,9 @@ namespace LLTrace
F32 getPerSec(const TraceType<TimeBlockAccumulator::CallCountFacet>& stat);
// Memory accessors
+ bool hasValue(const TraceType<MemStatAccumulator>& stat);
+ bool hasValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat);
+
F64Bytes getMin(const TraceType<MemStatAccumulator>& stat);
F64Bytes getMean(const TraceType<MemStatAccumulator>& stat);
F64Bytes getMax(const TraceType<MemStatAccumulator>& stat);
@@ -392,6 +395,9 @@ namespace LLTrace
return T(getPeriodMin(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
+ F64Bytes getPeriodMin(const TraceType<MemStatAccumulator>& stat, size_t num_periods = U32_MAX);
+ F64Bytes getPeriodMin(const MemStatHandle& stat, size_t num_periods = U32_MAX);
+
template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMinPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
@@ -453,6 +459,9 @@ namespace LLTrace
return T(getPeriodMax(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
+ F64Bytes getPeriodMax(const TraceType<MemStatAccumulator>& stat, size_t num_periods = U32_MAX);
+ F64Bytes getPeriodMax(const MemStatHandle& stat, size_t num_periods = U32_MAX);
+
template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMaxPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
@@ -519,6 +528,9 @@ namespace LLTrace
return typename RelatedTypes<T>::fractional_t(getPeriodMean(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
+ F64Bytes getPeriodMean(const TraceType<MemStatAccumulator>& stat, size_t num_periods = U32_MAX);
+ F64Bytes getPeriodMean(const MemStatHandle& stat, size_t num_periods = U32_MAX);
+
template <typename T>
typename RelatedTypes<typename T::value_t>::fractional_t getPeriodMeanPerSec(const TraceType<T>& stat, size_t num_periods = U32_MAX)
{
@@ -566,6 +578,9 @@ namespace LLTrace
return typename RelatedTypes<T>::fractional_t(getPeriodStandardDeviation(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
+ F64Bytes getPeriodStandardDeviation(const TraceType<MemStatAccumulator>& stat, size_t num_periods = U32_MAX);
+ F64Bytes getPeriodStandardDeviation(const MemStatHandle& stat, size_t num_periods = U32_MAX);
+
private:
// implementation for LLStopWatchControlsMixin
/*virtual*/ void handleStart();
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index bb4253a9f5..34e0e202b6 100755
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -159,7 +159,7 @@ void LLImageBase::sanityCheck()
void LLImageBase::deleteData()
{
FREE_MEM(sPrivatePoolp, mData) ;
- memDisclaimAmount(mDataSize) = 0;
+ memDisclaim(mDataSize) = 0;
mData = NULL;
}
@@ -202,7 +202,7 @@ U8* LLImageBase::allocateData(S32 size)
mBadBufferAllocation = true ;
}
mDataSize = size;
- memClaimAmount(mDataSize);
+ memClaim(mDataSize);
}
return mData;
@@ -224,7 +224,7 @@ U8* LLImageBase::reallocateData(S32 size)
FREE_MEM(sPrivatePoolp, mData) ;
}
mData = new_datap;
- memClaimAmount(memDisclaimAmount(mDataSize) = size);
+ memClaim(memDisclaim(mDataSize) = size);
return mData;
}
@@ -1619,7 +1619,7 @@ void LLImageBase::setDataAndSize(U8 *data, S32 size)
{
ll_assert_aligned(data, 16);
mData = data;
- memClaimAmount(memDisclaimAmount(mDataSize) = size);
+ memClaim(memDisclaim(mDataSize) = size);
}
//static
diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp
index 725a835f7f..9f96dd642d 100755
--- a/indra/llui/llstatbar.cpp
+++ b/indra/llui/llstatbar.cpp
@@ -190,8 +190,10 @@ LLStatBar::LLStatBar(const Params& p)
mAutoScaleMax(!p.bar_max.isProvided()),
mAutoScaleMin(!p.bar_min.isProvided()),
mTickValue(p.tick_spacing),
- mLastDisplayValue(0.f)
+ mLastDisplayValue(0.f),
+ mStatType(STAT_NONE)
{
+ mStat.valid = NULL;
// tick value will be automatically calculated later
if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided())
{
@@ -203,17 +205,22 @@ LLStatBar::LLStatBar(const Params& p)
BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask)
{
- if (mCountFloatp)
+ switch(mStatType)
{
- LLToolTipMgr::instance().show(LLToolTip::Params().message(mCountFloatp->getDescription()).sticky_rect(calcScreenRect()));
- }
- else if ( mEventFloatp)
- {
- LLToolTipMgr::instance().show(LLToolTip::Params().message(mEventFloatp->getDescription()).sticky_rect(calcScreenRect()));
- }
- else if (mSampleFloatp)
- {
- LLToolTipMgr::instance().show(LLToolTip::Params().message(mSampleFloatp->getDescription()).sticky_rect(calcScreenRect()));
+ case STAT_COUNT:
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.countStatp->getDescription()).sticky_rect(calcScreenRect()));
+ break;
+ case STAT_EVENT:
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.eventStatp->getDescription()).sticky_rect(calcScreenRect()));
+ break;
+ case STAT_SAMPLE:
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.sampleStatp->getDescription()).sticky_rect(calcScreenRect()));
+ break;
+ case STAT_MEM:
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.memStatp->getDescription()).sticky_rect(calcScreenRect()));
+ break;
+ default:
+ break;
}
return TRUE;
}
@@ -321,50 +328,69 @@ void LLStatBar::draw()
: mNumShortHistoryFrames;
S32 num_rapid_changes = 0;
- if (mCountFloatp)
- {
- const LLTrace::TraceType<LLTrace::CountAccumulator>& count_stat = *mCountFloatp;
-
- unit_label = std::string(count_stat.getUnitLabel()) + "/s";
- current = last_frame_recording.getPerSec(count_stat);
- min = frame_recording.getPeriodMinPerSec(count_stat, num_frames);
- max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames);
- mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames);
- display_value = mean;
- }
- else if (mEventFloatp)
- {
- const LLTrace::TraceType<LLTrace::EventAccumulator>& event_stat = *mEventFloatp;
-
- unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel;
- current = last_frame_recording.getLastValue(event_stat);
- min = frame_recording.getPeriodMin(event_stat, num_frames);
- max = frame_recording.getPeriodMax(event_stat, num_frames);
- mean = frame_recording.getPeriodMean(event_stat, num_frames);
- num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, RAPID_CHANGE_WINDOW);
- display_value = mean;
- }
- else if (mSampleFloatp)
+ switch(mStatType)
{
- const LLTrace::TraceType<LLTrace::SampleAccumulator>& sample_stat = *mSampleFloatp;
-
- unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel;
- current = last_frame_recording.getLastValue(sample_stat);
- min = frame_recording.getPeriodMin(sample_stat, num_frames);
- max = frame_recording.getPeriodMax(sample_stat, num_frames);
- mean = frame_recording.getPeriodMean(sample_stat, num_frames);
- num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW);
-
- if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC)
+ case STAT_COUNT:
{
+ const LLTrace::TraceType<LLTrace::CountAccumulator>& count_stat = *mStat.countStatp;
+
+ unit_label = std::string(count_stat.getUnitLabel()) + "/s";
+ current = last_frame_recording.getPerSec(count_stat);
+ min = frame_recording.getPeriodMinPerSec(count_stat, num_frames);
+ max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames);
+ mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames);
display_value = mean;
}
- else
+ break;
+ case STAT_EVENT:
+ {
+ const LLTrace::TraceType<LLTrace::EventAccumulator>& event_stat = *mStat.eventStatp;
+
+ unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel;
+ current = last_frame_recording.getLastValue(event_stat);
+ min = frame_recording.getPeriodMin(event_stat, num_frames);
+ max = frame_recording.getPeriodMax(event_stat, num_frames);
+ mean = frame_recording.getPeriodMean(event_stat, num_frames);
+ display_value = mean;
+ }
+ break;
+ case STAT_SAMPLE:
+ {
+ const LLTrace::TraceType<LLTrace::SampleAccumulator>& sample_stat = *mStat.sampleStatp;
+
+ unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel;
+ current = last_frame_recording.getLastValue(sample_stat);
+ min = frame_recording.getPeriodMin(sample_stat, num_frames);
+ max = frame_recording.getPeriodMax(sample_stat, num_frames);
+ mean = frame_recording.getPeriodMean(sample_stat, num_frames);
+ num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW);
+
+ if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC)
+ {
+ display_value = mean;
+ }
+ else
+ {
+ display_value = current;
+ // always display current value, don't rate limit
+ mLastDisplayValue = current;
+ }
+ }
+ break;
+ case STAT_MEM:
{
- display_value = current;
- // always display current value, don't rate limit
- mLastDisplayValue = current;
+ const LLTrace::TraceType<LLTrace::MemStatAccumulator>& mem_stat = *mStat.memStatp;
+
+ unit_label = mUnitLabel.empty() ? mem_stat.getUnitLabel() : mUnitLabel;
+ current = last_frame_recording.getLastValue(mem_stat).value();
+ min = frame_recording.getPeriodMin(mem_stat, num_frames).value();
+ max = frame_recording.getPeriodMax(mem_stat, num_frames).value();
+ mean = frame_recording.getPeriodMean(mem_stat, num_frames).value();
+ display_value = current;
}
+ break;
+ default:
+ break;
}
LLRect bar_rect;
@@ -405,8 +431,7 @@ void LLStatBar::draw()
mLastDisplayValue = display_value;
- if (mDisplayBar
- && (mCountFloatp || mEventFloatp || mSampleFloatp))
+ if (mDisplayBar && mStat.valid)
{
// Draw the tick marks.
LLGLSUIDefault gls_ui;
@@ -454,7 +479,7 @@ void LLStatBar::draw()
? (bar_rect.getWidth())
: (bar_rect.getHeight());
- if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp))
+ if (mDisplayHistory && mStat.valid)
{
const S32 num_values = frame_recording.getNumRecordedPeriods() - 1;
F32 value = 0;
@@ -468,22 +493,28 @@ void LLStatBar::draw()
F32 offset = ((F32)i / (F32)num_frames) * span;
LLTrace::Recording& recording = frame_recording.getPrevRecording(i);
- if (mCountFloatp)
- {
- value = recording.getPerSec(*mCountFloatp);
- num_samples = recording.getSampleCount(*mCountFloatp);
- }
- else if (mEventFloatp)
+ switch(mStatType)
{
- value = recording.getMean(*mEventFloatp);
- num_samples = recording.getSampleCount(*mEventFloatp);
+ case STAT_COUNT:
+ value = recording.getPerSec(*mStat.countStatp);
+ num_samples = recording.getSampleCount(*mStat.countStatp);
+ break;
+ case STAT_EVENT:
+ value = recording.getMean(*mStat.eventStatp);
+ num_samples = recording.getSampleCount(*mStat.eventStatp);
+ break;
+ case STAT_SAMPLE:
+ value = recording.getMean(*mStat.sampleStatp);
+ num_samples = recording.getSampleCount(*mStat.sampleStatp);
+ break;
+ case STAT_MEM:
+ value = recording.getMean(*mStat.memStatp).value();
+ num_samples = 1;
+ break;
+ default:
+ break;
}
- else if (mSampleFloatp)
- {
- value = recording.getMean(*mSampleFloatp);
- num_samples = recording.getSampleCount(*mSampleFloatp);
- }
-
+
if (!num_samples) continue;
F32 begin = (value - mCurMinBar) * value_scale;
@@ -540,9 +571,32 @@ void LLStatBar::draw()
void LLStatBar::setStat(const std::string& stat_name)
{
- mCountFloatp = LLTrace::TraceType<LLTrace::CountAccumulator>::getInstance(stat_name);
- mEventFloatp = LLTrace::TraceType<LLTrace::EventAccumulator>::getInstance(stat_name);
- mSampleFloatp = LLTrace::TraceType<LLTrace::SampleAccumulator>::getInstance(stat_name);
+ using namespace LLTrace;
+ const TraceType<CountAccumulator>* count_stat;
+ const TraceType<EventAccumulator>* event_stat;
+ const TraceType<SampleAccumulator>* sample_stat;
+ const TraceType<MemStatAccumulator>* mem_stat;
+
+ if ((count_stat = TraceType<CountAccumulator>::getInstance(stat_name)))
+ {
+ mStat.countStatp = count_stat;
+ mStatType = STAT_COUNT;
+ }
+ else if ((event_stat = TraceType<EventAccumulator>::getInstance(stat_name)))
+ {
+ mStat.eventStatp = event_stat;
+ mStatType = STAT_EVENT;
+ }
+ else if ((sample_stat = TraceType<SampleAccumulator>::getInstance(stat_name)))
+ {
+ mStat.sampleStatp = sample_stat;
+ mStatType = STAT_SAMPLE;
+ }
+ else if ((mem_stat = TraceType<MemStatAccumulator>::getInstance(stat_name)))
+ {
+ mStat.memStatp = mem_stat;
+ mStatType = STAT_MEM;
+ }
}
@@ -688,6 +742,3 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect )
}
}
}
-
-
-
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index f311e4a13c..5e9255b9eb 100755
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -93,9 +93,23 @@ private:
F32 mLastDisplayValue;
LLFrameTimer mLastDisplayValueTimer;
- const LLTrace::TraceType<LLTrace::CountAccumulator>* mCountFloatp;
- const LLTrace::TraceType<LLTrace::EventAccumulator>* mEventFloatp;
- const LLTrace::TraceType<LLTrace::SampleAccumulator>* mSampleFloatp;
+ enum
+ {
+ STAT_NONE,
+ STAT_COUNT,
+ STAT_EVENT,
+ STAT_SAMPLE,
+ STAT_MEM
+ } mStatType;
+
+ union
+ {
+ void* valid;
+ const LLTrace::TraceType<LLTrace::CountAccumulator>* countStatp;
+ const LLTrace::TraceType<LLTrace::EventAccumulator>* eventStatp;
+ const LLTrace::TraceType<LLTrace::SampleAccumulator>* sampleStatp;
+ const LLTrace::TraceType<LLTrace::MemStatAccumulator>* memStatp;
+ } mStat;
LLUIString mLabel;
std::string mUnitLabel;