summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapr.h12
-rw-r--r--indra/llcommon/lldate.cpp1
-rw-r--r--indra/llcommon/llfasttimer.cpp120
-rw-r--r--indra/llcommon/llfasttimer.h165
-rw-r--r--indra/llcommon/llfile.cpp2
-rw-r--r--indra/llcommon/llfindlocale.cpp2
-rw-r--r--indra/llcommon/llinitparam.cpp1
-rw-r--r--indra/llcommon/llinitparam.h1
-rw-r--r--indra/llcommon/llmemory.cpp1
-rw-r--r--indra/llcommon/llmetricperformancetester.cpp6
-rw-r--r--indra/llcommon/llmortician.h1
-rw-r--r--indra/llcommon/llprocess.h3
-rw-r--r--indra/llcommon/llprocessor.cpp4
-rw-r--r--indra/llcommon/llsdparam.h1
-rw-r--r--indra/llcommon/llstacktrace.cpp2
-rw-r--r--indra/llcommon/llstring.cpp5
-rw-r--r--indra/llcommon/llstring.h3
-rw-r--r--indra/llcommon/llsys.cpp5
-rw-r--r--indra/llcommon/lltimer.cpp6
-rw-r--r--indra/llcommon/lltrace.cpp6
-rw-r--r--indra/llcommon/lltrace.h22
-rw-r--r--indra/llcommon/lltracerecording.h8
-rw-r--r--indra/llcommon/lltracethreadrecorder.cpp1
-rw-r--r--indra/llcommon/llunit.h9
-rw-r--r--indra/llcommon/lluuid.cpp4
-rw-r--r--indra/llcommon/llwin32headers.h38
-rw-r--r--indra/llcommon/llwin32headerslean.h37
27 files changed, 266 insertions, 200 deletions
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index 510725ffc6..c77d96c1c9 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -32,16 +32,6 @@
#if LL_LINUX || LL_SOLARIS
#include <sys/param.h> // Need PATH_MAX in APR headers...
#endif
-#if LL_WINDOWS
- // Limit Windows API to small and manageable set.
- // If you get undefined symbols, find the appropriate
- // Windows header file and include that in your .cpp file.
- #define WIN32_LEAN_AND_MEAN
- #include <winsock2.h>
- #include <windows.h>
- #undef min
- #undef max
-#endif
#include <boost/noncopyable.hpp>
@@ -340,7 +330,7 @@ public:
LLThreadLocalPointer(const LLThreadLocalPointer<T>& other)
- : LLThreadLocalPointerBase(other)
+ : LLThreadLocalPointerBase(other)
{
set(other.get());
}
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp
index 5569b4102d..2efe39e158 100644
--- a/indra/llcommon/lldate.cpp
+++ b/indra/llcommon/lldate.cpp
@@ -39,6 +39,7 @@
#include "lltimer.h"
#include "llstring.h"
+#include "llfasttimer.h"
static const F64 DATE_EPOCH = 0.0;
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index cced0bdfa9..d007f76e5f 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -58,22 +58,22 @@ namespace LLTrace
//////////////////////////////////////////////////////////////////////////////
// statics
-S32 Time::sCurFrameIndex = -1;
-S32 Time::sLastFrameIndex = -1;
-U64 Time::sLastFrameTime = Time::getCPUClockCount64();
-bool Time::sPauseHistory = 0;
-bool Time::sResetHistory = 0;
-LLThreadLocalPointer<Time::CurTimerData> Time::sCurTimerData;
-bool Time::sLog = FALSE;
-std::string Time::sLogName = "";
-bool Time::sMetricLog = FALSE;
+S32 BlockTimer::sCurFrameIndex = -1;
+S32 BlockTimer::sLastFrameIndex = -1;
+U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64();
+bool BlockTimer::sPauseHistory = 0;
+bool BlockTimer::sResetHistory = 0;
+LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData;
+bool BlockTimer::sLog = false;
+std::string BlockTimer::sLogName = "";
+bool BlockTimer::sMetricLog = false;
static LLMutex* sLogLock = NULL;
static std::queue<LLSD> sLogQueue;
#if LL_LINUX || LL_SOLARIS
-U64 Time::sClockResolution = 1000000000; // Nanosecond resolution
+U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution
#else
-U64 Time::sClockResolution = 1000000; // Microsecond resolution
+U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution
#endif
// FIXME: move these declarations to the relevant modules
@@ -114,15 +114,22 @@ BlockTimer& BlockTimer::getRootTimer()
return root_timer;
}
+void BlockTimer::pushLog(LLSD log)
+{
+ LLMutexLock lock(sLogLock);
+
+ sLogQueue.push(log);
+}
+
//static
#if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__))
-U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
+U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
{
return sClockResolution >> 8;
}
#else // windows or x86-mac or x86-linux or x86-solaris
-U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
+U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
{
#if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS
//getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
@@ -225,7 +232,7 @@ S32 BlockTimer::getDepth()
// static
void BlockTimer::processTimes()
{
- if (Time::getCurFrameIndex() < 0) return;
+ if (getCurFrameIndex() < 0) return;
buildHierarchy();
accumulateTimings();
@@ -243,7 +250,7 @@ struct SortTimerByName
//static
void BlockTimer::buildHierarchy()
{
- if (Time::getCurFrameIndex() < 0 ) return;
+ if (getCurFrameIndex() < 0 ) return;
// set up initial tree
{
@@ -254,11 +261,11 @@ void BlockTimer::buildHierarchy()
// bootstrap tree construction by attaching to last timer to be on stack
// when this timer was called
- if (timer.mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
+ if (timer.getPrimaryAccumulator().mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
{
- timer.setParent(timer.mLastCaller);
+ timer.setParent(timer.getPrimaryAccumulator().mLastCaller);
// no need to push up tree on first use, flag can be set spuriously
- timer.mMoveUpTree = false;
+ timer.getPrimaryAccumulator().mMoveUpTree = false;
}
}
}
@@ -274,14 +281,14 @@ void BlockTimer::buildHierarchy()
// skip root timer
if (timerp == &BlockTimer::getRootTimer()) continue;
- if (timerp->mMoveUpTree)
+ if (timerp->getPrimaryAccumulator().mMoveUpTree)
{
- // since ancestors have already been visited, reparenting won't affect tree traversal
+ // since ancestors have already been visited, re-parenting won't affect tree traversal
//step up tree, bringing our descendants with us
LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() <<
" to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL;
timerp->setParent(timerp->getParent()->getParent());
- timerp->mMoveUpTree = false;
+ timerp->getPrimaryAccumulator().mMoveUpTree = false;
// don't bubble up any ancestors until descendants are done bubbling up
it.skipAncestors();
@@ -308,21 +315,23 @@ void BlockTimer::accumulateTimings()
U32 cur_time = getCPUClockCount32();
// walk up stack of active timers and accumulate current time while leaving timing structures active
- Time* cur_timer = sCurTimerData.mCurTimer;
+ Time* cur_timer = sCurTimerData->mCurTimer;
// root defined by parent pointing to self
- CurTimerData* cur_data = &sCurTimerData;
+ CurTimerData* cur_data = sCurTimerData.get();
+ TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator();
while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
{
U32 cumulative_time_delta = cur_time - cur_timer->mStartTime;
U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime;
cur_data->mChildTime = 0;
- cur_data->mTimerData->mSelfTimeCounter += self_time_delta;
- cur_data->mTimerData->mTotalTimeCounter += cumulative_time_delta;
+ accumulator.mSelfTimeCounter += self_time_delta;
+ accumulator.mTotalTimeCounter += cumulative_time_delta;
cur_timer->mStartTime = cur_time;
cur_data = &cur_timer->mLastTimerData;
cur_data->mChildTime += cumulative_time_delta;
+ accumulator = cur_data->mTimerData->getPrimaryAccumulator();
cur_timer = cur_timer->mLastTimerData.mCurTimer;
}
@@ -333,13 +342,14 @@ void BlockTimer::accumulateTimings()
++it)
{
BlockTimer* timerp = (*it);
- timerp->mTreeTimeCounter = timerp->mSelfTimeCounter;
+ TimerAccumulator& accumulator = timerp->getPrimaryAccumulator();
+ timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter;
for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it)
{
timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter;
}
- S32 cur_frame = sCurFrameIndex;
+ S32 cur_frame = getCurFrameIndex();
if (cur_frame >= 0)
{
// update timer history
@@ -347,8 +357,8 @@ void BlockTimer::accumulateTimings()
timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter;
timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1);
- timerp->mCallHistory[hidx] = timerp->mCalls;
- timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->mCalls) / (cur_frame+1);
+ timerp->mCallHistory[hidx] = accumulator.mCalls;
+ timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1);
}
}
}
@@ -377,15 +387,19 @@ void BlockTimer::resetFrame()
LLSD sd;
{
- for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+ for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
+ end_it = LLInstanceTracker<BlockTimer>::endInstances();
+ it != end_it;
+ ++it)
{
BlockTimer& timer = *it;
- sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq);
- sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls;
+ TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
+ sd[timer.getName()]["Time"] = (LLSD::Real) (accumulator.mSelfTimeCounter*iclock_freq);
+ sd[timer.getName()]["Calls"] = (LLSD::Integer) accumulator.mCalls;
// computing total time here because getting the root timer's getCountHistory
// doesn't work correctly on the first frame
- total_time = total_time + timer.mSelfTimeCounter * iclock_freq;
+ total_time = total_time + accumulator.mSelfTimeCounter * iclock_freq;
}
}
@@ -399,13 +413,17 @@ void BlockTimer::resetFrame()
}
// reset for next frame
- for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+ for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
+ end_it = LLInstanceTracker<BlockTimer>::endInstances();
+ it != end_it;
+ ++it)
{
BlockTimer& timer = *it;
- timer.mSelfTimeCounter = 0;
- timer.mCalls = 0;
- timer.mLastCaller = NULL;
- timer.mMoveUpTree = false;
+ TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
+ accumulator.mSelfTimeCounter = 0;
+ accumulator.mCalls = 0;
+ accumulator.mLastCaller = NULL;
+ accumulator.mMoveUpTree = false;
}
}
@@ -419,7 +437,7 @@ void BlockTimer::reset()
U32 cur_time = getCPUClockCount32();
// root defined by parent pointing to self
- CurTimerData* cur_data = &sCurTimerData;
+ CurTimerData* cur_data = sCurTimerData.get();
Time* cur_timer = cur_data->mCurTimer;
while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
{
@@ -432,7 +450,10 @@ void BlockTimer::reset()
// reset all history
{
- for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+ for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
+ end_it = LLInstanceTracker<BlockTimer>::endInstances();
+ it != end_it;
+ ++it)
{
BlockTimer& timer = *it;
if (&timer != &BlockTimer::getRootTimer())
@@ -453,13 +474,13 @@ void BlockTimer::reset()
U32 BlockTimer::getHistoricalCount(S32 history_index) const
{
- S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
+ S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
return mCountHistory[history_idx];
}
U32 BlockTimer::getHistoricalCalls(S32 history_index ) const
{
- S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
+ S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
return mCallHistory[history_idx];
}
@@ -479,10 +500,10 @@ std::vector<BlockTimer*>& BlockTimer::getChildren()
}
//static
-void Time::nextFrame()
+void BlockTimer::nextFrame()
{
- countsPerSecond(); // good place to calculate clock frequency
- U64 frame_time = getCPUClockCount64();
+ BlockTimer::countsPerSecond(); // good place to calculate clock frequency
+ U64 frame_time = BlockTimer::getCPUClockCount64();
if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff)
{
llinfos << "Slow frame, fast timers inaccurate" << llendl;
@@ -505,7 +526,7 @@ void Time::dumpCurTimes()
// accumulate timings, etc.
BlockTimer::processTimes();
- F64 clock_freq = (F64)countsPerSecond();
+ F64 clock_freq = (F64)BlockTimer::countsPerSecond();
F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds
// walk over timers in depth order and output timings
@@ -533,13 +554,6 @@ void Time::dumpCurTimes()
}
}
-//static
-void Time::reset()
-{
- BlockTimer::reset();
-}
-
-
//static
void Time::writeLog(std::ostream& os)
{
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index f5e6d874a2..69a6773b12 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -28,60 +28,77 @@
#define LL_FASTTIMER_H
#include "llinstancetracker.h"
+#include "lltrace.h"
#define FAST_TIMER_ON 1
+#define LL_FASTTIMER_USE_RDTSC 1
class LLMutex;
-#include "lltrace.h"
-
-#define LL_FASTTIMER_USE_RDTSC 1
-
namespace LLTrace
{
+struct CurTimerData
+{
+ class Time* mCurTimer;
+ class BlockTimer* mTimerData;
+ U64 mChildTime;
+};
class Time
{
public:
+ friend class BlockTimer;
typedef Time self_t;
typedef class BlockTimer DeclareTimer;
-public:
Time(BlockTimer& timer);
~Time();
public:
- static bool sLog;
- static bool sMetricLog;
- static std::string sLogName;
- static bool sPauseHistory;
- static bool sResetHistory;
-
- // call this once a frame to reset timers
- static void nextFrame();
-
// dumps current cumulative frame stats to log
// call nextFrame() to reset timers
static void dumpCurTimes();
- // call this to reset timer hierarchy, averages, etc.
- static void reset();
+ static void writeLog(std::ostream& os);
- static U64 countsPerSecond();
- static S32 getLastFrameIndex() { return sLastFrameIndex; }
- static S32 getCurFrameIndex() { return sCurFrameIndex; }
+private:
- static void writeLog(std::ostream& os);
+ U64 mStartTime;
+ CurTimerData mLastTimerData;
+};
- struct CurTimerData
- {
- Time* mCurTimer;
- BlockTimer* mTimerData;
- U64 mChildTime;
- };
- static LLThreadLocalPointer<CurTimerData> sCurTimerData;
+// stores a "named" timer instance to be reused via multiple Time stack instances
+class BlockTimer
+: public TraceType<TimerAccumulator>,
+ public LLInstanceTracker<BlockTimer>
+{
+public:
+ BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
+ ~BlockTimer();
-private:
+ enum { HISTORY_NUM = 300 };
+
+ BlockTimer* getParent() const { return mParent; }
+ void setParent(BlockTimer* parent);
+ S32 getDepth();
+
+ typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
+ child_const_iter beginChildren();
+ child_const_iter endChildren();
+ std::vector<BlockTimer*>& getChildren();
+
+ void setCollapsed(bool collapsed) { mCollapsed = collapsed; }
+ bool getCollapsed() const { return mCollapsed; }
+
+ U32 getCountAverage() const { return mCountAverage; }
+ U32 getCallAverage() const { return mCallAverage; }
+
+ U32 getHistoricalCount(S32 history_index = 0) const;
+ U32 getHistoricalCalls(S32 history_index = 0) const;
+
+ static BlockTimer& getRootTimer();
+ static void pushLog(LLSD sd);
+ friend class Time;
//////////////////////////////////////////////////////////////////////////////
@@ -106,14 +123,14 @@ private:
//#undef _interlockedbittestandset
//#undef _interlockedbittestandreset
- //inline U32 Time::getCPUClockCount32()
+ //inline U32 BlockTimer::getCPUClockCount32()
//{
// U64 time_stamp = __rdtsc();
// return (U32)(time_stamp >> 8);
//}
//
//// return full timer value, *not* shifted by 8 bits
- //inline U64 Time::getCPUClockCount64()
+ //inline U64 BlockTimer::getCPUClockCount64()
//{
// return __rdtsc();
//}
@@ -220,64 +237,7 @@ private:
#endif
- static U64 sClockResolution;
- static S32 sCurFrameIndex;
- static S32 sLastFrameIndex;
- static U64 sLastFrameTime;
-
- U64 mStartTime;
- Time::CurTimerData mLastTimerData;
-};
-
-struct TimerAccumulator
-{
- void addSamples(const TimerAccumulator& other);
- void reset(const TimerAccumulator* other);
-
- //
- // members
- //
- U64 mSelfTimeCounter,
- mTotalTimeCounter;
- U32 mCalls;
- BlockTimer* mLastCaller; // used to bootstrap tree construction
- U16 mActiveCount; // number of timers with this ID active on stack
- bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame
-};
-
-// stores a "named" timer instance to be reused via multiple Time stack instances
-class BlockTimer
-: public TraceType<TimerAccumulator>,
- public LLInstanceTracker<BlockTimer>
-{
-public:
- BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
- ~BlockTimer();
-
- enum { HISTORY_NUM = 300 };
-
- BlockTimer* getParent() const { return mParent; }
- void setParent(BlockTimer* parent);
- S32 getDepth();
-
- typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
- child_const_iter beginChildren();
- child_const_iter endChildren();
- std::vector<BlockTimer*>& getChildren();
-
- void setCollapsed(bool collapsed) { mCollapsed = collapsed; }
- bool getCollapsed() const { return mCollapsed; }
-
- U32 getCountAverage() const { return mCountAverage; }
- U32 getCallAverage() const { return mCallAverage; }
-
- U32 getHistoricalCount(S32 history_index = 0) const;
- U32 getHistoricalCalls(S32 history_index = 0) const;
-
- static BlockTimer& getRootTimer();
-
-private:
- friend class Time;
+ static U64 countsPerSecond();
// recursive call to gather total time from children
static void accumulateTimings();
@@ -289,6 +249,12 @@ private:
static void buildHierarchy();
static void resetFrame();
static void reset();
+ // call this once a frame to reset timers
+ static void nextFrame();
+ static S32 getLastFrameIndex() { return sLastFrameIndex; }
+ static S32 getCurFrameIndex() { return sCurFrameIndex; }
+
+
// sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete
U32 mTreeTimeCounter;
@@ -304,12 +270,25 @@ private:
std::vector<BlockTimer*> mChildren;
bool mCollapsed; // don't show children
bool mNeedsSorting; // sort children whenever child added
+
+ // statics
+ static std::string sLogName;
+ static bool sMetricLog;
+ static bool sLog;
+ static LLThreadLocalPointer<CurTimerData> sCurTimerData;
+ static U64 sClockResolution;
+ static S32 sCurFrameIndex;
+ static S32 sLastFrameIndex;
+ static U64 sLastFrameTime;
+ static bool sPauseHistory;
+ static bool sResetHistory;
+
};
LL_FORCE_INLINE Time::Time(BlockTimer& timer)
{
#if FAST_TIMER_ON
- mStartTime = getCPUClockCount64();
+ mStartTime = BlockTimer::getCPUClockCount64();
TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
accumulator.mActiveCount++;
@@ -317,7 +296,7 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
// keep current parent as long as it is active when we are
accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0);
- CurTimerData* cur_timer_data = Time::sCurTimerData.get();
+ CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
// store top of stack
mLastTimerData = *cur_timer_data;
// push new information
@@ -330,8 +309,8 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
LL_FORCE_INLINE Time::~Time()
{
#if FAST_TIMER_ON
- U64 total_time = getCPUClockCount64() - mStartTime;
- CurTimerData* cur_timer_data = Time::sCurTimerData.get();
+ U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime;
+ CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator();
accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime;
accumulator.mTotalTimeCounter += total_time;
@@ -344,7 +323,7 @@ LL_FORCE_INLINE Time::~Time()
// we are only tracking self time, so subtract our total time delta from parents
mLastTimerData.mChildTime += total_time;
- *sCurTimerData = mLastTimerData;
+ *BlockTimer::sCurTimerData = mLastTimerData;
#endif
}
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index c51d042a3d..5917d7a420 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -28,7 +28,7 @@
*/
#if LL_WINDOWS
-#include <windows.h>
+#include "llwin32headerslean.h"
#include <stdlib.h> // Windows errno
#else
#include <errno.h>
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index cd7c0c7c09..f019bd0c64 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -33,7 +33,7 @@
#include <ctype.h>
#ifdef WIN32
-#include <windows.h>
+#include "llwin32headers.h"
#include <winnt.h>
#endif
diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp
index 32d4eec607..d72e10d2fa 100644
--- a/indra/llcommon/llinitparam.cpp
+++ b/indra/llcommon/llinitparam.cpp
@@ -28,6 +28,7 @@
#include "linden_common.h"
#include "llinitparam.h"
+#include "llformat.h"
namespace LLInitParam
diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h
index 3d4e4331c0..502f93cbb8 100644
--- a/indra/llcommon/llinitparam.h
+++ b/indra/llcommon/llinitparam.h
@@ -29,6 +29,7 @@
#define LL_LLPARAM_H
#include <vector>
+#include <list>
#include <boost/function.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/unordered_map.hpp>
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index afaf366668..7c4ab6cf98 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -32,7 +32,6 @@
//#endif
#if defined(LL_WINDOWS)
-//# include <windows.h>
# include <psapi.h>
#elif defined(LL_DARWIN)
# include <sys/types.h>
diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp
index a1b0a684c5..43d98be47b 100644
--- a/indra/llcommon/llmetricperformancetester.cpp
+++ b/indra/llcommon/llmetricperformancetester.cpp
@@ -31,6 +31,7 @@
#include "llsdserialize.h"
#include "lltreeiterators.h"
#include "llmetricperformancetester.h"
+#include "llfasttimer.h"
//----------------------------------------------------------------------------------------------
// LLMetricPerformanceTesterBasic : static methods and testers management
@@ -90,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s
// Return TRUE if this metric is requested or if the general default "catch all" metric is requested
BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name)
{
- return (LLFastTimer::sMetricLog && ((LLFastTimer::sLogName == name) || (LLFastTimer::sLogName == DEFAULT_METRIC_NAME)));
+ return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME)));
}
/*static*/
@@ -193,8 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd)
void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd)
{
- LLMutexLock lock(LLFastTimer::sLogLock);
- LLFastTimer::sLogQueue.push((*sd));
+ LLTrace::BlockTimer::pushLog(*sd);
}
void LLMetricPerformanceTesterBasic::outputTestResults()
diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h
index 319955ef93..9517e2db5e 100644
--- a/indra/llcommon/llmortician.h
+++ b/indra/llcommon/llmortician.h
@@ -28,6 +28,7 @@
#define LLMORTICIAN_H
#include "stdtypes.h"
+#include <list>
class LL_COMMON_API LLMortician
{
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index d711ce2f74..2fe084afcd 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -38,8 +38,7 @@
#include <stdexcept>
#if LL_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h> // HANDLE (eye roll)
+#include "llwin32headerslean.h" // for HANDLE
#elif LL_LINUX
#if defined(Status)
#undef Status
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 87a5930c14..6fe53396ca 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -32,9 +32,7 @@
//#include <memory>
#if LL_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# include <winsock2.h>
-# include <windows.h>
+# include "llwin32headerslean.h"
# define _interlockedbittestandset _renamed_interlockedbittestandset
# define _interlockedbittestandreset _renamed_interlockedbittestandreset
# include <intrin.h>
diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h
index 1181c2d433..7cfc265c62 100644
--- a/indra/llcommon/llsdparam.h
+++ b/indra/llcommon/llsdparam.h
@@ -30,6 +30,7 @@
#include "llinitparam.h"
#include "boost/function.hpp"
+#include "llfasttimer.h"
struct LL_COMMON_API LLParamSDParserUtilities
{
diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp
index ccd7ef91c2..e0e9056380 100644
--- a/indra/llcommon/llstacktrace.cpp
+++ b/indra/llcommon/llstacktrace.cpp
@@ -32,7 +32,7 @@
#include <iostream>
#include <sstream>
-#include "windows.h"
+#include "llwin32headerslean.h"
#include "Dbghelp.h"
typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index fa0eb9f72c..9600928ad5 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -28,11 +28,10 @@
#include "llstring.h"
#include "llerror.h"
+#include "llfasttimer.h"
#if LL_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
+#include "llwin32headerslean.h"
#include <winnls.h> // for WideCharToMultiByte
#endif
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 119efc7957..9d81ac25dd 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -31,8 +31,9 @@
#include <cstdio>
#include <locale>
#include <iomanip>
+#include <algorithm>
#include "llsd.h"
-#include "llfasttimer.h"
+#include "llformat.h"
#if LL_LINUX || LL_SOLARIS
#include <wctype.h>
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 6073bcd0a6..00b72ce1d8 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -42,6 +42,7 @@
#include "llprocessor.h"
#include "llerrorcontrol.h"
#include "llevents.h"
+#include "llformat.h"
#include "lltimer.h"
#include "llsdserialize.h"
#include "llsdutil.h"
@@ -58,9 +59,7 @@
using namespace llsd;
#if LL_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# include <winsock2.h>
-# include <windows.h>
+# include "llwin32headerslean.h"
# include <psapi.h> // GetPerformanceInfo() et al.
#elif LL_DARWIN
# include <errno.h>
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 23cebf4336..26063beff0 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -31,11 +31,9 @@
#include "u64.h"
#if LL_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# include <winsock2.h>
-# include <windows.h>
+# include "llwin32headerslean.h"
#elif LL_LINUX || LL_SOLARIS || LL_DARWIN
-# include <errno.h>
+# include <errno.h>
# include <sys/time.h>
#else
# error "architecture not supported"
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index afb175c398..9346aa7a45 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -38,15 +38,15 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL;
void init()
{
gMasterThreadRecorder = new MasterThreadRecorder();
- Time::sCurTimerData = new Time::CurTimerData();
+ BlockTimer::sCurTimerData = new CurTimerData();
}
void cleanup()
{
delete gMasterThreadRecorder;
gMasterThreadRecorder = NULL;
- delete Time::sCurTimerData.get();
- Time::sCurTimerData = NULL;
+ delete BlockTimer::sCurTimerData.get();
+ BlockTimer::sCurTimerData = NULL;
}
MasterThreadRecorder& getMasterThreadRecorder()
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index fb9dca5e84..61fed6e7b8 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -235,8 +235,8 @@ namespace LLTrace
MeasurementAccumulator()
: mSum(0),
- mMin(std::numeric_limits<T>::max()),
- mMax(std::numeric_limits<T>::min()),
+ mMin((std::numeric_limits<T>::max)()),
+ mMax((std::numeric_limits<T>::min)()),
mMean(0),
mVarianceSum(0),
mNumSamples(0),
@@ -380,6 +380,24 @@ namespace LLTrace
U32 mNumSamples;
};
+ class TimerAccumulator
+ {
+ public:
+ void addSamples(const TimerAccumulator& other);
+ void reset(const TimerAccumulator* other);
+
+ //
+ // members
+ //
+ U64 mSelfTimeCounter,
+ mTotalTimeCounter;
+ U32 mCalls;
+ class BlockTimer* mLastCaller; // used to bootstrap tree construction
+ U16 mActiveCount; // number of timers with this ID active on stack
+ bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame
+ };
+
+
template <typename T = F64>
class Measurement
: public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 4dcadfdf29..efc54d240f 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -273,7 +273,7 @@ namespace LLTrace
template <typename T>
typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const
{
- T min_val = std::numeric_limits<T>::max();
+ T min_val = (std::numeric_limits<T>::max)();
for (S32 i = 0; i < mNumPeriods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat));
@@ -284,7 +284,7 @@ namespace LLTrace
template <typename T>
F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const
{
- F64 min_val = std::numeric_limits<F64>::max();
+ F64 min_val = (std::numeric_limits<F64>::max)();
for (S32 i = 0; i < mNumPeriods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat));
@@ -295,7 +295,7 @@ namespace LLTrace
template <typename T>
T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const
{
- T max_val = std::numeric_limits<T>::min();
+ T max_val = (std::numeric_limits<T>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
@@ -306,7 +306,7 @@ namespace LLTrace
template <typename T>
F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const
{
- F64 max_val = std::numeric_limits<F64>::min();
+ F64 max_val = (std::numeric_limits<F64>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat));
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp
index 5a6ff14f97..0f111aab59 100644
--- a/indra/llcommon/lltracethreadrecorder.cpp
+++ b/indra/llcommon/lltracethreadrecorder.cpp
@@ -26,6 +26,7 @@
#include "linden_common.h"
#include "lltracethreadrecorder.h"
+#include "llfasttimer.h"
namespace LLTrace
{
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 4ac2197c11..1fe492fdce 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -33,18 +33,12 @@
namespace LLUnits
{
-template<typename T, typename IS_UNIT = void>
+template<typename T>
struct HighestPrecisionType
{
typedef T type_t;
};
-template<typename T>
-struct HighestPrecisionType<T, typename T::is_unit_tag_t>
-{
- typedef typename HighestPrecisionType<typename T::storage_t>::type_t type_t;
-};
-
template<> struct HighestPrecisionType<F32> { typedef F64 type_t; };
template<> struct HighestPrecisionType<S32> { typedef S64 type_t; };
template<> struct HighestPrecisionType<U32> { typedef S64 type_t; };
@@ -78,7 +72,6 @@ struct LLUnit
{
typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t;
typedef typename STORAGE_TYPE storage_t;
- typedef void is_unit_tag_t;
LLUnit(storage_t value = storage_t())
: mValue(value)
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index db8c9c85ab..83ed987d30 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -27,9 +27,7 @@
// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS
-#undef WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
+#include "llwin32headers.h"
// ugh, this is ugly. We need to straighten out our linking for this library
#pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h>
diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h
new file mode 100644
index 0000000000..80fd2e1768
--- /dev/null
+++ b/indra/llcommon/llwin32headers.h
@@ -0,0 +1,38 @@
+/**
+ * @file llwindows.h
+ * @brief sanitized include of windows header files
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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_LLWINDOWS_H
+#define LL_LLWINDOWS_H
+
+#ifdef LL_WINDOWS
+#define NOMINMAX
+#undef WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <windows.h>
+#undef NOMINMAX
+#endif
+
+#endif
diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h
new file mode 100644
index 0000000000..ab6e9c09e2
--- /dev/null
+++ b/indra/llcommon/llwin32headerslean.h
@@ -0,0 +1,37 @@
+/**
+ * @file llwindows.h
+ * @brief sanitized include of windows header files
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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_LLWINDOWS_H
+#define LL_LLWINDOWS_H
+
+#ifdef LL_WINDOWS
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#endif