From 05a3203d8274a0a0999faad128f629614b8d62c5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 26 Sep 2012 17:04:57 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages fixed various issues related to unit tests and LLThreadLocalPtr initialization and teardown --- indra/llimage/tests/llimageworker_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llimage/tests') diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index e255d65b43..be7aae4eb7 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -114,11 +114,13 @@ namespace tut // Constructor and destructor of the test wrapper imagedecodethread_test() { + LLTrace::init(); mThread = NULL; } ~imagedecodethread_test() { delete mThread; + LLTrace::cleanup(); } }; @@ -136,6 +138,8 @@ namespace tut imagerequest_test() { done = false; + LLTrace::init(); + mRequest = new LLImageDecodeThread::ImageRequest(0, 0, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, new responder_test(&done)); @@ -145,6 +149,7 @@ namespace tut // We should delete the object *but*, because its destructor is protected, that cannot be // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine... //delete mRequest; + LLTrace::cleanup(); } }; -- cgit v1.3 From 38354e19063478c8cda0408547ad05023b457041 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Sep 2012 10:45:14 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages created separate constructor for static allocation of sampler buffer fixed start/stop/resume semantics of samplers and added sampler time interval tracking --- indra/llcommon/llcommon.cpp | 1 + indra/llcommon/llqueuedthread.cpp | 1 + indra/llcommon/llthread.cpp | 14 +++- indra/llcommon/llthread.h | 10 ++- indra/llcommon/lltrace.cpp | 117 ++++++++++++++++++++++++----- indra/llcommon/lltrace.h | 108 ++++++++++++-------------- indra/llimage/tests/llimageworker_test.cpp | 2 + indra/newview/llappviewer.cpp | 2 +- 8 files changed, 170 insertions(+), 85 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index c149a1fe5c..c720df7555 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -29,6 +29,7 @@ #include "llmemory.h" #include "llthread.h" +#include "lltrace.h" //static BOOL LLCommon::sAprInitialized = FALSE; diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index a741d342d3..0a35474b7f 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -28,6 +28,7 @@ #include "llstl.h" #include "lltimer.h" // ms_sleep() +#include "lltrace.h" //============================================================================ diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 2ff524d9ba..7384842627 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -32,6 +32,7 @@ #include "llmutex.h" #include "lltimer.h" +#include "lltrace.h" #if LL_LINUX || LL_SOLARIS #include @@ -85,7 +86,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - sTraceData = new LLTrace::SlaveThreadTrace(); + setTraceData(new LLTrace::SlaveThreadTrace()); #if !LL_DARWIN sThreadIndex = threadp->mID; @@ -100,6 +101,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap threadp->mStatus = STOPPED; delete sTraceData.get(); + sTraceData = NULL; return NULL; } @@ -311,3 +313,13 @@ void LLThread::wakeLocked() mRunCondition->signal(); } } + +LLTrace::ThreadTrace* LLThread::getTraceData() +{ + return sTraceData.get(); +} + +void LLThread::setTraceData( LLTrace::ThreadTrace* data ) +{ + sTraceData = data; +} diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 5cd287ec39..334ea2f0da 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -30,8 +30,12 @@ #include "llapp.h" #include "llapr.h" #include "apr_thread_cond.h" -#include "lltrace.h" +#include "llmutex.h" +namespace LLTrace +{ + class ThreadTrace; +} class LL_COMMON_API LLThread { private: @@ -87,8 +91,8 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); } - static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;} + static LLTrace::ThreadTrace* getTraceData(); + static void setTraceData(LLTrace::ThreadTrace* data); private: BOOL mPaused; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 24a2b33a5f..2da4363b1d 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -55,40 +55,97 @@ MasterThreadTrace& getMasterThreadTrace() return *gMasterThreadTrace; } - - /////////////////////////////////////////////////////////////////////// // Sampler /////////////////////////////////////////////////////////////////////// +Sampler::Sampler(ThreadTrace* thread_trace) +: mElapsedSeconds(0), + mIsStarted(false), + mThreadTrace(thread_trace) +{ +} -void Sampler::stop() +Sampler::~Sampler() { - getThreadTrace()->deactivate(this); +} + +void Sampler::start() +{ + reset(); + resume(); +} + +void Sampler::reset() +{ + mF32Stats.reset(); + mS32Stats.reset(); + mStackTimers.reset(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); } void Sampler::resume() { - getThreadTrace()->activate(this); + if (!mIsStarted) + { + mSamplingTimer.reset(); + getThreadTrace()->activate(this); + mIsStarted = true; + } +} + +void Sampler::stop() +{ + if (mIsStarted) + { + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + getThreadTrace()->deactivate(this); + mIsStarted = false; + } +} + +ThreadTrace* Sampler::getThreadTrace() +{ + return mThreadTrace; +} + +void Sampler::makePrimary() +{ + mF32Stats.makePrimary(); + mS32Stats.makePrimary(); + mStackTimers.makePrimary(); } -class ThreadTrace* Sampler::getThreadTrace() +void Sampler::mergeFrom( const Sampler* other ) { - return LLThread::getTraceData(); + mF32Stats.mergeFrom(other->mF32Stats); + mS32Stats.mergeFrom(other->mS32Stats); + mStackTimers.mergeFrom(other->mStackTimers); } + /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// ThreadTrace::ThreadTrace() { - mPrimarySampler.makePrimary(); + mPrimarySampler = createSampler(); + mPrimarySampler->makePrimary(); + mPrimarySampler->start(); } -ThreadTrace::ThreadTrace( const ThreadTrace& other ) : mPrimarySampler(other.mPrimarySampler) +ThreadTrace::ThreadTrace( const ThreadTrace& other ) +: mPrimarySampler(new Sampler(*(other.mPrimarySampler))) { - mPrimarySampler.makePrimary(); + mPrimarySampler->makePrimary(); +} + +ThreadTrace::~ThreadTrace() +{ + delete mPrimarySampler; } void ThreadTrace::activate( Sampler* sampler ) @@ -117,11 +174,13 @@ void ThreadTrace::flushPrimary() { (*it)->mergeFrom(mPrimarySampler); } - mPrimarySampler.reset(); + mPrimarySampler->reset(); } - - +Sampler* ThreadTrace::createSampler() +{ + return new Sampler(this); +} @@ -129,12 +188,23 @@ void ThreadTrace::flushPrimary() // SlaveThreadTrace /////////////////////////////////////////////////////////////////////// +SlaveThreadTrace::SlaveThreadTrace() +: ThreadTrace(getMasterThreadTrace()), + mSharedData(createSampler()) +{ + getMasterThreadTrace().addSlaveThread(this); +} + +SlaveThreadTrace::~SlaveThreadTrace() +{ + getMasterThreadTrace().removeSlaveThread(this); +} + void SlaveThreadTrace::pushToMaster() { mSharedData.copyFrom(mPrimarySampler); } - /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// @@ -155,7 +225,7 @@ void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child)); + mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child, createSampler())); } void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) @@ -175,15 +245,26 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) } void MasterThreadTrace::pushToMaster() -{ - -} +{} MasterThreadTrace::MasterThreadTrace() { LLThread::setTraceData(this); } +/////////////////////////////////////////////////////////////////////// +// MasterThreadTrace::SlaveThreadTraceProxy +/////////////////////////////////////////////////////////////////////// + +MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace, Sampler* storage ) +: mSlaveTrace(trace), + mSamplerStorage(storage) +{} +MasterThreadTrace::SlaveThreadTraceProxy::~SlaveThreadTraceProxy() +{ + delete mSamplerStorage; } + +} diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 601b5ed182..a443735e69 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -32,6 +32,7 @@ #include "llmutex.h" #include "llmemory.h" +#include "lltimer.h" #include @@ -39,6 +40,7 @@ #define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) #define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); + namespace LLTrace { void init(); @@ -135,7 +137,7 @@ namespace LLTrace static AccumulatorBuffer& getDefaultBuffer() { - static AccumulatorBuffer sBuffer; + static AccumulatorBuffer sBuffer(STATIC_ALLOC); return sBuffer; } @@ -354,54 +356,38 @@ namespace LLTrace class Sampler { public: - Sampler() {} - Sampler(const Sampler& other) - : mF32Stats(other.mF32Stats), - mS32Stats(other.mS32Stats), - mTimers(other.mTimers) - {} - - ~Sampler() - {} + ~Sampler(); - void makePrimary() - { - mF32Stats.makePrimary(); - mS32Stats.makePrimary(); - mTimers.makePrimary(); - } - - void start() - { - reset(); - resume(); - } + void makePrimary(); + void start(); void stop(); void resume(); - void mergeFrom(const Sampler& other) - { - mF32Stats.mergeFrom(other.mF32Stats); - mS32Stats.mergeFrom(other.mS32Stats); - mTimers.mergeFrom(other.mTimers); - } + void mergeFrom(const Sampler* other); - void reset() - { - mF32Stats.reset(); - mS32Stats.reset(); - mTimers.reset(); - } + void reset(); + + bool isStarted() { return mIsStarted; } private: + friend class ThreadTrace; + Sampler(class ThreadTrace* thread_trace); + + // no copy + Sampler(const Sampler& other) {} // returns data for current thread class ThreadTrace* getThreadTrace(); AccumulatorBuffer > mF32Stats; AccumulatorBuffer > mS32Stats; - AccumulatorBuffer mTimers; + AccumulatorBuffer mStackTimers; + + bool mIsStarted; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + ThreadTrace* mThreadTrace; }; class ThreadTrace @@ -410,17 +396,19 @@ namespace LLTrace ThreadTrace(); ThreadTrace(const ThreadTrace& other); - virtual ~ThreadTrace() {} + virtual ~ThreadTrace(); void activate(Sampler* sampler); void deactivate(Sampler* sampler); void flushPrimary(); + Sampler* createSampler(); + virtual void pushToMaster() = 0; - Sampler* getPrimarySampler() { return &mPrimarySampler; } + Sampler* getPrimarySampler() { return mPrimarySampler; } protected: - Sampler mPrimarySampler; + Sampler* mPrimarySampler; std::list mActiveSamplers; }; @@ -440,11 +428,11 @@ namespace LLTrace private: struct SlaveThreadTraceProxy { - SlaveThreadTraceProxy(class SlaveThreadTrace* trace) - : mSlaveTrace(trace) - {} + SlaveThreadTraceProxy(class SlaveThreadTrace* trace, Sampler* storage); + + ~SlaveThreadTraceProxy(); class SlaveThreadTrace* mSlaveTrace; - Sampler mSamplerStorage; + Sampler* mSamplerStorage; }; typedef std::list slave_thread_trace_list_t; @@ -455,18 +443,8 @@ namespace LLTrace class SlaveThreadTrace : public ThreadTrace { public: - explicit - SlaveThreadTrace() - : ThreadTrace(getMasterThreadTrace()), - mSharedData(mPrimarySampler) - { - getMasterThreadTrace().addSlaveThread(this); - } - - ~SlaveThreadTrace() - { - getMasterThreadTrace().removeSlaveThread(this); - } + SlaveThreadTrace(); + ~SlaveThreadTrace(); // call this periodically to gather stats data for master thread to consume /*virtual*/ void pushToMaster(); @@ -479,29 +457,35 @@ namespace LLTrace { public: explicit - SharedData(const Sampler& other_sampler) - : mSampler(other_sampler) - {} + SharedData(Sampler* sampler) + : mSampler(sampler) + { + } + + ~SharedData() + { + delete mSampler; + } - void copyFrom(Sampler& source) + void copyFrom(Sampler* source) { LLMutexLock lock(&mSamplerMutex); { - mSampler.mergeFrom(source); + mSampler->mergeFrom(source); } } - void copyTo(Sampler& sink) + void copyTo(Sampler* sink) { LLMutexLock lock(&mSamplerMutex); { - sink.mergeFrom(mSampler); + sink->mergeFrom(mSampler); } } private: // add a cache line's worth of unused space to avoid any potential of false sharing LLMutex mSamplerMutex; - Sampler mSampler; + Sampler* mSampler; }; SharedData mSharedData; }; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index be7aae4eb7..29497257ac 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -31,6 +31,8 @@ #include "../llimageworker.h" // For timer class #include "../llcommon/lltimer.h" +// for lltrace class +#include "../llcommon/lltrace.h" // Tut header #include "../test/lltut.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index fcbef491fe..0bb87dfa6c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -60,7 +60,7 @@ #include "llcurl.h" #include "llcalc.h" #include "lltexturestats.h" -#include "lltexturestats.h" +#include "lltrace.h" #include "llviewerwindow.h" #include "llviewerdisplay.h" #include "llviewermedia.h" -- cgit v1.3 From 68413515029f50713c70e4adec3ce6fd1022d59f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 6 Jan 2013 21:37:31 -0800 Subject: SH-3468 WIP add memory tracking base class fix for unit test failures...cleanup apr without destroying pools, allowing LLProxy to clean itself up as a singleton (and avoiding spurious dependencies associated with manually destorying singletons that rely on apr pools) --- indra/llcommon/llapr.cpp | 4 ++-- indra/llcommon/llapr.h | 2 +- indra/llcommon/lltracethreadrecorder.cpp | 2 +- indra/llimage/tests/llimageworker_test.cpp | 3 +++ indra/llkdu/tests/llimagej2ckdu_test.cpp | 4 +++- indra/llmessage/llproxy.cpp | 3 +-- indra/test/test.cpp | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d911f258b6..8a87911315 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -60,7 +60,7 @@ void ll_init_apr() } -void ll_cleanup_apr() +void ll_cleanup_apr(bool destroy_pools) { LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; @@ -83,7 +83,7 @@ void ll_cleanup_apr() LLThreadLocalPointerBase::destroyAllThreadLocalStorage(); - if (gAPRPoolp) + if (gAPRPoolp && destroy_pools) { apr_pool_destroy(gAPRPoolp); gAPRPoolp = NULL; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index b3c9bfd58c..424ddc6505 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -70,7 +70,7 @@ void LL_COMMON_API ll_init_apr(); /** * @brief Cleanup those common apr constructs. */ -void LL_COMMON_API ll_cleanup_apr(); +void LL_COMMON_API ll_cleanup_apr(bool destroy_pools = true); // //LL apr_pool diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 9fb789c62d..7b493a651e 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -127,7 +127,7 @@ std::list::iterator ThreadRecorder::update( Rec if (it == end_it) { - llerrs << "Recording not active on this thread" << llendl; + llwarns << "Recording not active on this thread" << llendl; } return it; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 29497257ac..4118896768 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,6 +44,9 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. +LLTrace::MemStat LLImageBase::sMemStat("LLImage"); + + LLImageBase::LLImageBase() : mData(NULL), mDataSize(0), diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 62c245f125..c28f121eb8 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -43,7 +43,9 @@ // End Stubbing // ------------------------------------------------------------------------------------------- -// Stubb the LL Image Classes +// Stub the LL Image Classes +LLTrace::MemStat LLImageBase::sMemStat("LLImage"); + LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } U8* LLImageRaw::allocateData(S32 ) { return NULL; } diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp index 9988fcd9c0..aa474fabd2 100644 --- a/indra/llmessage/llproxy.cpp +++ b/indra/llmessage/llproxy.cpp @@ -57,8 +57,7 @@ LLProxy::LLProxy(): mAuthMethodSelected(METHOD_NOAUTH), mSocksUsername(), mSocksPassword() -{ -} +{} LLProxy::~LLProxy() { diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 8bd302ce7a..d75040393c 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -643,7 +643,7 @@ int main(int argc, char **argv) s.close(); } - ll_cleanup_apr(); + ll_cleanup_apr(false); int retval = (success ? 0 : 1); return retval; -- cgit v1.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 +++++------ indra/llcommon/lltracerecording.h | 51 +++++----- indra/llcommon/llunit.h | 8 +- indra/llimage/tests/llimageworker_test.cpp | 2 +- indra/llkdu/tests/llimagej2ckdu_test.cpp | 2 +- indra/llui/llcontainerview.cpp | 8 +- indra/llui/llcontainerview.h | 4 +- indra/llui/llmultifloater.h | 3 - indra/llui/llstatbar.cpp | 13 ++- indra/llui/llstatbar.h | 2 +- indra/newview/CMakeLists.txt | 10 +- indra/newview/llagent.cpp | 8 ++ indra/newview/llagent.h | 2 + indra/newview/llfasttimerview.cpp | 8 +- indra/newview/llfloatersceneloadstats.cpp | 37 +++++++ indra/newview/llfloatersceneloadstats.h | 39 ++++++++ indra/newview/llscenemonitor.cpp | 108 ++++++++++++++++++++- indra/newview/llscenemonitor.h | 13 +++ indra/newview/llviewerfloaterreg.cpp | 35 +++---- indra/newview/llworld.cpp | 2 +- .../default/xui/en/floater_scene_load_stats.xml | 84 ++++++++++++---- 21 files changed, 380 insertions(+), 114 deletions(-) create mode 100644 indra/newview/llfloatersceneloadstats.cpp create mode 100644 indra/newview/llfloatersceneloadstats.h (limited to 'indra/llimage/tests') 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; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 751ff298ce..3e7ed2b592 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -249,16 +249,15 @@ namespace LLTrace : public LLStopWatchControlsMixin { public: - PeriodicRecording(S32 num_periods, EPlayState state = STOPPED); - PeriodicRecording(PeriodicRecording& recording); - ~PeriodicRecording(); + PeriodicRecording(U32 num_periods, EPlayState state = STOPPED); void nextPeriod(); - S32 getNumPeriods() { return mNumPeriods; } + U32 getNumPeriods() { return mRecordingPeriods.size(); } Recording& getLastRecordingPeriod() { - return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; + U32 num_periods = mRecordingPeriods.size(); + return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; } const Recording& getLastRecordingPeriod() const @@ -276,16 +275,18 @@ namespace LLTrace return mRecordingPeriods[mCurPeriod]; } - Recording& getPrevRecordingPeriod(S32 offset) + Recording& getPrevRecordingPeriod(U32 offset) { - offset = llclamp(offset, 0, mNumPeriods - 1); - return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } - const Recording& getPrevRecordingPeriod(S32 offset) const + const Recording& getPrevRecordingPeriod(U32 offset) const { - offset = llclamp(offset, 0, mNumPeriods - 1); - return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } Recording snapshotCurRecordingPeriod() const @@ -301,7 +302,8 @@ namespace LLTrace typename T::value_t getPeriodMin(const TraceType& stat) const { typename T::value_t min_val = (std::numeric_limits::max)(); - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat)); } @@ -312,7 +314,8 @@ namespace LLTrace F64 getPeriodMinPerSec(const TraceType& stat) const { F64 min_val = (std::numeric_limits::max)(); - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat)); } @@ -323,7 +326,8 @@ namespace LLTrace typename T::value_t getPeriodMax(const TraceType& stat) const { typename T::value_t max_val = (std::numeric_limits::min)(); - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat)); } @@ -334,7 +338,8 @@ namespace LLTrace F64 getPeriodMaxPerSec(const TraceType& stat) const { F64 max_val = (std::numeric_limits::min)(); - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat)); } @@ -345,14 +350,15 @@ namespace LLTrace typename MeanValueType >::type getPeriodMean(const TraceType& stat) const { typename MeanValueType >::type mean = 0.0; - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { if (mRecordingPeriods[i].getDuration() > 0.f) { mean += mRecordingPeriods[i].getSum(stat); } } - mean /= mNumPeriods; + mean /= num_periods; return mean; } @@ -360,14 +366,15 @@ namespace LLTrace typename MeanValueType >::type getPeriodMeanPerSec(const TraceType& stat) const { typename MeanValueType >::type mean = 0.0; - for (S32 i = 0; i < mNumPeriods; i++) + U32 num_periods = mRecordingPeriods.size(); + for (S32 i = 0; i < num_periods; i++) { if (mRecordingPeriods[i].getDuration() > 0.f) { mean += mRecordingPeriods[i].getPerSec(stat); } } - mean /= mNumPeriods; + mean /= num_periods; return mean; } @@ -382,11 +389,11 @@ namespace LLTrace /*virtual*/ void splitFrom(PeriodicRecording& other); private: - Recording* mRecordingPeriods; + std::vector mRecordingPeriods; Recording mTotalRecording; bool mTotalValid; - S32 mNumPeriods, - mCurPeriod; + const bool mAutoResize; + S32 mCurPeriod; }; PeriodicRecording& get_frame_recording(); diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 823550db5d..f86f111b90 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -143,7 +143,7 @@ struct LLUnit void operator *= (LLUnit multiplicand) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert_template(OTHER_UNIT, 0, "Multiplication of unit types not supported."); + llstatic_assert_template(OTHER_UNIT, false, "Multiplication of unit types not supported."); } void operator /= (storage_t divisor) @@ -155,7 +155,7 @@ struct LLUnit void operator /= (LLUnit divisor) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert_template(OTHER_UNIT, 0, "Illegal in-place division of unit types."); + llstatic_assert_template(OTHER_UNIT, false, "Illegal in-place division of unit types."); } template @@ -315,7 +315,7 @@ template operator * (LLUnit, LLUnit) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported."); + llstatic_assert_template(STORAGE_TYPE1, false, "Multiplication of unit types results in new unit type - not supported."); return LLUnit(); } @@ -335,7 +335,7 @@ template operator * (LLUnitImplicit, LLUnitImplicit) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported."); + llstatic_assert_template(STORAGE_TYPE1, false, "Multiplication of unit types results in new unit type - not supported."); return LLUnitImplicit(); } diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 4118896768..b6f2694742 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,7 +44,7 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -LLTrace::MemStat LLImageBase::sMemStat("LLImage"); +LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); LLImageBase::LLImageBase() diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index c28f121eb8..14fbf344ab 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -44,7 +44,7 @@ // End Stubbing // ------------------------------------------------------------------------------------------- // Stub the LL Image Classes -LLTrace::MemStat LLImageBase::sMemStat("LLImage"); +LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } diff --git a/indra/llui/llcontainerview.cpp b/indra/llui/llcontainerview.cpp index e08ccb0b78..06f8e72c9c 100644 --- a/indra/llui/llcontainerview.cpp +++ b/indra/llui/llcontainerview.cpp @@ -49,7 +49,6 @@ LLContainerView::LLContainerView(const LLContainerView::Params& p) mLabel(p.label), mDisplayChildren(p.display_children) { - mCollapsible = TRUE; mScrollContainer = NULL; } @@ -75,6 +74,11 @@ bool LLContainerView::addChild(LLView* child, S32 tab_group) return res; } +BOOL LLContainerView::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + return handleMouseDown(x, y, mask); +} + BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; @@ -84,7 +88,7 @@ BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) } if (!handled) { - if( mCollapsible && mShowLabel && (y >= getRect().getHeight() - 10) ) + if( mShowLabel && (y >= getRect().getHeight() - 10) ) { setDisplayChildren(!mDisplayChildren); reshape(getRect().getWidth(), getRect().getHeight(), FALSE); diff --git a/indra/llui/llcontainerview.h b/indra/llui/llcontainerview.h index e81600fd6c..ac92b19977 100644 --- a/indra/llui/llcontainerview.h +++ b/indra/llui/llcontainerview.h @@ -66,6 +66,7 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -87,8 +88,5 @@ public: protected: BOOL mDisplayChildren; std::string mLabel; -public: - BOOL mCollapsible; - }; #endif // LL_CONTAINERVIEW_ diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index 9fa917eca1..6c97f80e31 100644 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -96,6 +96,3 @@ protected: }; #endif // LL_MULTI_FLOATER_H - - - diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 219ddad452..cda40aac72 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -88,7 +88,7 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) LLView* parent = getParent(); parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); - return FALSE; + return TRUE; } void LLStatBar::draw() @@ -98,6 +98,7 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; + S32 num_samples = 0; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); if (mCountFloatp) @@ -110,6 +111,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountFloatp); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } else { @@ -117,6 +119,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp); max = frame_recording.getPeriodMax(*mCountFloatp); mean = frame_recording.getPeriodMean(*mCountFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } } else if (mCountIntp) @@ -129,6 +132,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountIntp); max = frame_recording.getPeriodMaxPerSec(*mCountIntp); mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } else { @@ -136,6 +140,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountIntp); max = frame_recording.getPeriodMax(*mCountIntp); mean = frame_recording.getPeriodMean(*mCountIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } } else if (mMeasurementFloatp) @@ -145,6 +150,7 @@ void LLStatBar::draw() min = recording.getMin(*mMeasurementFloatp); max = recording.getMax(*mMeasurementFloatp); mean = recording.getMean(*mMeasurementFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementFloatp); } else if (mMeasurementIntp) { @@ -153,6 +159,7 @@ void LLStatBar::draw() min = recording.getMin(*mMeasurementIntp); max = recording.getMax(*mMeasurementIntp); mean = recording.getMean(*mMeasurementIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementIntp); } current *= mUnitScale; @@ -191,7 +198,7 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if (mScaleRange) + if (mScaleRange && num_samples) { F32 cur_max = mLabelSpacing; while(max > cur_max) @@ -472,7 +479,7 @@ LLRect LLStatBar::getRequiredRect() } else { - rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, LLTrace::get_frame_recording().getNumPeriods())); + rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, (S32)LLTrace::get_frame_recording().getNumPeriods())); } } else diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index a83ccbe9e5..74a3ebde2f 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -71,7 +71,7 @@ public: update_rate("update_rate", 5.0f), unit_scale("unit_scale", 1.f), show_per_sec("show_per_sec", true), - show_bar("show_bar", TRUE), + show_bar("show_bar", true), show_history("show_history", false), show_mean("show_mean", true), scale_range("scale_range", true), diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 16d82d5a0a..575400941f 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -239,6 +239,7 @@ set(viewer_SOURCE_FILES llfloaterregiondebugconsole.cpp llfloaterregioninfo.cpp llfloaterreporter.cpp + llfloatersceneloadstats.cpp llfloaterscriptdebug.cpp llfloaterscriptlimits.cpp llfloatersearch.cpp @@ -462,7 +463,7 @@ set(viewer_SOURCE_FILES llremoteparcelrequest.cpp llsavedsettingsglue.cpp llsaveoutfitcombobtn.cpp - llscenemonitor.cpp + llscenemonitor.cpp llsceneview.cpp llscreenchannel.cpp llscriptfloater.cpp @@ -587,7 +588,7 @@ set(viewer_SOURCE_FILES llviewernetwork.cpp llviewerobject.cpp llviewerobjectlist.cpp - llvieweroctree.cpp + llvieweroctree.cpp llviewerparcelmedia.cpp llviewerparcelmediaautoplay.cpp llviewerparcelmgr.cpp @@ -816,6 +817,7 @@ set(viewer_HEADER_FILES llfloaterregiondebugconsole.h llfloaterregioninfo.h llfloaterreporter.h + llfloatersceneloadstats.h llfloaterscriptdebug.h llfloaterscriptlimits.h llfloatersearch.h @@ -1030,7 +1032,7 @@ set(viewer_HEADER_FILES llrootview.h llsavedsettingsglue.h llsaveoutfitcombobtn.h - llscenemonitor.h + llscenemonitor.h llsceneview.h llscreenchannel.h llscriptfloater.h @@ -1155,7 +1157,7 @@ set(viewer_HEADER_FILES llviewernetwork.h llviewerobject.h llviewerobjectlist.h - llvieweroctree.h + llvieweroctree.h llviewerparcelmedia.h llviewerparcelmediaautoplay.h llviewerparcelmgr.h diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 4fb298df13..4e60127ef3 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1046,6 +1046,14 @@ const LLVector3d &LLAgent::getPositionGlobal() const return mPositionGlobal; } +bool LLAgent::isPositionChanged() const +{ + LLVector3d diff; + diff = mPositionGlobal - mLastPositionGlobal; + + return diff.lengthSquared() > 1.0; +} + //----------------------------------------------------------------------------- // getPositionAgent() //----------------------------------------------------------------------------- diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 99904e118c..a1e899b45d 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -250,6 +250,8 @@ public: const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; } void setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; } + + bool isPositionChanged() const; private: std::set mRegionsVisited; // Stat - what distinct regions has the avatar been to? F64 mDistanceTraveled; // Stat - how far has the avatar moved? diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index f55535b6e3..6caa89a611 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -263,7 +263,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, mRecording->getNumPeriods()); + mScrollIndex = llclamp( mScrollIndex, 0, (S32)mRecording->getNumPeriods()); return TRUE; } mHoverTimer = NULL; @@ -272,7 +272,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(mPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, - mRecording->getNumPeriods() - 1, + (S32)mRecording->getNumPeriods() - 1, MAX_VISIBLE_HISTORY); if (mHoverBarIndex == 0) { @@ -381,7 +381,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) setPauseState(true); mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); + llmin((S32)mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -1425,7 +1425,7 @@ void LLFastTimerView::drawBars() // Special: -1 = show running average LLPointer bar_image = LLUI::getUIImage("Rounded_Square"); gGL.getTexUnit(0)->bind(bar_image->getImage()); - const S32 histmax = llmin(mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; + const S32 histmax = llmin((S32)mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++) { diff --git a/indra/newview/llfloatersceneloadstats.cpp b/indra/newview/llfloatersceneloadstats.cpp new file mode 100644 index 0000000000..95e8fbf4dd --- /dev/null +++ b/indra/newview/llfloatersceneloadstats.cpp @@ -0,0 +1,37 @@ +/** + * @file llfloatersceneloadstats.cpp + * @author Richard Nelson + * @brief debug floater for measuring various scene load statistics + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, 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 "llviewerprecompiledheaders.h" + +#include "llfloatersceneloadstats.h" + + +LLFloaterSceneLoadStats::LLFloaterSceneLoadStats( const LLSD& key ) +: LLFloater(key) +{ + +} diff --git a/indra/newview/llfloatersceneloadstats.h b/indra/newview/llfloatersceneloadstats.h new file mode 100644 index 0000000000..095541f2f6 --- /dev/null +++ b/indra/newview/llfloatersceneloadstats.h @@ -0,0 +1,39 @@ +/** + * @file llfloatersceneloadstats.h + * @brief debug floater for measuring various scene load statistics + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, 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$ + */ + +#ifndef LL_FLOATERSCENELOADSTATS_H +#define LL_FLOATERSCENELOADSTATS_H + +#include "llfloater.h" + +class LLFloaterSceneLoadStats : public LLFloater +{ + friend class LLFloaterReg; +private: + LLFloaterSceneLoadStats(const LLSD& key); +}; + +#endif // LL_FLOATERSCENELOADSTATS_H diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 189697dcf0..c69f276aa2 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -37,6 +37,8 @@ #include "llwindow.h" #include "llpointer.h" #include "llspatialpartition.h" +#include "llagent.h" +#include "pipeline.h" LLSceneMonitorView* gSceneMonitorView = NULL; @@ -67,7 +69,10 @@ LLSceneMonitor::LLSceneMonitor() : mDiffPixelRatio(0.5f) { mFrames[0] = NULL; - mFrames[1] = NULL; + mFrames[1] = NULL; + + mRecording = new LLTrace::ExtendableRecording(); + mRecording->start(); } LLSceneMonitor::~LLSceneMonitor() @@ -78,6 +83,10 @@ LLSceneMonitor::~LLSceneMonitor() void LLSceneMonitor::destroyClass() { reset(); + + delete mRecording; + mRecording = NULL; + mDitheringTexture = NULL; } void LLSceneMonitor::reset() @@ -100,6 +109,67 @@ void LLSceneMonitor::reset() } } +void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height) +{ +#if 1 + //4 * 4 matrix + mDitherMatrixWidth = 4; + S32 dither_matrix[4][4] = + { + {1, 9, 3, 11}, + {13, 5, 15, 7}, + {4, 12, 2, 10}, + {16, 8, 14, 6} + }; + + mDitherScale = 255.f / 17; +#else + //8 * 8 matrix + mDitherMatrixWidth = 16; + S32 dither_matrix[16][16] = + { + {1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, + {33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, + {9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, + {41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24}, + {3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62}, + {35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30}, + {11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54}, + {43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22}, + {1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, + {33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, + {9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, + {41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24}, + {3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62}, + {35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30}, + {11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54}, + {43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22} + }; + + mDitherScale = 255.f / 65; +#endif + + LLPointer image_raw = new LLImageRaw(mDitherMatrixWidth, mDitherMatrixWidth, 3); + U8* data = image_raw->getData(); + for (S32 i = 0; i < mDitherMatrixWidth; i++) + { + for (S32 j = 0; j < mDitherMatrixWidth; j++) + { + U8 val = dither_matrix[i][j]; + *data++ = val; + *data++ = val; + *data++ = val; + } + } + + mDitheringTexture = LLViewerTextureManager::getLocalTexture(image_raw.get(), FALSE) ; + mDitheringTexture->setAddressMode(LLTexUnit::TAM_WRAP); + mDitheringTexture->setFilteringOption(LLTexUnit::TFO_POINT); + + mDitherScaleS = (F32)width / mDitherMatrixWidth; + mDitherScaleT = (F32)height / mDitherMatrixWidth; +} + void LLSceneMonitor::setDebugViewerVisible(BOOL visible) { mDebugViewerVisible = visible; @@ -137,6 +207,11 @@ bool LLSceneMonitor::preCapture() return false; } + if(gAgent.isPositionChanged()) + { + mRecording->reset(); + } + if(timer.getElapsedTimeF32() < mSamplingTime) { return false; @@ -197,6 +272,9 @@ void LLSceneMonitor::freezeScene() // freeze everything else gSavedSettings.setBOOL("FreezeTime", TRUE); + + gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); } void LLSceneMonitor::unfreezeScene() @@ -206,6 +284,9 @@ void LLSceneMonitor::unfreezeScene() // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); + + gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); } void LLSceneMonitor::capture() @@ -268,10 +349,13 @@ void LLSceneMonitor::compare() { mDiff = new LLRenderTarget(); mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true); + + generateDitheringTexture(width, height); } else if(mDiff->getWidth() != width || mDiff->getHeight() != height) { mDiff->resize(width, height, GL_RGBA); + generateDitheringTexture(width, height); } mDiff->bindTarget(); @@ -279,6 +363,10 @@ void LLSceneMonitor::compare() gTwoTextureCompareProgram.bind(); + gTwoTextureCompareProgram.uniform1f("dither_scale", mDitherScale); + gTwoTextureCompareProgram.uniform1f("dither_scale_s", mDitherScaleS); + gTwoTextureCompareProgram.uniform1f("dither_scale_t", mDitherScaleT); + gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->bind(mFrames[0]); @@ -289,6 +377,11 @@ void LLSceneMonitor::compare() gGL.getTexUnit(1)->bind(mFrames[1]); gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(2)->activate(); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->bind(mDitheringTexture); + gGL.getTexUnit(2)->activate(); + gl_rect_2d_simple_tex(width, height); mDiff->flush(); @@ -299,6 +392,8 @@ void LLSceneMonitor::compare() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->disable(); + gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); mHasNewDiff = TRUE; @@ -368,6 +463,7 @@ void LLSceneMonitor::calcDiffAggregate() } } +static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference"); void LLSceneMonitor::fetchQueryResult() { if(!mHasNewQueryResult) @@ -388,6 +484,11 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) + if(mDiffResult > 0.01f) + { + mRecording->extend(); + sample(sFramePixelDiff, mDiffResult); + } //llinfos << count << " : " << mDiffResult << llendl; } //------------------------------------------------------------------------------------------------------------- @@ -454,6 +555,11 @@ void LLSceneMonitorView::draw() num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime()); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; + + num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getAcceptedRecording().getDuration().value()); + LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; LLView::draw(); } diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h index 02e3d57d46..709650e206 100644 --- a/indra/newview/llscenemonitor.h +++ b/indra/newview/llscenemonitor.h @@ -31,9 +31,11 @@ #include "llmath.h" #include "llfloater.h" #include "llcharacter.h" +#include "lltracerecording.h" class LLCharacter; class LLRenderTarget; +class LLViewerTexture; class LLSceneMonitor : public LLSingleton { @@ -61,11 +63,14 @@ public: bool isEnabled()const {return mEnabled;} bool needsUpdate() const; + LLTrace::ExtendableRecording* getRecording() const {return mRecording;} + private: void freezeScene(); void unfreezeScene(); void reset(); bool preCapture(); + void generateDitheringTexture(S32 width, S32 height); private: BOOL mEnabled; @@ -85,7 +90,15 @@ private: F32 mSamplingTime; //time interval to capture frames, in seconds F32 mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension + LLPointer mDitheringTexture; + S32 mDitherMatrixWidth; + F32 mDitherScale; + F32 mDitherScaleS; + F32 mDitherScaleT; + std::vector mAvatarPauseHandles; + + LLTrace::ExtendableRecording* mRecording; }; class LLSceneMonitorView : public LLFloater diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index e72ea4b826..792c55441d 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -28,63 +28,62 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterreg.h" - #include "llviewerfloaterreg.h" -#include "llfloaterautoreplacesettings.h" -#include "llcompilequeue.h" + #include "llcallfloater.h" +#include "llcommandhandler.h" +#include "llcompilequeue.h" #include "llfasttimerview.h" #include "llfloaterabout.h" #include "llfloaterauction.h" +#include "llfloaterautoreplacesettings.h" #include "llfloateravatar.h" #include "llfloateravatarpicker.h" #include "llfloateravatartextures.h" #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" +#include "llfloaterbulkpermission.h" +#include "llfloaterbump.h" #include "llfloaterbuy.h" #include "llfloaterbuycontents.h" #include "llfloaterbuycurrency.h" #include "llfloaterbuycurrencyhtml.h" #include "llfloaterbuyland.h" -#include "llfloaterbulkpermission.h" -#include "llfloaterbump.h" #include "llfloaterbvhpreview.h" #include "llfloatercamera.h" #include "llfloaterdeleteenvpreset.h" +#include "llfloaterdestinations.h" #include "llfloaterdisplayname.h" #include "llfloatereditdaycycle.h" #include "llfloatereditsky.h" #include "llfloatereditwater.h" #include "llfloaterenvironmentsettings.h" #include "llfloaterevent.h" -#include "llfloaterdestinations.h" #include "llfloaterfonttest.h" #include "llfloatergesture.h" #include "llfloatergodtools.h" #include "llfloatergroups.h" #include "llfloaterhardwaresettings.h" #include "llfloaterhelpbrowser.h" -#include "llfloaterwebcontent.h" -#include "llfloaterwebprofile.h" -#include "llfloatermediasettings.h" #include "llfloaterhud.h" #include "llfloaterimagepreview.h" -#include "llimfloater.h" #include "llfloaterinspect.h" #include "llfloaterinventory.h" #include "llfloaterjoystick.h" #include "llfloaterland.h" #include "llfloaterlandholdings.h" #include "llfloatermap.h" +#include "llfloatermediasettings.h" #include "llfloatermemleak.h" +#include "llfloatermodelpreview.h" #include "llfloaternamedesc.h" #include "llfloaternotificationsconsole.h" #include "llfloaterobjectweights.h" #include "llfloateropenobject.h" #include "llfloateroutbox.h" #include "llfloaterpathfindingcharacters.h" -#include "llfloaterpathfindinglinksets.h" #include "llfloaterpathfindingconsole.h" +#include "llfloaterpathfindinglinksets.h" #include "llfloaterpay.h" #include "llfloaterperms.h" #include "llfloaterpostprocess.h" @@ -93,6 +92,7 @@ #include "llfloaterregiondebugconsole.h" #include "llfloaterregioninfo.h" #include "llfloaterreporter.h" +#include "llfloatersceneloadstats.h" #include "llfloaterscriptdebug.h" #include "llfloaterscriptlimits.h" #include "llfloatersearch.h" @@ -107,15 +107,18 @@ #include "llfloatertestlistview.h" #include "llfloatertexturefetchdebugger.h" #include "llfloatertools.h" -#include "llfloatertos.h" #include "llfloatertopobjects.h" +#include "llfloatertos.h" #include "llfloatertoybox.h" #include "llfloatertranslationsettings.h" #include "llfloateruipreview.h" #include "llfloatervoiceeffect.h" +#include "llfloaterwebcontent.h" +#include "llfloaterwebprofile.h" #include "llfloaterwhitelistentry.h" #include "llfloaterwindowsize.h" #include "llfloaterworldmap.h" +#include "llimfloater.h" #include "llimfloatercontainer.h" #include "llinspectavatar.h" #include "llinspectgroup.h" @@ -124,6 +127,7 @@ #include "llinspecttoast.h" #include "llmoveview.h" #include "llnearbychat.h" +#include "llnearbychatbar.h" #include "llpanelblockedlist.h" #include "llpanelclassified.h" #include "llpreviewanim.h" @@ -132,11 +136,8 @@ #include "llpreviewscript.h" #include "llpreviewsound.h" #include "llpreviewtexture.h" -#include "llsyswellwindow.h" #include "llscriptfloater.h" -#include "llfloatermodelpreview.h" -#include "llcommandhandler.h" -#include "llnearbychatbar.h" +#include "llsyswellwindow.h" // *NOTE: Please add files in alphabetical order to keep merges easy. @@ -297,8 +298,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index e088f94d64..aba9df24c9 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1172,7 +1172,7 @@ void send_agent_resume() } // Resume data collection to ignore invalid rates - LLViewerStats::instance().getRecording().resume();//getInstance()->mFPSStat.reset(); + LLViewerStats::instance().getRecording().resume(); LLAppViewer::instance()->resumeMainloopTimeout(); } diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml index 9dbf59ef4d..f4021d210a 100644 --- a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml @@ -15,7 +15,7 @@ label="Pause" name="playpause"/> - + + precision="0"/> - - + + show_bar="false"/> + show_bar="false"/> @@ -222,6 +245,7 @@ setting="OpenDebugStatSim"> Date: Mon, 1 Jul 2013 17:04:01 -0700 Subject: SH-4294 FIX Interesting: Statistics Texture cache hit rate is always 0% also, removed LLTrace::init and cleanup removed derived class implementation of memory stat for LLMemTrackable is automatic now --- indra/llcommon/llcommon.cpp | 14 ++++- indra/llcommon/llfasttimer.cpp | 2 +- indra/llcommon/llthread.cpp | 2 +- indra/llcommon/lltrace.cpp | 26 ++++------ indra/llcommon/lltrace.h | 68 +++++++++++++++---------- indra/llcommon/lltraceaccumulators.h | 7 +-- indra/llcommon/lltracethreadrecorder.cpp | 14 +++-- indra/llcommon/lltracethreadrecorder.h | 10 ++-- indra/llimage/llimage.cpp | 13 ++--- indra/llimage/llimage.h | 2 - indra/llimage/tests/llimageworker_test.cpp | 8 --- indra/llkdu/tests/llimagej2ckdu_test.cpp | 2 - indra/llui/llstatbar.cpp | 12 ++--- indra/llui/lltextbase.cpp | 2 - indra/llui/lltextbase.h | 2 - indra/llui/llview.cpp | 1 - indra/llui/llview.h | 1 - indra/llui/llviewmodel.cpp | 2 - indra/llui/llviewmodel.h | 2 - indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawable.cpp | 1 - indra/newview/lldrawable.h | 1 - indra/newview/llfasttimerview.cpp | 10 ++-- indra/newview/llviewerobject.cpp | 2 - indra/newview/llviewerobject.h | 1 - indra/newview/llvocache.cpp | 2 - indra/newview/llvocache.h | 3 -- indra/newview/tests/llviewerassetstats_test.cpp | 6 ++- indra/test/test.cpp | 9 +++- 29 files changed, 107 insertions(+), 120 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index c720df7555..96ec0cdefe 100755 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -30,10 +30,13 @@ #include "llmemory.h" #include "llthread.h" #include "lltrace.h" +#include "lltracethreadrecorder.h" //static BOOL LLCommon::sAprInitialized = FALSE; +static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; + //static void LLCommon::initClass() { @@ -45,13 +48,20 @@ void LLCommon::initClass() } LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); - LLTrace::init(); + + if (!sMasterThreadRecorder) + { + sMasterThreadRecorder = new LLTrace::ThreadRecorder(); + LLTrace::set_master_thread_recorder(sMasterThreadRecorder); + } } //static void LLCommon::cleanupClass() { - LLTrace::cleanup(); + delete sMasterThreadRecorder; + sMasterThreadRecorder = NULL; + LLTrace::set_master_thread_recorder(NULL); LLThreadSafeRefCount::cleanupThreadSafeRefCount(); LLTimer::cleanupClass(); if (sAprInitialized) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 7a7f1c79c1..a72f16d385 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -250,7 +250,7 @@ void TimeBlock::updateTimes() { // walk up stack of active timers and accumulate current time while leaving timing structures active BlockTimerStackRecord* stack_record = LLThreadLocalSingletonPointer::getInstance(); - if (stack_record) return; + if (!stack_record) return; U64 cur_time = getCPUClockCount64(); BlockTimer* cur_timer = stack_record->mActiveTimer; diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index d07cccdf15..166a4eb26d 100755 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -93,7 +93,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - LLTrace::ThreadRecorder thread_recorder(LLTrace::getUIThreadRecorder()); + LLTrace::ThreadRecorder thread_recorder(*LLTrace::get_master_thread_recorder()); #if !LL_DARWIN sThreadID = threadp->mID; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 26c19e5121..3dffbe6d4a 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,34 +30,26 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" -static S32 sInitializationCount = 0; - namespace LLTrace { -void init() +TraceBase::TraceBase( const char* name, const char* description ) +: mName(name), + mDescription(description ? description : "") { - if (sInitializationCount++ == 0) +#ifndef LL_RELEASE_FOR_DOWNLOAD + if (LLTrace::get_master_thread_recorder() != NULL) { - gUIThreadRecorder = new ThreadRecorder(); + llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; } +#endif } -bool isInitialized() +const char* TraceBase::getUnitLabel() { - return sInitializationCount > 0; + return ""; } -void cleanup() -{ - if (--sInitializationCount == 0) - { - delete gUIThreadRecorder; - gUIThreadRecorder = NULL; - } -} - - TimeBlockTreeNode::TimeBlockTreeNode() : mBlock(NULL), mParent(NULL), diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 72ef51c232..1cde450dc2 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -53,19 +53,29 @@ STORAGE_TYPE storage_value(LLUnit val) { return val.val template STORAGE_TYPE storage_value(LLUnitImplicit val) { return val.value(); } -void init(); -void cleanup(); -bool isInitialized(); +class TraceBase +{ +public: + TraceBase(const char* name, const char* description); + virtual ~TraceBase() {}; + virtual const char* getUnitLabel(); + + const std::string& getName() const { return mName; } + +protected: + const std::string mName; + const std::string mDescription; +}; template class TraceType -: public LLInstanceTracker, std::string> +: public TraceBase, + public LLInstanceTracker, std::string> { public: TraceType(const char* name, const char* description = NULL) : LLInstanceTracker, std::string>(name), - mName(name), - mDescription(description ? description : ""), + TraceBase(name, description), mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} @@ -78,13 +88,7 @@ public: size_t getIndex() const { return mAccumulatorIndex; } static size_t getNumIndices() { return AccumulatorBuffer::getNumIndices(); } - virtual const char* getUnitLabel() { return ""; } - - const std::string& getName() const { return mName; } - -protected: - const std::string mName; - const std::string mDescription; +private: const size_t mAccumulatorIndex; }; @@ -320,7 +324,7 @@ class MemTrackable template struct TrackMemImpl; - typedef MemTrackable mem_trackable_t; + typedef MemTrackable mem_trackable_t; public: typedef void mem_trackable_tag_t; @@ -332,7 +336,7 @@ public: void* operator new(size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -344,7 +348,7 @@ public: void operator delete(void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -356,7 +360,7 @@ public: void *operator new [](size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -368,7 +372,7 @@ public: void operator delete[](void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -394,14 +398,16 @@ public: } - void memClaimAmount(size_t size) + template + AMOUNT_T& memClaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - mMemFootprint += size; + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + mMemFootprint += (size_t)size; if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); } + return size; } // remove memory we had claimed from our calculated footprint @@ -419,24 +425,28 @@ public: return value; } - void memDisclaimAmount(size_t size) + template + AMOUNT_T& memDisclaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); } + return size; } private: size_t mMemFootprint; + static MemStatHandle sMemStat; + template struct TrackMemImpl { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -447,7 +457,7 @@ private: static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -462,7 +472,7 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked)); @@ -471,7 +481,7 @@ private: static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked)); @@ -480,5 +490,9 @@ private: }; }; +template +MemStatHandle MemTrackable::sMemStat(typeid(DERIVED).name()); + + } #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 825cc9e3a8..fac6347ff9 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -33,6 +33,7 @@ #include "llunit.h" #include "lltimer.h" #include "llrefcount.h" +#include "llthreadlocalstorage.h" namespace LLTrace { @@ -142,12 +143,6 @@ namespace LLTrace // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned size_t reserveSlot() { -#ifndef LL_RELEASE_FOR_DOWNLOAD - if (LLTrace::isInitialized()) - { - llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; - } -#endif size_t next_slot = sNextStorageSlot++; if (next_slot >= mStorageSize) { diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index e88c5bf177..7ac0e75154 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -31,13 +31,14 @@ namespace LLTrace { -ThreadRecorder* gUIThreadRecorder = NULL; +static ThreadRecorder* sMasterThreadRecorder = NULL; /////////////////////////////////////////////////////////////////////// // ThreadRecorder /////////////////////////////////////////////////////////////////////// ThreadRecorder::ThreadRecorder() +: mMasterRecorder(NULL) { init(); } @@ -268,10 +269,15 @@ void ThreadRecorder::pullFromChildren() } -ThreadRecorder& getUIThreadRecorder() +void set_master_thread_recorder(ThreadRecorder* recorder) { - llassert(gUIThreadRecorder != NULL); - return *gUIThreadRecorder; + sMasterThreadRecorder = recorder; +} + + +ThreadRecorder* get_master_thread_recorder() +{ + return sMasterThreadRecorder; } LLThreadLocalPointer& get_thread_recorder_ptr() diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index b5ed77416c..535f855200 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -92,13 +92,11 @@ namespace LLTrace }; - //FIXME: let user code set up thread recorder topology - extern ThreadRecorder* gUIThreadRecorder ; - - const LLThreadLocalPointer& get_thread_recorder(); - void set_thread_recorder(class ThreadRecorder*); - ThreadRecorder& getUIThreadRecorder(); + const LLThreadLocalPointer& get_thread_recorder(); + void set_thread_recorder(ThreadRecorder*); + void set_master_thread_recorder(ThreadRecorder*); + ThreadRecorder* get_master_thread_recorder(); } #endif // LL_LLTRACETHREADRECORDER_H diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 50df2ebe55..395e6a6cc5 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -50,7 +50,6 @@ LLMutex* LLImage::sMutex = NULL; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ; -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); //static void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) @@ -159,9 +158,8 @@ void LLImageBase::sanityCheck() void LLImageBase::deleteData() { FREE_MEM(sPrivatePoolp, mData) ; - memDisclaimAmount(mDataSize); + memDisclaimAmount(mDataSize) = 0; mData = NULL; - mDataSize = 0; } // virtual @@ -225,9 +223,7 @@ U8* LLImageBase::reallocateData(S32 size) FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; - memDisclaimAmount(mDataSize); - mDataSize = size; - memClaimAmount(mDataSize); + memClaimAmount(memDisclaimAmount(mDataSize) = size); return mData; } @@ -1612,9 +1608,8 @@ static void avg4_colors2(const U8* a, const U8* b, const U8* c, const U8* d, U8* void LLImageBase::setDataAndSize(U8 *data, S32 size) { ll_assert_aligned(data, 16); - memDisclaimAmount(mDataSize); - mData = data; mDataSize = size; - memClaimAmount(mDataSize); + mData = data; + memClaimAmount(memDisclaimAmount(mDataSize) = size); } //static diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 504b7e4795..b2bfdba3f8 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -165,8 +165,6 @@ public: static void destroyPrivatePool() ; static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;} - static LLTrace::MemStatHandle sMemStat; - private: U8 *mData; S32 mDataSize; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index b6f2694742..7d7e9e036e 100755 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,9 +44,6 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); - - LLImageBase::LLImageBase() : mData(NULL), mDataSize(0), @@ -115,17 +112,14 @@ namespace tut { // Instance to be tested LLImageDecodeThread* mThread; - // Constructor and destructor of the test wrapper imagedecodethread_test() { - LLTrace::init(); mThread = NULL; } ~imagedecodethread_test() { delete mThread; - LLTrace::cleanup(); } }; @@ -143,7 +137,6 @@ namespace tut imagerequest_test() { done = false; - LLTrace::init(); mRequest = new LLImageDecodeThread::ImageRequest(0, 0, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, @@ -154,7 +147,6 @@ namespace tut // We should delete the object *but*, because its destructor is protected, that cannot be // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine... //delete mRequest; - LLTrace::cleanup(); } }; diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 14fbf344ab..0e73f33e04 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -44,8 +44,6 @@ // End Stubbing // ------------------------------------------------------------------------------------------- // Stub the LL Image Classes -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); - LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } U8* LLImageRaw::allocateData(S32 ) { return NULL; } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d3cc2733e6..fd88565de4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -345,9 +345,9 @@ void LLStatBar::draw() else if (mSampleFloatp) { //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } else @@ -366,9 +366,9 @@ void LLStatBar::draw() } else if (mSampleFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 7243931dbb..9845941778 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -48,8 +48,6 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. -LLTrace::MemStatHandle LLTextSegment::sMemStat("LLTextSegment"); - LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 74dc7f9693..3e93b7de65 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -100,8 +100,6 @@ public: S32 getEnd() const { return mEnd; } void setEnd( S32 end ) { mEnd = end; } - static LLTrace::MemStatHandle sMemStat; - protected: S32 mStart; S32 mEnd; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index daeb4d7939..b2805a32e8 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -69,7 +69,6 @@ LLView* LLView::sPreviewClickedElement = NULL; BOOL LLView::sDrawPreviewHighlights = FALSE; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; -LLTrace::MemStatHandle LLView::sMemStat("LLView"); std::vector LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 0568fa889a..62bfb54566 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -675,7 +675,6 @@ public: static S32 sLastLeftXML; static S32 sLastBottomXML; static BOOL sForceReshape; - static LLTrace::MemStatHandle sMemStat; }; namespace LLInitParam diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index 901260bec8..dff0dcb2fd 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -35,8 +35,6 @@ // external library headers // other Linden headers -LLTrace::MemStatHandle LLViewModel::sMemStat("LLViewModel"); - /// LLViewModel::LLViewModel() : mDirty(false) diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index 2c016d2560..a2ca20c739 100755 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -83,8 +83,6 @@ public: // void setDirty() { mDirty = true; } - static LLTrace::MemStatHandle sMemStat; - protected: LLSD mValue; bool mDirty; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 348eb43b5e..e77f793a43 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1297,7 +1297,7 @@ bool LLAppViewer::mainLoop() LLTrace::get_frame_recording().nextPeriod(); LLTrace::TimeBlock::logStats(); - LLTrace::getUIThreadRecorder().pullFromChildren(); + LLTrace::get_master_thread_recorder()->pullFromChildren(); //clear call stack records llclearcallstacks; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 628f7f7bfb..3dddf4b554 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -59,7 +59,6 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f; static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); extern bool gShiftFrame; -LLTrace::MemStatHandle LLDrawable::sMemStat("LLDrawable"); //////////////////////// diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index b7c5aeb5a8..4558597d89 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -293,7 +293,6 @@ public: F32 mDistanceWRTCamera; static F32 sCurPixelAngle; //current pixels per radian - static LLTrace::MemStatHandle sMemStat; private: typedef std::vector face_list_t; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7a5e1dcad0..d922659435 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -430,18 +430,18 @@ void LLFastTimerView::draw() } void LLFastTimerView::onOpen(const LLSD& key) - { +{ setPauseState(false); mRecording.reset(); mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); for(std::deque::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end(); it != end_it; - ++it) - { + ++it) + { delete []it->mBars; it->mBars = NULL; - } - } + } +} void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e514ddfd1..c633e3acdd 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -114,8 +114,6 @@ BOOL LLViewerObject::sMapDebug = TRUE; LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit S32 LLViewerObject::sAxisArrowLength(50); -LLTrace::MemStatHandle LLViewerObject::sMemStat("LLViewerObject"); - BOOL LLViewerObject::sPulseEnabled(FALSE); BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5556a4c7d3..63da7152b3 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -661,7 +661,6 @@ public: LLPointer mIcon; static BOOL sUseSharedDrawables; - static LLTrace::MemStatHandle sMemStat; protected: // delete an item in the inventory, but don't tell the diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 60d78890b5..d87eb5d3db 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,8 +34,6 @@ #include "llviewerregion.h" #include "pipeline.h" -LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); - BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { return apr_file->read(src, n_bytes) == n_bytes ; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index bf75cafac5..c43c42908f 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -35,7 +35,6 @@ //--------------------------------------------------------------------------- // Cache entries -class LLVOCacheEntry; class LLCamera; class LLVOCacheEntry : public LLViewerOctreeEntryData @@ -158,8 +157,6 @@ public: /*virtual*/ S32 cull(LLCamera &camera); void addOccluders(LLviewerOctreeGroup* gp); - static LLTrace::MemStatHandle sMemStat; - private: void processOccluders(LLCamera* camera, const LLVector3* region_agent); diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index b9712e5e9c..bd42b59df2 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -35,6 +35,7 @@ #include "lluuid.h" #include "llsdutil.h" #include "llregionhandle.h" +#include "lltracethreadrecorder.h" #include "../llvoavatar.h" namespace LLStatViewer @@ -231,14 +232,15 @@ namespace tut { tst_viewerassetstats_index() { - LLTrace::init(); + LLTrace::set_master_thread_recorder(&mThreadRecorder); } ~tst_viewerassetstats_index() { - LLTrace::cleanup(); + LLTrace::set_master_thread_recorder(NULL); } + LLTrace::ThreadRecorder mThreadRecorder; }; typedef test_group tst_viewerassetstats_index_t; typedef tst_viewerassetstats_index_t::object tst_viewerassetstats_index_object_t; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 28de88201c..10f71a2843 100755 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -41,6 +41,7 @@ #include "stringize.h" #include "namedtempfile.h" #include "lltrace.h" +#include "lltracethreadrecorder.h" #include "apr_pools.h" #include "apr_getopt.h" @@ -483,6 +484,8 @@ void wouldHaveCrashed(const std::string& message) tut::fail("llerrs message: " + message); } +static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; + int main(int argc, char **argv) { // The following line must be executed to initialize Google Mock @@ -515,7 +518,11 @@ int main(int argc, char **argv) ll_init_apr(); - LLTrace::init(); + if (!sMasterThreadRecorder) + { + sMasterThreadRecorder = new LLTrace::ThreadRecorder(); + LLTrace::set_master_thread_recorder(sMasterThreadRecorder); + } apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { -- cgit v1.3 From 8208a40412fac35593d4b8b13f43c6be5e4d6990 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 1 Jul 2013 18:50:51 -0700 Subject: BUILDFIX: reverted changes that attempted to automate mem track stat definition as they don't work on gcc/clang --- indra/llcommon/lltrace.h | 22 ++++++++-------------- indra/llimage/llimage.cpp | 1 + indra/llimage/llimage.h | 2 ++ indra/llimage/tests/llimageworker_test.cpp | 3 +++ indra/llkdu/tests/llimagej2ckdu_test.cpp | 2 ++ indra/llui/lltextbase.cpp | 2 ++ indra/llui/lltextbase.h | 2 ++ indra/llui/llview.cpp | 1 + indra/llui/llview.h | 1 + indra/llui/llviewmodel.cpp | 2 ++ indra/llui/llviewmodel.h | 2 ++ indra/newview/lldrawable.cpp | 1 + indra/newview/lldrawable.h | 1 + indra/newview/llviewerobject.cpp | 2 ++ indra/newview/llviewerobject.h | 1 + indra/newview/llvocache.cpp | 2 ++ indra/newview/llvocache.h | 2 ++ 17 files changed, 35 insertions(+), 14 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1cde450dc2..e2c4b63276 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -336,7 +336,7 @@ public: void* operator new(size_t size) { - MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -348,7 +348,7 @@ public: void operator delete(void* ptr, size_t size) { - MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -360,7 +360,7 @@ public: void *operator new [](size_t size) { - MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -372,7 +372,7 @@ public: void operator delete[](void* ptr, size_t size) { - MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -438,15 +438,13 @@ public: private: size_t mMemFootprint; - static MemStatHandle sMemStat; - template struct TrackMemImpl { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -457,7 +455,7 @@ private: static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -472,7 +470,7 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked)); @@ -481,7 +479,7 @@ private: static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked)); @@ -490,9 +488,5 @@ private: }; }; -template -MemStatHandle MemTrackable::sMemStat(typeid(DERIVED).name()); - - } #endif // LL_LLTRACE_H diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 395e6a6cc5..8477e62db7 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -50,6 +50,7 @@ LLMutex* LLImage::sMutex = NULL; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ; +LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); //static void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index b2bfdba3f8..504b7e4795 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -165,6 +165,8 @@ public: static void destroyPrivatePool() ; static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;} + static LLTrace::MemStatHandle sMemStat; + private: U8 *mData; S32 mDataSize; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 7d7e9e036e..aba7883974 100755 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,6 +44,9 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. +LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); + + LLImageBase::LLImageBase() : mData(NULL), mDataSize(0), diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 0e73f33e04..14fbf344ab 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -44,6 +44,8 @@ // End Stubbing // ------------------------------------------------------------------------------------------- // Stub the LL Image Classes +LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); + LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } U8* LLImageRaw::allocateData(S32 ) { return NULL; } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 9845941778..7243931dbb 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -48,6 +48,8 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. +LLTrace::MemStatHandle LLTextSegment::sMemStat("LLTextSegment"); + LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 3e93b7de65..74dc7f9693 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -100,6 +100,8 @@ public: S32 getEnd() const { return mEnd; } void setEnd( S32 end ) { mEnd = end; } + static LLTrace::MemStatHandle sMemStat; + protected: S32 mStart; S32 mEnd; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index b2805a32e8..daeb4d7939 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -69,6 +69,7 @@ LLView* LLView::sPreviewClickedElement = NULL; BOOL LLView::sDrawPreviewHighlights = FALSE; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; +LLTrace::MemStatHandle LLView::sMemStat("LLView"); std::vector LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 62bfb54566..0568fa889a 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -675,6 +675,7 @@ public: static S32 sLastLeftXML; static S32 sLastBottomXML; static BOOL sForceReshape; + static LLTrace::MemStatHandle sMemStat; }; namespace LLInitParam diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index dff0dcb2fd..901260bec8 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -35,6 +35,8 @@ // external library headers // other Linden headers +LLTrace::MemStatHandle LLViewModel::sMemStat("LLViewModel"); + /// LLViewModel::LLViewModel() : mDirty(false) diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index a2ca20c739..2c016d2560 100755 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -83,6 +83,8 @@ public: // void setDirty() { mDirty = true; } + static LLTrace::MemStatHandle sMemStat; + protected: LLSD mValue; bool mDirty; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 3dddf4b554..628f7f7bfb 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -59,6 +59,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f; static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); extern bool gShiftFrame; +LLTrace::MemStatHandle LLDrawable::sMemStat("LLDrawable"); //////////////////////// diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 4558597d89..b7c5aeb5a8 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -293,6 +293,7 @@ public: F32 mDistanceWRTCamera; static F32 sCurPixelAngle; //current pixels per radian + static LLTrace::MemStatHandle sMemStat; private: typedef std::vector face_list_t; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index c633e3acdd..4e514ddfd1 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -114,6 +114,8 @@ BOOL LLViewerObject::sMapDebug = TRUE; LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit S32 LLViewerObject::sAxisArrowLength(50); +LLTrace::MemStatHandle LLViewerObject::sMemStat("LLViewerObject"); + BOOL LLViewerObject::sPulseEnabled(FALSE); BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 63da7152b3..5556a4c7d3 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -661,6 +661,7 @@ public: LLPointer mIcon; static BOOL sUseSharedDrawables; + static LLTrace::MemStatHandle sMemStat; protected: // delete an item in the inventory, but don't tell the diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index d87eb5d3db..60d78890b5 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,6 +34,8 @@ #include "llviewerregion.h" #include "pipeline.h" +LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); + BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { return apr_file->read(src, n_bytes) == n_bytes ; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index c43c42908f..c42374e154 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -157,6 +157,8 @@ public: /*virtual*/ S32 cull(LLCamera &camera); void addOccluders(LLviewerOctreeGroup* gp); + static LLTrace::MemStatHandle sMemStat; + private: void processOccluders(LLCamera* camera, const LLVector3* region_agent); -- cgit v1.3 From e4cacda5a0cf3918bdc8091997b988235e9d4f3d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 5 Sep 2013 16:24:57 -0700 Subject: BUILDFIX: unit tests still using old sMemStat declarations --- indra/llimage/tests/llimageworker_test.cpp | 2 +- indra/llkdu/tests/llimagej2ckdu_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index aba7883974..8c9fefca90 100755 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,7 +44,7 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); +//LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); LLImageBase::LLImageBase() diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 14fbf344ab..4f597f4848 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -44,7 +44,7 @@ // End Stubbing // ------------------------------------------------------------------------------------------- // Stub the LL Image Classes -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); +//LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } -- cgit v1.3 From 9bae912308a75cc1ceaec49d28b50f7119ec02ba Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 1 Oct 2013 17:18:35 -0700 Subject: BUILDFIX: old style fast timer use, broken unit test --- indra/llimage/tests/llimageworker_test.cpp | 6 ++---- indra/newview/llscenemonitor.cpp | 4 ++-- indra/newview/pipeline.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'indra/llimage/tests') diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 8c9fefca90..c030b105fb 100755 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,11 +44,9 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -//LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); - - LLImageBase::LLImageBase() -: mData(NULL), +: LLTrace::MemTrackable("LLImageBase"), +mData(NULL), mDataSize(0), mWidth(0), mHeight(0), diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 429d6a9258..c1ebd1f435 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -202,7 +202,7 @@ LLRenderTarget& LLSceneMonitor::getCaptureTarget() if(cur_target->getWidth() != width || cur_target->getHeight() != height) //size changed { - cur_target->resize(width, height, GL_RGB); + cur_target->resize(width, height); } // we're promising the target exists @@ -366,7 +366,7 @@ void LLSceneMonitor::compare() else if(mDiff->getWidth() != width || mDiff->getHeight() != height) { LL_RECORD_BLOCK_TIME(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE); - mDiff->resize(width, height, GL_RGBA); + mDiff->resize(width, height); generateDitheringTexture(width, height); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1804f6eb64..52e9585029 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9046,7 +9046,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) } { - LLFastTimer ftm(FTM_RENDER_DEFERRED); + LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); LLViewerCamera* camera = LLViewerCamera::getInstance(); @@ -9103,7 +9103,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) { mDeferredLight.bindTarget(); { //paint shadow/SSAO light map (direct lighting lightmap) - LLFastTimer ftm(FTM_SUN_SHADOW); + LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW); bindDeferredShader(gDeferredSunProgram); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); glClearColor(1,1,1,1); @@ -9161,7 +9161,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) if (RenderDeferredAtmospheric) { //apply sunlight contribution - LLFastTimer ftm(FTM_ATMOSPHERICS); + LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); bindDeferredShader(gDeferredSoftenProgram); { LLGLDepthTest depth(GL_FALSE); @@ -9298,7 +9298,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) col.mV[1] = powf(col.mV[1], 2.2f); col.mV[2] = powf(col.mV[2], 2.2f);*/ - LLFastTimer ftm(FTM_LOCAL_LIGHTS); + LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS); gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); @@ -9339,7 +9339,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) { - LLFastTimer ftm(FTM_PROJECTORS); + LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); LLDrawable* drawablep = *iter; LLVOVolume* volume = drawablep->getVOVolume(); @@ -9396,7 +9396,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) while (!fullscreen_lights.empty()) { - LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS); + LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS); light[count] = fullscreen_lights.front(); fullscreen_lights.pop_front(); col[count] = light_colors.front(); @@ -9434,7 +9434,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { - LLFastTimer ftm(FTM_PROJECTORS); + LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); LLDrawable* drawablep = *iter; LLVOVolume* volume = drawablep->getVOVolume(); -- cgit v1.3