summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-09-25 19:12:35 -0700
committerRichard Linden <none@none>2013-09-25 19:12:35 -0700
commit053d97db1b283ca2548dc1f64756ddfc5166158f (patch)
tree5bcbc17e5092fc54791e880bc4640d4b43af7e50 /indra/llcommon
parentab8f64a96754edaa68dd1ff97b9519eff4496aa6 (diff)
better memory usage for LLTrace (tighter packing of recording arrays)
removed complicated and unnecessary fast timer gapless handoff logic (it should be gapless anyway) improved MemTrackable API, better separation of shadow and footprint added memory usage stats to floater_stats.xml
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/llfasttimer.cpp20
-rwxr-xr-xindra/llcommon/llfasttimer.h4
-rwxr-xr-xindra/llcommon/llmemory.h49
-rw-r--r--indra/llcommon/lltrace.h299
-rw-r--r--indra/llcommon/lltraceaccumulators.h23
-rw-r--r--indra/llcommon/lltracerecording.cpp6
-rw-r--r--indra/llcommon/lltracethreadrecorder.cpp5
7 files changed, 202 insertions, 204 deletions
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 52b3bb39b2..32ef01b2b6 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -259,15 +259,12 @@ void TimeBlock::updateTimes()
&& cur_timer->mParentTimerData.mActiveTimer != cur_timer) // root defined by parent pointing to self
{
U64 cumulative_time_delta = cur_time - cur_timer->mStartTime;
- accumulator->mTotalTimeCounter += cumulative_time_delta
- - (accumulator->mTotalTimeCounter
- - cur_timer->mBlockStartTotalTimeCounter);
+ cur_timer->mStartTime = cur_time;
+
+ accumulator->mTotalTimeCounter += cumulative_time_delta;
accumulator->mSelfTimeCounter += cumulative_time_delta - stack_record->mChildTime;
stack_record->mChildTime = 0;
- cur_timer->mStartTime = cur_time;
- cur_timer->mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter;
-
stack_record = &cur_timer->mParentTimerData;
accumulator = &stack_record->mTimeBlock->getCurrentAccumulator();
cur_timer = stack_record->mActiveTimer;
@@ -423,7 +420,6 @@ void TimeBlock::writeLog(std::ostream& os)
TimeBlockAccumulator::TimeBlockAccumulator()
: mTotalTimeCounter(0),
mSelfTimeCounter(0),
- mStartTotalTimeCounter(0),
mCalls(0),
mLastCaller(NULL),
mActiveCount(0),
@@ -436,7 +432,7 @@ void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other, EBuffe
// we can't merge two unrelated time block samples, as that will screw with the nested timings
// due to the call hierarchy of each thread
llassert(append_type == SEQUENTIAL);
- mTotalTimeCounter += other.mTotalTimeCounter - other.mStartTotalTimeCounter;
+ mTotalTimeCounter += other.mTotalTimeCounter;
mSelfTimeCounter += other.mSelfTimeCounter;
mCalls += other.mCalls;
mLastCaller = other.mLastCaller;
@@ -449,21 +445,15 @@ void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other )
{
mCalls = 0;
mSelfTimeCounter = 0;
+ mTotalTimeCounter = 0;
if (other)
{
- mStartTotalTimeCounter = other->mTotalTimeCounter;
- mTotalTimeCounter = mStartTotalTimeCounter;
-
mLastCaller = other->mLastCaller;
mActiveCount = other->mActiveCount;
mMoveUpTree = other->mMoveUpTree;
mParent = other->mParent;
}
- else
- {
- mStartTotalTimeCounter = mTotalTimeCounter;
- }
}
F64Seconds BlockTimer::getElapsedTime()
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 53c61734e5..4eb12907dc 100755
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -71,7 +71,6 @@ public:
private:
U64 mStartTime;
- U64 mBlockStartTotalTimeCounter;
BlockTimerStackRecord mParentTimerData;
};
@@ -287,7 +286,6 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer)
if (!cur_timer_data) return;
TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator();
accumulator.mActiveCount++;
- mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter;
// keep current parent as long as it is active when we are
accumulator.mMoveUpTree |= (accumulator.mParent->getCurrentAccumulator().mActiveCount == 0);
@@ -312,7 +310,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer()
TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getCurrentAccumulator();
accumulator.mCalls++;
- accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter);
+ accumulator.mTotalTimeCounter += total_time;
accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime;
accumulator.mActiveCount--;
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index d3c5e5235d..2330bfb8ea 100755
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -54,7 +54,7 @@ class LLMutex ;
#define LL_DEFAULT_HEAP_ALIGN 8
#endif
-inline void* ll_aligned_malloc( size_t size, int align )
+inline void* ll_aligned_malloc_fallback( size_t size, int align )
{
void* mem = malloc( size + (align - 1) + sizeof(void*) );
char* aligned = ((char*)mem) + sizeof(void*);
@@ -64,7 +64,7 @@ inline void* ll_aligned_malloc( size_t size, int align )
return aligned;
}
-inline void ll_aligned_free( void* ptr )
+inline void ll_aligned_free_fallback( void* ptr )
{
free( ((void**)ptr)[-1] );
}
@@ -130,7 +130,7 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
#if defined(LL_WINDOWS)
return _aligned_malloc(size, 32);
#elif defined(LL_DARWIN)
- return ll_aligned_malloc( size, 32 );
+ return ll_aligned_malloc_fallback( size, 32 );
#else
void *rtn;
if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size)))
@@ -151,6 +151,49 @@ inline void ll_aligned_free_32(void *p)
#endif
}
+// general purpose dispatch functions that are forced inline so they can compile down to a single call
+LL_FORCE_INLINE void* ll_aligned_malloc(size_t alignment, size_t size)
+{
+ if (LL_DEFAULT_HEAP_ALIGN % alignment == 0)
+ {
+ return malloc(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_fallback(size, alignment);
+ }
+}
+
+LL_FORCE_INLINE void ll_aligned_free(size_t alignment, void* ptr)
+{
+ if (alignment == LL_DEFAULT_HEAP_ALIGN)
+ {
+ free(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_fallback(ptr);
+ }
+}
+
+
+
#ifndef __DEBUG_PRIVATE_MEM__
#define __DEBUG_PRIVATE_MEM__ 0
#endif
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 5c833ea287..355617a898 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -161,21 +161,6 @@ void sample(SampleStatHandle<T>& measurement, VALUE_T value)
measurement.getCurrentAccumulator().sample(storage_value(converted_value));
}
-template<typename T, typename VALUE_T>
-void add(SampleStatHandle<T>& measurement, VALUE_T value)
-{
- T converted_value(value);
- SampleAccumulator& acc = measurement.getCurrentAccumulator();
- if (acc.hasValue())
- {
- acc.sample(acc.getLastValue() + converted_value);
- }
- else
- {
- acc.sample(converted_value);
- }
-}
-
template <typename T = F64>
class CountStatHandle
: public TraceType<CountAccumulator>
@@ -296,28 +281,28 @@ public:
}
};
-inline void claim_mem(MemStatHandle& measurement, size_t size)
+inline void claim_footprint(MemStatHandle& measurement, S32 size)
{
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mAllocated.add(1);
}
-inline void disclaim_mem(MemStatHandle& measurement, size_t size)
+inline void disclaim_footprint(MemStatHandle& measurement, S32 size)
{
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mDeallocated.add(1);
}
-inline void claim_shadow_mem(MemStatHandle& measurement, size_t size)
+inline void claim_shadow(MemStatHandle& measurement, S32 size)
{
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mShadowAllocated.add(1);
}
-inline void disclaim_shadow_mem(MemStatHandle& measurement, size_t size)
+inline void disclaim_shadow(MemStatHandle& measurement, S32 size)
{
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
@@ -327,94 +312,122 @@ inline void disclaim_shadow_mem(MemStatHandle& measurement, size_t size)
// measures effective memory footprint of specified type
// specialize to cover different types
-template<typename T>
-struct MemFootprint
+template<typename T, typename IS_MEM_TRACKABLE = void>
+struct MeasureMem
{
- static size_t measure(const T& value)
+ static size_t measureFootprint(const T& value)
{
return sizeof(T);
}
- static size_t measure()
+ static size_t measureFootprint()
{
return sizeof(T);
}
+
+ static size_t measureShadow(const T& value)
+ {
+ return 0;
+ }
+
+ static size_t measureShadow()
+ {
+ return 0;
+ }
};
template<typename T>
-struct MemFootprint<T*>
+struct MeasureMem<T, typename T::mem_trackable_tag_t>
{
- static size_t measure(const T* value)
+ static size_t measureFootprint(const T& value)
+ {
+ return sizeof(T) + value.getMemFootprint();
+ }
+
+ static size_t measureFootprint()
+ {
+ return sizeof(T);
+ }
+
+ static size_t measureShadow(const T& value)
+ {
+ return value.getMemShadow();
+ }
+
+ static size_t measureShadow()
+ {
+ return MeasureMem<T>::measureShadow();
+ }
+};
+
+
+template<typename T, typename IS_MEM_TRACKABLE>
+struct MeasureMem<T*, IS_MEM_TRACKABLE>
+{
+ static size_t measureFootprint(const T* value)
{
if (!value)
{
return 0;
}
- return MemFootprint<T>::measure(*value);
+ return MeasureMem<T>::measureFootprint(*value);
}
- static size_t measure()
+ static size_t measureFootprint()
{
- return MemFootprint<T>::measure();
+ return MeasureMem<T>::measureFootprint();
}
-};
-template<typename T>
-struct MemFootprint<std::basic_string<T> >
-{
- static size_t measure(const std::basic_string<T>& value)
+ static size_t measureShadow(const T* value)
{
- return value.capacity() * sizeof(T);
+ return MeasureMem<T>::measureShadow(*value);
}
- static size_t measure()
+ static size_t measureShadow()
{
- return sizeof(std::basic_string<T>);
+ return MeasureMem<T>::measureShadow();
}
};
-template<typename T>
-struct MemFootprint<std::vector<T> >
+template<typename T, typename IS_MEM_TRACKABLE>
+struct MeasureMem<std::basic_string<T>, IS_MEM_TRACKABLE>
{
- static size_t measure(const std::vector<T>& value)
+ static size_t measureFootprint(const std::basic_string<T>& value)
{
- return value.capacity() * MemFootprint<T>::measure();
+ return value.capacity() * sizeof(T);
}
- static size_t measure()
+ static size_t measureFootprint()
{
- return sizeof(std::vector<T>);
+ return sizeof(std::basic_string<T>);
}
-};
-template<typename T>
-struct MemFootprint<std::list<T> >
-{
- static size_t measure(const std::list<T>& value)
+ static size_t measureShadow(const std::basic_string<T>& value)
{
- return value.size() * (MemFootprint<T>::measure() + sizeof(void*) * 2);
+ return 0;
}
- static size_t measure()
+ static size_t measureShadow()
{
- return sizeof(std::list<T>);
+ return 0;
}
};
template<typename DERIVED, size_t ALIGNMENT = LL_DEFAULT_HEAP_ALIGN>
class MemTrackable
{
- template<typename TRACKED, typename TRACKED_IS_TRACKER>
- struct TrackMemImpl;
-
- typedef MemTrackable<DERIVED, ALIGNMENT> mem_trackable_t;
- static MemStatHandle sMemStat;
-
public:
typedef void mem_trackable_tag_t;
+ enum EMemType
+ {
+ MEM_FOOTPRINT,
+ MEM_SHADOW
+ };
+
MemTrackable()
- : mMemFootprint(0)
+ : mMemFootprint(0),
+ mMemShadow(0)
{
static bool name_initialized = false;
if (!name_initialized)
@@ -426,7 +439,8 @@ public:
virtual ~MemTrackable()
{
- memDisclaim(mMemFootprint);
+ disclaimMem(mMemFootprint, MEM_FOOTPRINT);
+ disclaimMem(mMemShadow, MEM_SHADOW);
}
static MemStatHandle& getMemStatHandle()
@@ -434,186 +448,129 @@ public:
return sMemStat;
}
+ S32 getMemFootprint() const { return mMemFootprint; }
+ S32 getMemShadow() const { return mMemShadow; }
+
void* operator new(size_t size)
{
- claim_mem(sMemStat, 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);
- }
+ claim_footprint(sMemStat, size);
+ return ll_aligned_malloc(ALIGNMENT, size);
}
void operator delete(void* ptr, size_t size)
{
- disclaim_mem(sMemStat, size);
-
- 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);
- }
+ disclaim_footprint(sMemStat, size);
+ ll_aligned_free(ALIGNMENT, ptr);
}
void *operator new [](size_t size)
{
- claim_mem(sMemStat, 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);
- }
+ claim_footprint(sMemStat, size);
+ return ll_aligned_malloc(ALIGNMENT, size);
}
void operator delete[](void* ptr, size_t size)
{
- disclaim_mem(sMemStat, size);
-
- 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);
- }
+ disclaim_footprint(sMemStat, size);
+ ll_aligned_free(ALIGNMENT, ptr);
}
// claim memory associated with other objects/data as our own, adding to our calculated footprint
template<typename CLAIM_T>
- CLAIM_T& memClaim(CLAIM_T& value)
+ CLAIM_T& claimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT)
{
- TrackMemImpl<CLAIM_T>::claim(*this, value);
+ trackAlloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type);
+ trackAlloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW);
return value;
}
template<typename CLAIM_T>
- const CLAIM_T& memClaim(const CLAIM_T& value)
+ const CLAIM_T& claimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT)
{
- TrackMemImpl<CLAIM_T>::claim(*this, value);
+ trackAlloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type);
+ trackAlloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW);
return value;
}
- size_t& memClaim(size_t& size)
+ size_t& claimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT)
{
- claim_mem(sMemStat, size);
- mMemFootprint += size;
+ trackAlloc(size, mem_type);
return size;
}
- int& memClaim(int& size)
+ S32& claimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT)
{
- claim_mem(sMemStat, size);
- mMemFootprint += size;
+ trackAlloc(size, mem_type);
return size;
}
// remove memory we had claimed from our calculated footprint
template<typename CLAIM_T>
- CLAIM_T& memDisclaim(CLAIM_T& value)
+ CLAIM_T& disclaimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT)
{
- TrackMemImpl<CLAIM_T>::disclaim(*this, value);
+ trackDealloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type);
+ trackDealloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW);
return value;
}
template<typename CLAIM_T>
- const CLAIM_T& memDisclaim(const CLAIM_T& value)
+ const CLAIM_T& disclaimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT)
{
- TrackMemImpl<CLAIM_T>::disclaim(*this, value);
+ trackDealloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type);
+ trackDealloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW);
return value;
}
- size_t& memDisclaim(size_t& size)
+ size_t& disclaimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT)
{
- disclaim_mem(sMemStat, size);
- mMemFootprint -= size;
+ trackDealloc(size, mem_type);
return size;
}
- int& memDisclaim(int& size)
+ S32& disclaimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT)
{
- disclaim_mem(sMemStat, size);
- mMemFootprint -= size;
+ trackDealloc(size, mem_type);
return size;
}
private:
- size_t mMemFootprint;
- template<typename TRACKED, typename TRACKED_IS_TRACKER = void>
- struct TrackMemImpl
+ void trackAlloc(S32 size, EMemType mem_type)
{
- static void claim(mem_trackable_t& tracker, const TRACKED& tracked)
+ if (mem_type == MEM_FOOTPRINT)
{
- size_t footprint = MemFootprint<TRACKED>::measure(tracked);
- claim_mem(sMemStat, footprint);
- tracker.mMemFootprint += footprint;
+ claim_footprint(sMemStat, size);
+ mMemFootprint += size;
}
-
- static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked)
+ else
{
- size_t footprint = MemFootprint<TRACKED>::measure(tracked);
- disclaim_mem(sMemStat, footprint);
- tracker.mMemFootprint -= footprint;
+ claim_shadow(sMemStat, size);
+ mMemShadow += size;
}
- };
+ }
- template<typename TRACKED>
- struct TrackMemImpl<TRACKED, typename TRACKED::mem_trackable_tag_t>
+ void trackDealloc(S32 size, EMemType mem_type)
{
- static void claim(mem_trackable_t& tracker, TRACKED& tracked)
+ if (mem_type == MEM_FOOTPRINT)
{
- claim_shadow_mem( sMemStat, MemFootprint<TRACKED>::measure(tracked));
+ disclaim_footprint(sMemStat, size);
+ mMemFootprint -= size;
}
-
- static void disclaim(mem_trackable_t& tracker, TRACKED& tracked)
+ else
{
- disclaim_shadow_mem(sMemStat, MemFootprint<TRACKED>::measure(tracked));
+ disclaim_shadow(sMemStat, size);
+ mMemShadow -= size;
}
- };
+ }
+
+private:
+ // use signed values so that we can temporarily go negative
+ // and reconcile in destructor
+ // NB: this assumes that no single class is responsible for > 2GB of allocations
+ S32 mMemFootprint,
+ mMemShadow;
+
+ static MemStatHandle sMemStat;
};
template<typename DERIVED, size_t ALIGNMENT>
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index 37a35f4e23..4fe84455a6 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -35,6 +35,7 @@
#include "lltimer.h"
#include "llrefcount.h"
#include "llthreadlocalstorage.h"
+#include "llmemory.h"
#include <limits>
namespace LLTrace
@@ -51,7 +52,7 @@ namespace LLTrace
class AccumulatorBuffer : public LLRefCount
{
typedef AccumulatorBuffer<ACCUMULATOR> self_t;
- static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64;
+ static const U32 ACCUMULATOR_BUFFER_SIZE_INCREMENT = 16;
private:
struct StaticAllocationMarker { };
@@ -149,7 +150,9 @@ namespace LLTrace
size_t next_slot = sNextStorageSlot++;
if (next_slot >= mStorageSize)
{
- resize(mStorageSize + (mStorageSize >> 2));
+ // don't perform doubling, as this should only happen during startup
+ // want to keep a tight bounds as we will have a lot of these buffers
+ resize(mStorageSize + ACCUMULATOR_BUFFER_SIZE_INCREMENT);
}
llassert(mStorage && next_slot < mStorageSize);
return next_slot;
@@ -199,7 +202,7 @@ namespace LLTrace
// so as not to trigger an access violation
sDefaultBuffer = new AccumulatorBuffer(StaticAllocationMarker());
sInitialized = true;
- sDefaultBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE);
+ sDefaultBuffer->resize(ACCUMULATOR_BUFFER_SIZE_INCREMENT);
}
return sDefaultBuffer;
}
@@ -427,6 +430,17 @@ namespace LLTrace
typedef F64Seconds value_t;
};
+ // arrays are allocated with 32 byte alignment
+ void *operator new [](size_t size)
+ {
+ return ll_aligned_malloc(32, size);
+ }
+
+ void operator delete[](void* ptr, size_t size)
+ {
+ ll_aligned_free(32, ptr);
+ }
+
TimeBlockAccumulator();
void addSamples(const self_t& other, EBufferAppendType append_type);
void reset(const self_t* other);
@@ -435,8 +449,7 @@ namespace LLTrace
//
// members
//
- U64 mStartTotalTimeCounter,
- mTotalTimeCounter,
+ U64 mTotalTimeCounter,
mSelfTimeCounter;
U32 mCalls;
class TimeBlock* mParent; // last acknowledged parent of this time block
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index c606007d89..c16d02216d 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -131,7 +131,7 @@ void Recording::appendRecording( Recording& other )
F64Seconds Recording::getSum(const TraceType<TimeBlockAccumulator>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
+ return F64Seconds((F64)(accumulator.mTotalTimeCounter)
/ (F64)LLTrace::TimeBlock::countsPerSecond());
}
@@ -151,7 +151,7 @@ F64Seconds Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat)
{
const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()];
- return F64Seconds((F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter)
+ return F64Seconds((F64)(accumulator.mTotalTimeCounter)
/ ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value()));
}
@@ -935,7 +935,7 @@ void ExtendablePeriodicRecording::handleSplitTo(ExtendablePeriodicRecording& oth
PeriodicRecording& get_frame_recording()
{
- static LLThreadLocalPointer<PeriodicRecording> sRecording(new PeriodicRecording(1000, PeriodicRecording::STARTED));
+ static LLThreadLocalPointer<PeriodicRecording> sRecording(new PeriodicRecording(200, PeriodicRecording::STARTED));
return *sRecording;
}
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp
index d3d9eb5ca7..e131af5f16 100644
--- a/indra/llcommon/lltracethreadrecorder.cpp
+++ b/indra/llcommon/lltracethreadrecorder.cpp
@@ -127,10 +127,7 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand
{
AccumulatorBufferGroup& prev_active_recording = mActiveRecordings.back()->mPartialRecording;
prev_active_recording.sync();
- if (!from_handoff)
- {
- TimeBlock::updateTimes();
- }
+ TimeBlock::updateTimes();
prev_active_recording.handOffTo(active_recording->mPartialRecording);
}
mActiveRecordings.push_back(active_recording);