diff options
author | Richard Linden <none@none> | 2013-09-07 21:54:03 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-09-07 21:54:03 -0700 |
commit | c6b6ae7a45f7ab473dd839515a1717bae68af03a (patch) | |
tree | 74bc548852a9ea3cf350096b55182761362a3f6d /indra/llcommon | |
parent | 3fd68662f267a3fd96d101834b3a9563bde3f61e (diff) | |
parent | e4cacda5a0cf3918bdc8091997b988235e9d4f3d (diff) |
merge
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-x | indra/llcommon/lldate.cpp | 6 | ||||
-rwxr-xr-x | indra/llcommon/lldefs.h | 3 | ||||
-rwxr-xr-x | indra/llcommon/llfasttimer.cpp | 6 | ||||
-rwxr-xr-x | indra/llcommon/llfasttimer.h | 32 | ||||
-rwxr-xr-x | indra/llcommon/llpreprocessor.h | 7 | ||||
-rwxr-xr-x | indra/llcommon/llsdparam.cpp | 2 | ||||
-rwxr-xr-x | indra/llcommon/llsdparam.h | 4 | ||||
-rwxr-xr-x | indra/llcommon/llstring.cpp | 6 | ||||
-rw-r--r-- | indra/llcommon/lltrace.h | 80 | ||||
-rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 4 |
10 files changed, 121 insertions, 29 deletions
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index 4f2e1304b2..b32c3f6830 100755 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -86,11 +86,11 @@ std::string LLDate::asRFC1123() const return toHTTPDateString (std::string ("%A, %d %b %Y %H:%M:%S GMT")); } -LLFastTimer::DeclareTimer FT_DATE_FORMAT("Date Format"); +LLTrace::TimeBlock FT_DATE_FORMAT("Date Format"); std::string LLDate::toHTTPDateString (std::string fmt) const { - LLFastTimer ft1(FT_DATE_FORMAT); + LL_RECORD_BLOCK_TIME(FT_DATE_FORMAT); time_t locSeconds = (time_t) mSecondsSinceEpoch; struct tm * gmt = gmtime (&locSeconds); @@ -99,7 +99,7 @@ std::string LLDate::toHTTPDateString (std::string fmt) const std::string LLDate::toHTTPDateString (tm * gmt, std::string fmt) { - LLFastTimer ft1(FT_DATE_FORMAT); + LL_RECORD_BLOCK_TIME(FT_DATE_FORMAT); // avoid calling setlocale() unnecessarily - it's expensive. static std::string prev_locale = ""; diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index d57b9dccff..5a4b8325f4 100755 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -244,8 +244,5 @@ inline void llswap(LLDATATYPE& lhs, LLDATATYPE& rhs) rhs = tmp; } -#define LL_GLUE_IMPL(x, y) x##y -#define LL_GLUE_TOKENS(x, y) LL_GLUE_IMPL(x, y) - #endif // LL_LLDEFS_H diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index c58fad12e7..52b3bb39b2 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -276,13 +276,13 @@ void TimeBlock::updateTimes() } } -static LLFastTimer::DeclareTimer FTM_PROCESS_TIMES("Process FastTimer Times"); +static LLTrace::TimeBlock FTM_PROCESS_TIMES("Process FastTimer Times"); // not thread safe, so only call on main thread //static void TimeBlock::processTimes() { - LLFastTimer _(FTM_PROCESS_TIMES); + LL_RECORD_BLOCK_TIME(FTM_PROCESS_TIMES); get_clock_count(); // good place to calculate clock frequency // set up initial tree @@ -413,7 +413,7 @@ void TimeBlock::writeLog(std::ostream& os) LLSDSerialize::toXML(sd, os); LLMutexLock lock(sLogLock); sLogQueue.pop(); - } + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 1586ea2d04..53c61734e5 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -35,28 +35,56 @@ class LLMutex; +#define LL_RECORD_BLOCK_TIME(timer_stat) const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__); + namespace LLTrace { +class BlockTimer timeThisBlock(class TimeBlock& timer); + class BlockTimer { public: - friend class TimeBlock; typedef BlockTimer self_t; typedef class TimeBlock DeclareTimer; - BlockTimer(TimeBlock& timer); ~BlockTimer(); F64Seconds getElapsedTime(); private: + friend class TimeBlock; + // FIXME: this friendship exists so that each thread can instantiate a root timer, + // which could be a derived class with a public constructor instead, possibly + friend class ThreadRecorder; + friend BlockTimer timeThisBlock(TimeBlock&); + BlockTimer(TimeBlock& timer); +#if !defined(MSC_VER) || MSC_VER < 1700 + // Visual Studio 2010 has a bug where capturing an object returned by value + // into a local reference requires access to the copy constructor at the call site. + // This appears to be fixed in 2012. +public: +#endif + // no-copy + BlockTimer(const BlockTimer& other) {}; + +private: U64 mStartTime; U64 mBlockStartTotalTimeCounter; BlockTimerStackRecord mParentTimerData; }; +// this dummy function assists in allocating a block timer with stack-based lifetime. +// this is done by capturing the return value in a stack-allocated const reference variable. +// (This is most easily done using the macro LL_RECORD_BLOCK_TIME) +// Otherwise, it would be possible to store a BlockTimer on the heap, resulting in non-nested lifetimes, +// which would break the invariants of the timing hierarchy logic +LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer) +{ + return BlockTimer(timer); +} + // stores a "named" timer instance to be reused via multiple BlockTimer stack instances class TimeBlock : public TraceType<TimeBlockAccumulator>, diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 0fcc872690..309165da7f 100755 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -191,9 +191,12 @@ #define LL_TO_STRING_HELPER(x) #x #define LL_TO_STRING(x) LL_TO_STRING_HELPER(x) -#define LL_FILE_LINENO(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg +#define LL_FILE_LINENO_MSG(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg +#define LL_GLUE_IMPL(x, y) x##y +#define LL_GLUE_TOKENS(x, y) LL_GLUE_IMPL(x, y) + #if LL_WINDOWS -#define LL_COMPILE_TIME_MESSAGE(msg) __pragma(message(LL_FILE_LINENO(msg))) +#define LL_COMPILE_TIME_MESSAGE(msg) __pragma(message(LL_FILE_LINENO_MSG(msg))) #else // no way to get gcc 4.2 to print a user-defined diagnostic message only when a macro is used #define LL_COMPILE_TIME_MESSAGE(msg) diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index c1ba777543..371bd49c04 100755 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -37,7 +37,7 @@ static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs; static const LLSD NO_VALUE_MARKER; -LLFastTimer::DeclareTimer FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion"); +LLTrace::TimeBlock FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion"); // // LLParamSDParser diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 7cfc265c62..47ec6414dd 100755 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -110,7 +110,7 @@ private: }; -extern LL_COMMON_API LLFastTimer::DeclareTimer FTM_SD_PARAM_ADAPTOR; +extern LL_COMMON_API LLTrace::TimeBlock FTM_SD_PARAM_ADAPTOR; template<typename T> class LLSDParamAdapter : public T { @@ -118,7 +118,7 @@ public: LLSDParamAdapter() {} LLSDParamAdapter(const LLSD& sd) { - LLFastTimer _(FTM_SD_PARAM_ADAPTOR); + LL_RECORD_BLOCK_TIME(FTM_SD_PARAM_ADAPTOR); LLParamSDParser parser; // don't spam for implicit parsing of LLSD, as we want to allow arbitrary freeform data and ignore most of it bool parse_silently = true; diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index e6e80fa279..a4b1d2ede3 100755 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -36,7 +36,7 @@ #include <winnls.h> // for WideCharToMultiByte #endif -LLFastTimer::DeclareTimer FT_STRING_FORMAT("String Format"); +LLTrace::TimeBlock FT_STRING_FORMAT("String Format"); std::string ll_safe_string(const char* in) @@ -1195,7 +1195,7 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token, template<> S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) { - LLFastTimer ft(FT_STRING_FORMAT); + LL_RECORD_BLOCK_TIME(FT_STRING_FORMAT); S32 res = 0; std::string output; @@ -1268,7 +1268,7 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) template<> S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) { - LLFastTimer ft(FT_STRING_FORMAT); + LL_RECORD_BLOCK_TIME(FT_STRING_FORMAT); S32 res = 0; if (!substitutions.isMap()) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index cda15c0de5..6436570492 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,8 +38,6 @@ #include <list> -#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::TimeBlock::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer); - namespace LLTrace { class Recording; @@ -89,7 +87,7 @@ public: size_t getIndex() const { return mAccumulatorIndex; } static size_t getNumIndices() { return AccumulatorBuffer<ACCUMULATOR>::getNumIndices(); } -private: +protected: const size_t mAccumulatorIndex; }; @@ -344,7 +342,7 @@ class MemTrackable struct TrackMemImpl; typedef MemTrackable<DERIVED, ALIGNMENT> mem_trackable_t; - + static MemStatHandle sMemStat; public: typedef void mem_trackable_tag_t; @@ -359,7 +357,22 @@ public: accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocatedCount++; - return ::operator new(size); + if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) + { + return ::operator new(size); + } + else if (ALIGNMENT == 16) + { + return ll_aligned_malloc_16(size); + } + else if (ALIGNMENT == 32) + { + return ll_aligned_malloc_32(size); + } + else + { + return ll_aligned_malloc(size, ALIGNMENT); + } } void operator delete(void* ptr, size_t size) @@ -368,7 +381,23 @@ public: accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mAllocatedCount--; accumulator.mDeallocatedCount++; - ::operator delete(ptr); + + if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) + { + ::operator delete(ptr); + } + else if (ALIGNMENT == 16) + { + ll_aligned_free_16(ptr); + } + else if (ALIGNMENT == 32) + { + return ll_aligned_free_32(ptr); + } + else + { + return ll_aligned_free(ptr); + } } void *operator new [](size_t size) @@ -377,7 +406,22 @@ public: accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocatedCount++; - return ::operator new[](size); + if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) + { + return ::operator new[](size); + } + else if (ALIGNMENT == 16) + { + return ll_aligned_malloc_16(size); + } + else if (ALIGNMENT == 32) + { + return ll_aligned_malloc_32(size); + } + else + { + return ll_aligned_malloc(size, ALIGNMENT); + } } void operator delete[](void* ptr, size_t size) @@ -386,7 +430,23 @@ public: accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mAllocatedCount--; accumulator.mDeallocatedCount++; - ::operator delete[](ptr); + + if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) + { + ::operator delete[](ptr); + } + else if (ALIGNMENT == 16) + { + ll_aligned_free_16(ptr); + } + else if (ALIGNMENT == 32) + { + return ll_aligned_free_32(ptr); + } + else + { + return ll_aligned_free(ptr); + } } // claim memory associated with other objects/data as our own, adding to our calculated footprint @@ -477,5 +537,9 @@ private: }; }; +// pretty sure typeid of containing class in static object constructor doesn't work in gcc +template<typename DERIVED, size_t ALIGNMENT> +MemStatHandle MemTrackable<DERIVED, ALIGNMENT>::sMemStat(typeid(DERIVED).name()); + } #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index df4af89184..8cddc49e71 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -249,11 +249,11 @@ void ThreadRecorder::pushToParent() } -static LLFastTimer::DeclareTimer FTM_PULL_TRACE_DATA_FROM_CHILDREN("Pull child thread trace data"); +static LLTrace::TimeBlock FTM_PULL_TRACE_DATA_FROM_CHILDREN("Pull child thread trace data"); void ThreadRecorder::pullFromChildren() { - LLFastTimer _(FTM_PULL_TRACE_DATA_FROM_CHILDREN); + LL_RECORD_BLOCK_TIME(FTM_PULL_TRACE_DATA_FROM_CHILDREN); if (mActiveRecordings.empty()) return; { LLMutexLock lock(&mChildListMutex); |