diff options
author | Richard Linden <none@none> | 2013-10-17 19:18:53 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-10-17 19:18:53 -0700 |
commit | 18aedf0241ba893e12140c0a3855f328d2b4eded (patch) | |
tree | 11d95ba4f7578d52e8ab69b35b181f956f4a8590 | |
parent | ec178690240a56ffa43b8f37c6b581c9008d3d7d (diff) |
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)
-rwxr-xr-x | indra/llcommon/llinstancetracker.h | 2 | ||||
-rw-r--r-- | indra/llcommon/lltraceaccumulators.h | 15 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.cpp | 29 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.h | 35 | ||||
-rwxr-xr-x | indra/newview/llviewerstats.cpp | 8 |
5 files changed, 76 insertions, 13 deletions
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 1385475444..3fdb84cfd7 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -215,7 +215,7 @@ private: { mInstanceKey = key; InstanceMap& map = getMap_(); - InstanceMap::iterator insertion_point_it = map.lower_bound(key); + typename InstanceMap::iterator insertion_point_it = map.lower_bound(key); if (ALLOW_KEY_COLLISIONS == InstanceTrackerDisallowKeyCollisions && insertion_point_it != map.end() && insertion_point_it->first == key) diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index c30cc9a107..2971907849 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -226,6 +226,7 @@ namespace LLTrace { public: typedef F64 value_t; + static F64 getDefaultValue() { return NaN; } EventAccumulator() : mSum(0), @@ -293,6 +294,7 @@ namespace LLTrace { public: typedef F64 value_t; + static F64 getDefaultValue() { return NaN; } SampleAccumulator() : mSum(0), @@ -385,6 +387,7 @@ namespace LLTrace { public: typedef F64 value_t; + static F64 getDefaultValue() { return 0; } CountAccumulator() : mSum(0), @@ -415,6 +418,8 @@ namespace LLTrace S32 getSampleCount() const { return mNumSamples; } + bool hasValue() const { return true; } + private: F64 mSum; @@ -425,6 +430,8 @@ namespace LLTrace { public: typedef F64Seconds value_t; + static F64Seconds getDefaultValue() { return F64Seconds(0); } + typedef TimeBlockAccumulator self_t; // fake classes that allows us to view different facets of underlying statistic @@ -453,6 +460,7 @@ namespace LLTrace void addSamples(const self_t& other, EBufferAppendType append_type); void reset(const self_t* other); void sync(F64SecondsImplicit) {} + bool hasValue() const { return true; } // // members @@ -493,17 +501,22 @@ namespace LLTrace struct MemAccumulator { + typedef F64Bytes value_t; + static F64Bytes getDefaultValue() { return F64Bytes(0); } + typedef MemAccumulator self_t; // fake classes that allows us to view different facets of underlying statistic struct AllocationFacet { typedef F64Bytes value_t; + static F64Bytes getDefaultValue() { return F64Bytes(0); } }; struct DeallocationFacet { typedef F64Bytes value_t; + static F64Bytes getDefaultValue() { return F64Bytes(0); } }; void addSamples(const MemAccumulator& other, EBufferAppendType append_type) @@ -536,6 +549,8 @@ namespace LLTrace mSize.sync(time_stamp); } + bool hasValue() const { return mSize.hasValue(); } + SampleAccumulator mSize; EventAccumulator mAllocations; CountAccumulator mDeallocations; 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<TimeBlockAccumulator>& stat) +{ + llassert(!isStarted()); + return mBuffers->mStackTimers[stat.getIndex()].hasValue(); +} + F64Seconds Recording::getSum(const StatType<TimeBlockAccumulator>& stat) { llassert(!isStarted()); @@ -219,6 +225,12 @@ F64Kilobytes Recording::getLastValue(const StatType<MemAccumulator>& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } +bool Recording::hasValue(const StatType<MemAccumulator::AllocationFacet>& stat) +{ + llassert(!isStarted()); + return mBuffers->mMemStats[stat.getIndex()].mAllocations.hasValue(); +} + F64Kilobytes Recording::getSum(const StatType<MemAccumulator::AllocationFacet>& stat) { llassert(!isStarted()); @@ -237,6 +249,13 @@ S32 Recording::getSampleCount(const StatType<MemAccumulator::AllocationFacet>& s return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } +bool Recording::hasValue(const StatType<MemAccumulator::DeallocationFacet>& stat) +{ + llassert(!isStarted()); + return mBuffers->mMemStats[stat.getIndex()].mDeallocations.hasValue(); +} + + F64Kilobytes Recording::getSum(const StatType<MemAccumulator::DeallocationFacet>& stat) { llassert(!isStarted()); @@ -255,13 +274,19 @@ S32 Recording::getSampleCount(const StatType<MemAccumulator::DeallocationFacet>& return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } -F64 Recording::getSum( const StatType<CountAccumulator>& stat ) +bool Recording::hasValue(const StatType<CountAccumulator>& stat) +{ + llassert(!isStarted()); + return mBuffers->mCounts[stat.getIndex()].hasValue(); +} + +F64 Recording::getSum(const StatType<CountAccumulator>& stat) { llassert(!isStarted()); return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const StatType<EventAccumulator>& stat ) +F64 Recording::getSum( const StatType<EventAccumulator>& stat) { llassert(!isStarted()); return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 810f796666..4b7a5ef0da 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -168,6 +168,7 @@ namespace LLTrace void makeUnique() { mBuffers.makeUnique(); } // Timer accessors + bool hasValue(const StatType<TimeBlockAccumulator>& stat); F64Seconds getSum(const StatType<TimeBlockAccumulator>& stat); F64Seconds getSum(const StatType<TimeBlockAccumulator::SelfTimeFacet>& stat); S32 getSum(const StatType<TimeBlockAccumulator::CallCountFacet>& stat); @@ -178,22 +179,24 @@ namespace LLTrace // Memory accessors bool hasValue(const StatType<MemAccumulator>& stat); - F64Kilobytes getMin(const StatType<MemAccumulator>& stat); F64Kilobytes getMean(const StatType<MemAccumulator>& stat); F64Kilobytes getMax(const StatType<MemAccumulator>& stat); F64Kilobytes getStandardDeviation(const StatType<MemAccumulator>& stat); F64Kilobytes getLastValue(const StatType<MemAccumulator>& stat); + bool hasValue(const StatType<MemAccumulator::AllocationFacet>& stat); F64Kilobytes getSum(const StatType<MemAccumulator::AllocationFacet>& stat); F64Kilobytes getPerSec(const StatType<MemAccumulator::AllocationFacet>& stat); S32 getSampleCount(const StatType<MemAccumulator::AllocationFacet>& stat); + bool hasValue(const StatType<MemAccumulator::DeallocationFacet>& stat); F64Kilobytes getSum(const StatType<MemAccumulator::DeallocationFacet>& stat); F64Kilobytes getPerSec(const StatType<MemAccumulator::DeallocationFacet>& stat); S32 getSampleCount(const StatType<MemAccumulator::DeallocationFacet>& stat); // CountStatHandle accessors + bool hasValue(const StatType<CountAccumulator>& stat); F64 getSum(const StatType<CountAccumulator>& stat); template <typename T> typename RelatedTypes<T>::sum_t getSum(const CountStatHandle<T>& stat) @@ -367,13 +370,21 @@ namespace LLTrace S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - typename T::value_t min_val = std::numeric_limits<typename T::value_t>::max(); + bool has_value = false; + T::value_t min_val(std::numeric_limits<T::value_t>::max()); for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); - min_val = llmin(min_val, recording.getSum(stat)); + if (recording.hasValue(stat)) + { + min_val = llmin(min_val, recording.getSum(stat)); + has_value = true; + } } - return min_val; + + return has_value + ? min_val + : T::getDefaultValue(); } template<typename T> @@ -405,7 +416,7 @@ namespace LLTrace S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - typename RelatedTypes<typename T::value_t>::fractional_t min_val = std::numeric_limits<F64>::max(); + typename RelatedTypes<typename T::value_t>::fractional_t min_val(std::numeric_limits<F64>::max()); for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); @@ -431,13 +442,21 @@ namespace LLTrace S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - typename T::value_t max_val = std::numeric_limits<typename T::value_t>::min(); + bool has_value = false; + T::value_t max_val(std::numeric_limits<T::value_t>::min()); for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); - max_val = llmax(max_val, recording.getSum(stat)); + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getSum(stat)); + has_value = true; + } } - return max_val; + + return has_value + ? max_val + : T::getDefaultValue(); } template<typename T> diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index b5aa052a90..d5ae2d1030 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -208,7 +208,7 @@ LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > OBJECT_CACHE_HIT_RATE(" LLViewerStats::LLViewerStats() : mLastTimeDiff(0.0) { - mRecording.start(); + getRecording().start(); } LLViewerStats::~LLViewerStats() @@ -216,7 +216,7 @@ LLViewerStats::~LLViewerStats() void LLViewerStats::resetStats() { - LLViewerStats::instance().mRecording.reset(); + getRecording().reset(); } void LLViewerStats::updateFrameStats(const F64Seconds time_diff) @@ -457,6 +457,8 @@ void send_stats() return; } + LLViewerStats::instance().getRecording().pause(); + body["session_id"] = gAgentSessionID; LLSD &agent = body["agent"]; @@ -616,6 +618,8 @@ void send_stats() LLViewerStats::getInstance()->addToMessage(body); LLHTTPClient::post(url, body, new ViewerStatsResponder()); + + LLViewerStats::instance().getRecording().resume(); } LLFrameTimer& LLViewerStats::PhaseMap::getPhaseTimer(const std::string& phase_name) |