diff options
author | Andrew Meadows <andrew@lindenlab.com> | 2008-09-05 22:03:35 +0000 |
---|---|---|
committer | Andrew Meadows <andrew@lindenlab.com> | 2008-09-05 22:03:35 +0000 |
commit | 222bca24c12e162669c1a810c3102811f21cfbe4 (patch) | |
tree | 8eee52c0ffd4e9b03d624fc78d6547b8312a5c85 /indra/llcommon | |
parent | 1493a212629b02a4323bf0c1f5a6960bc7b5e271 (diff) |
svn merge -r95288:95907 svn+ssh://svn.lindenlab.com/svn/linden/qa/maint-server/qar-841
this is a combined mergeback of the following branches as per QAR-841:
maint-server/maint-server-1 (absorbed by maint-server-2)
maint-server/maint-server-2
maint-server/maint-server-3
havok4/havok4-8
havok4/havok4-9
yes dataserver-is-deprecated
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llcommon.cpp | 4 | ||||
-rw-r--r-- | indra/llcommon/llsdserialize.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llsdserialize_xml.cpp | 13 | ||||
-rw-r--r-- | indra/llcommon/llstat.cpp | 159 | ||||
-rw-r--r-- | indra/llcommon/llstat.h | 37 | ||||
-rw-r--r-- | indra/llcommon/llstl.h | 5 | ||||
-rw-r--r-- | indra/llcommon/llthread.cpp | 4 | ||||
-rw-r--r-- | indra/llcommon/llthread.h | 4 |
8 files changed, 127 insertions, 101 deletions
diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 0069d03de0..268b12b02a 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -46,7 +46,7 @@ void LLCommon::initClass() sAprInitialized = TRUE; } LLTimer::initClass(); - LLThreadSafeRefCount::initClass(); + LLThreadSafeRefCount::initThreadSafeRefCount(); // LLWorkerThread::initClass(); // LLFrameCallbackManager::initClass(); } @@ -56,7 +56,7 @@ void LLCommon::cleanupClass() { // LLFrameCallbackManager::cleanupClass(); // LLWorkerThread::cleanupClass(); - LLThreadSafeRefCount::cleanupClass(); + LLThreadSafeRefCount::cleanupThreadSafeRefCount(); LLTimer::cleanupClass(); if (sAprInitialized) { diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index e4ad00da6d..d496230dd8 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -324,7 +324,7 @@ S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes) S32 LLSDParser::parseLines(std::istream& istr, LLSD& data) { mCheckLimits = false; - mParseLines = false; // was true, Emergency fix DEV-17785 parsing newline failure + mParseLines = true; return doParse(istr, data); } diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index 51a2e5ec40..edcc244f58 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -461,11 +461,11 @@ S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data) input.clear(); } - // Don't parse the NULL at the end which might be added if \n was absorbed by getline() + // Re-insert with the \n that was absorbed by getline() char * text = (char *) buffer; if ( text[num_read - 1] == 0) { - num_read--; + text[num_read - 1] = '\n'; } } @@ -808,12 +808,11 @@ void LLSDXMLParser::parsePart(const char *buf, int len) // virtual S32 LLSDXMLParser::doParse(std::istream& input, LLSD& data) const { -// Remove code - emergency fix DEV-17785 parsing newline failure -// if (mParseLines) -// { + if (mParseLines) + { // Use line-based reading (faster code) -// return impl.parseLines(input, data); -// } + return impl.parseLines(input, data); + } return impl.parse(input, data); } diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 21b723de71..80492d2e31 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -34,47 +34,9 @@ #include "llframetimer.h" #include "timing.h" -class LLStatAccum::impl -{ -public: - static const TimeScale IMPL_NUM_SCALES = (TimeScale)(SCALE_TWO_MINUTE + 1); - static U64 sScaleTimes[IMPL_NUM_SCALES]; - - BOOL mUseFrameTimer; - - BOOL mRunning; - U64 mLastTime; - - struct Bucket - { - F64 accum; - U64 endTime; - - BOOL lastValid; - F64 lastAccum; - }; - - Bucket mBuckets[IMPL_NUM_SCALES]; - - BOOL mLastSampleValid; - F64 mLastSampleValue; - - - impl(bool useFrameTimer); - - void reset(U64 when); - - void sum(F64 value); - void sum(F64 value, U64 when); - - F32 meanValue(TimeScale scale) const; - - U64 getCurrentUsecs() const; - // Get current microseconds based on timer type -}; -U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] = +U64 LLStatAccum::sScaleTimes[IMPL_NUM_SCALES] = { USEC_PER_SEC / 10, // 100 millisec USEC_PER_SEC * 1, // seconds @@ -89,14 +51,22 @@ U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] = }; -LLStatAccum::impl::impl(bool useFrameTimer) + +LLStatAccum::LLStatAccum(bool useFrameTimer) + : mUseFrameTimer(useFrameTimer), + mRunning(FALSE), + mLastSampleValue(0.0), + mLastSampleValid(FALSE) +{ +} + +LLStatAccum::~LLStatAccum() { - mUseFrameTimer = useFrameTimer; - mRunning = FALSE; - mLastSampleValid = FALSE; } -void LLStatAccum::impl::reset(U64 when) + + +void LLStatAccum::reset(U64 when) { mRunning = TRUE; mLastTime = when; @@ -109,12 +79,12 @@ void LLStatAccum::impl::reset(U64 when) } } -void LLStatAccum::impl::sum(F64 value) +void LLStatAccum::sum(F64 value) { sum(value, getCurrentUsecs()); } -void LLStatAccum::impl::sum(F64 value, U64 when) +void LLStatAccum::sum(F64 value, U64 when) { if (!mRunning) { @@ -131,6 +101,9 @@ void LLStatAccum::impl::sum(F64 value, U64 when) return; } + // how long is this value for + U64 timeSpan = when - mLastTime; + for (int i = 0; i < IMPL_NUM_SCALES; ++i) { Bucket& bucket = mBuckets[i]; @@ -143,8 +116,6 @@ void LLStatAccum::impl::sum(F64 value, U64 when) { U64 timeScale = sScaleTimes[i]; - U64 timeSpan = when - mLastTime; - // how long is this value for U64 timeLeft = when - bucket.endTime; // how much time is left after filling this bucket @@ -173,7 +144,7 @@ void LLStatAccum::impl::sum(F64 value, U64 when) } -F32 LLStatAccum::impl::meanValue(TimeScale scale) const +F32 LLStatAccum::meanValue(TimeScale scale) const { if (!mRunning) { @@ -209,7 +180,7 @@ F32 LLStatAccum::impl::meanValue(TimeScale scale) const } -U64 LLStatAccum::impl::getCurrentUsecs() const +U64 LLStatAccum::getCurrentUsecs() const { if (mUseFrameTimer) { @@ -222,24 +193,43 @@ U64 LLStatAccum::impl::getCurrentUsecs() const } +// ------------------------------------------------------------------------ - - -LLStatAccum::LLStatAccum(bool useFrameTimer) - : m(* new impl(useFrameTimer)) +LLStatRate::LLStatRate(bool use_frame_timer) + : LLStatAccum(use_frame_timer) { } -LLStatAccum::~LLStatAccum() +void LLStatRate::count(U32 value) { - delete &m; + sum((F64)value * sScaleTimes[SCALE_SECOND]); } -F32 LLStatAccum::meanValue(TimeScale scale) const -{ - return m.meanValue(scale); -} +void LLStatRate::mark() + { + // Effectively the same as count(1), but sets mLastSampleValue + U64 when = getCurrentUsecs(); + + if ( mRunning + && (when > mLastTime) ) + { // Set mLastSampleValue to the time from the last mark() + F64 duration = ((F64)(when - mLastTime)) / sScaleTimes[SCALE_SECOND]; + if ( duration > 0.0 ) + { + mLastSampleValue = 1.0 / duration; + } + else + { + mLastSampleValue = 0.0; + } + } + + sum( (F64) sScaleTimes[SCALE_SECOND], when); + } + + +// ------------------------------------------------------------------------ LLStatMeasure::LLStatMeasure(bool use_frame_timer) @@ -249,53 +239,58 @@ LLStatMeasure::LLStatMeasure(bool use_frame_timer) void LLStatMeasure::sample(F64 value) { - U64 when = m.getCurrentUsecs(); + U64 when = getCurrentUsecs(); - if (m.mLastSampleValid) + if (mLastSampleValid) { - F64 avgValue = (value + m.mLastSampleValue) / 2.0; - F64 interval = (F64)(when - m.mLastTime); + F64 avgValue = (value + mLastSampleValue) / 2.0; + F64 interval = (F64)(when - mLastTime); - m.sum(avgValue * interval, when); + sum(avgValue * interval, when); } else { - m.reset(when); + reset(when); } - m.mLastSampleValid = TRUE; - m.mLastSampleValue = value; -} - - -LLStatRate::LLStatRate(bool use_frame_timer) - : LLStatAccum(use_frame_timer) -{ + mLastSampleValid = TRUE; + mLastSampleValue = value; } -void LLStatRate::count(U32 value) -{ - m.sum((F64)value * impl::sScaleTimes[SCALE_SECOND]); -} +// ------------------------------------------------------------------------ LLStatTime::LLStatTime(bool use_frame_timer) - : LLStatAccum(use_frame_timer) + : LLStatAccum(use_frame_timer), + mFrameNumber(0), + mTotalTimeInFrame(0) { + mFrameNumber = LLFrameTimer::getFrameCount(); } void LLStatTime::start() { - m.sum(0.0); + // Reset frame accumluation if the frame number has changed + U32 frame_number = LLFrameTimer::getFrameCount(); + if ( frame_number != mFrameNumber) + { + mFrameNumber = frame_number; + mTotalTimeInFrame = 0; + } + + sum(0.0); } void LLStatTime::stop() { - U64 endTime = m.getCurrentUsecs(); - m.sum((F64)(endTime - m.mLastTime), endTime); + U64 end_time = getCurrentUsecs(); + U64 duration = end_time - mLastTime; + sum(F64(duration), end_time); + mTotalTimeInFrame += duration; } +// ------------------------------------------------------------------------ LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index 5fa46fca75..d4dcb3a961 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -67,6 +67,9 @@ public: NUM_SCALES }; + static const TimeScale IMPL_NUM_SCALES = (TimeScale)(SCALE_TWO_MINUTE + 1); + static U64 sScaleTimes[IMPL_NUM_SCALES]; + F32 meanValue(TimeScale scale) const; // see the subclasses for the specific meaning of value @@ -74,9 +77,32 @@ public: F32 meanValueOverLastSecond() const { return meanValue(SCALE_SECOND); } F32 meanValueOverLastMinute() const { return meanValue(SCALE_MINUTE); } -protected: - class impl; - impl& m; + void reset(U64 when); + + void sum(F64 value); + void sum(F64 value, U64 when); + + U64 getCurrentUsecs() const; + // Get current microseconds based on timer type + + BOOL mUseFrameTimer; + + BOOL mRunning; + U64 mLastTime; + + struct Bucket + { + F64 accum; + U64 endTime; + + BOOL lastValid; + F64 lastAccum; + }; + + Bucket mBuckets[IMPL_NUM_SCALES]; + + BOOL mLastSampleValid; + F64 mLastSampleValue; }; class LLStatMeasure : public LLStatAccum @@ -105,7 +131,7 @@ public: void count(U32); // used to note that n items have occured - void mark() { count(1); } + void mark(); // used for counting the rate thorugh a point in the code }; @@ -119,6 +145,9 @@ class LLStatTime : public LLStatAccum public: LLStatTime(bool use_frame_timer = false); + U32 mFrameNumber; // Current frame number + U64 mTotalTimeInFrame; // Total time (microseconds) accumulated during the last frame + private: void start(); void stop(); diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index 99fc83274b..7b7e73470e 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -79,6 +79,9 @@ struct compare_pointer_contents // The general form is: // // std::for_each(cont.begin(), cont.end(), DeletePointer()); +// somemap.clear(); +// +// Don't forget to clear()! struct DeletePointer { @@ -95,7 +98,7 @@ struct DeletePointerArray } }; -// DeletePointer is a simple helper for deleting all pointers in a map. +// DeletePairedPointer is a simple helper for deleting all pointers in a map. // The general form is: // // std::for_each(somemap.begin(), somemap.end(), DeletePairedPointer()); diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index dc0a7a83e4..cc58552099 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -359,7 +359,7 @@ void LLCondition::broadcast() LLMutex* LLThreadSafeRefCount::sMutex = 0; //static -void LLThreadSafeRefCount::initClass() +void LLThreadSafeRefCount::initThreadSafeRefCount() { if (!sMutex) { @@ -368,7 +368,7 @@ void LLThreadSafeRefCount::initClass() } //static -void LLThreadSafeRefCount::cleanupClass() +void LLThreadSafeRefCount::cleanupThreadSafeRefCount() { delete sMutex; sMutex = NULL; diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 7864d93395..a6b2c0be7d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -191,8 +191,8 @@ void LLThread::unlockData() class LLThreadSafeRefCount { public: - static void initClass(); // creates sMutex - static void cleanupClass(); // destroys sMutex + static void initThreadSafeRefCount(); // creates sMutex + static void cleanupThreadSafeRefCount(); // destroys sMutex private: static LLMutex* sMutex; |