summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/llfasttimer.cpp10
-rwxr-xr-xindra/llcommon/llfasttimer.h6
-rwxr-xr-xindra/llcommon/llmemory.cpp5
-rw-r--r--indra/llcommon/lltrace.cpp2
-rw-r--r--indra/llcommon/lltrace.h79
-rw-r--r--indra/llcommon/lltraceaccumulators.cpp30
-rw-r--r--indra/llcommon/lltraceaccumulators.h16
-rw-r--r--indra/llcommon/lltracethreadrecorder.cpp14
8 files changed, 90 insertions, 72 deletions
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index be240c754a..52b3bb39b2 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -189,7 +189,7 @@ void TimeBlock::bootstrapTimerTree()
// when this timer was called
if (timer.getParent() == &TimeBlock::getRootTimeBlock())
{
- TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator();
+ TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator();
if (accumulator.mLastCaller)
{
@@ -223,7 +223,7 @@ void TimeBlock::incrementalUpdateTimerTree()
// skip root timer
if (timerp != &TimeBlock::getRootTimeBlock())
{
- TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator();
+ TimeBlockAccumulator& accumulator = timerp->getCurrentAccumulator();
if (accumulator.mMoveUpTree)
{
@@ -253,7 +253,7 @@ void TimeBlock::updateTimes()
U64 cur_time = getCPUClockCount64();
BlockTimer* cur_timer = stack_record->mActiveTimer;
- TimeBlockAccumulator* accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator();
+ TimeBlockAccumulator* accumulator = &stack_record->mTimeBlock->getCurrentAccumulator();
while(cur_timer
&& cur_timer->mParentTimerData.mActiveTimer != cur_timer) // root defined by parent pointing to self
@@ -269,7 +269,7 @@ void TimeBlock::updateTimes()
cur_timer->mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter;
stack_record = &cur_timer->mParentTimerData;
- accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator();
+ accumulator = &stack_record->mTimeBlock->getCurrentAccumulator();
cur_timer = stack_record->mActiveTimer;
stack_record->mChildTime += cumulative_time_delta;
@@ -299,7 +299,7 @@ void TimeBlock::processTimes()
++it)
{
TimeBlock& timer = *it;
- TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator();
+ TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator();
accumulator.mLastCaller = NULL;
accumulator.mMoveUpTree = false;
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index e6bf544b51..53c61734e5 100755
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -285,11 +285,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer)
#if FAST_TIMER_ON
BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance();
if (!cur_timer_data) return;
- TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator();
+ 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->getPrimaryAccumulator().mActiveCount == 0);
+ accumulator.mMoveUpTree |= (accumulator.mParent->getCurrentAccumulator().mActiveCount == 0);
// store top of stack
mParentTimerData = *cur_timer_data;
@@ -309,7 +309,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer()
BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer<BlockTimerStackRecord>::getInstance();
if (!cur_timer_data) return;
- TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator();
+ TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getCurrentAccumulator();
accumulator.mCalls++;
accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter);
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index cb2f853070..e0b2aa87c2 100755
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -43,12 +43,15 @@
#include "llsys.h"
#include "llframetimer.h"
+#include "lltrace.h"
//----------------------------------------------------------------------------
//static
char* LLMemory::reserveMem = 0;
U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0);
+static LLTrace::SampleStatHandle<F64Megabytes> sAllocatedMem("allocated_mem", "active memory in use by application");
+static LLTrace::SampleStatHandle<F64Megabytes> sVirtualMem("virtual_mem", "virtual memory assigned to application");
U32Kilobytes LLMemory::sAllocatedMemInKB(0);
U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0);
U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
@@ -114,7 +117,9 @@ void LLMemory::updateMemoryInfo()
}
sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ;
+ sample(sAllocatedMem, sAllocatedMemInKB);
sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ;
+ sample(sVirtualMem, sAllocatedPageSizeInKB);
U32Kilobytes avail_phys, avail_virtual;
LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ;
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index 05422f9191..e4a6f4c902 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -76,7 +76,7 @@ void TimeBlockTreeNode::setParent( TimeBlock* parent )
}
mParent = parent;
- mBlock->getPrimaryAccumulator().mParent = parent;
+ mBlock->getCurrentAccumulator().mParent = parent;
parent_tree_node->mChildren.push_back(mBlock);
parent_tree_node->mNeedsSorting = true;
}
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index afa9933165..f7ceaf585d 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -78,9 +78,9 @@ public:
mAccumulatorIndex(AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot())
{}
- LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const
+ LL_FORCE_INLINE ACCUMULATOR& getCurrentAccumulator() const
{
- ACCUMULATOR* accumulator_storage = AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage();
+ ACCUMULATOR* accumulator_storage = AccumulatorBuffer<ACCUMULATOR>::getCurrentStorage();
return accumulator_storage[mAccumulatorIndex];
}
@@ -135,7 +135,7 @@ template<typename T, typename VALUE_T>
void record(EventStatHandle<T>& measurement, VALUE_T value)
{
T converted_value(value);
- measurement.getPrimaryAccumulator().record(storage_value(converted_value));
+ measurement.getCurrentAccumulator().record(storage_value(converted_value));
}
template <typename T = F64>
@@ -158,7 +158,22 @@ template<typename T, typename VALUE_T>
void sample(SampleStatHandle<T>& measurement, VALUE_T value)
{
T converted_value(value);
- measurement.getPrimaryAccumulator().sample(storage_value(converted_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>
@@ -181,7 +196,7 @@ template<typename T, typename VALUE_T>
void add(CountStatHandle<T>& count, VALUE_T value)
{
T converted_value(value);
- count.getPrimaryAccumulator().add(storage_value(converted_value));
+ count.getCurrentAccumulator().add(storage_value(converted_value));
}
template<>
@@ -225,12 +240,12 @@ public:
: trace_t(name)
{}
- void setName(const char* name)
- {
- mName = name;
- setKey(name);
- }
-
+ void setName(const char* name)
+ {
+ mName = name;
+ setKey(name);
+ }
+
/*virtual*/ const char* getUnitLabel() const { return "B"; }
TraceType<MemStatAccumulator::AllocationCountFacet>& allocationCount()
@@ -337,17 +352,16 @@ class MemTrackable
public:
typedef void mem_trackable_tag_t;
- MemTrackable()
- {
- static bool name_initialized = false;
- if (!name_initialized)
- {
- name_initialized = true;
- sMemStat.setName(typeid(DERIVED).name());
- }
- }
-
-
+ MemTrackable()
+ {
+ static bool name_initialized = false;
+ if (!name_initialized)
+ {
+ name_initialized = true;
+ sMemStat.setName(typeid(DERIVED).name());
+ }
+ }
+
virtual ~MemTrackable()
{
memDisclaim(mMemFootprint);
@@ -355,7 +369,7 @@ public:
void* operator new(size_t size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mAllocatedCount++;
@@ -379,7 +393,7 @@ public:
void operator delete(void* ptr, size_t size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mAllocatedCount--;
accumulator.mDeallocatedCount++;
@@ -404,7 +418,7 @@ public:
void *operator new [](size_t size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mAllocatedCount++;
@@ -428,7 +442,7 @@ public:
void operator delete[](void* ptr, size_t size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mAllocatedCount--;
accumulator.mDeallocatedCount++;
@@ -470,7 +484,7 @@ public:
template<typename AMOUNT_T>
AMOUNT_T& memClaimAmount(AMOUNT_T& size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
mMemFootprint += (size_t)size;
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
return size;
@@ -494,7 +508,7 @@ public:
template<typename AMOUNT_T>
AMOUNT_T& memDisclaimAmount(AMOUNT_T& size)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
return size;
}
@@ -507,7 +521,7 @@ private:
{
static void claim(mem_trackable_t& tracker, const TRACKED& tracked)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
size_t footprint = MemFootprint<TRACKED>::measure(tracked);
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)footprint : (F64)footprint);
tracker.mMemFootprint += footprint;
@@ -515,7 +529,7 @@ private:
static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
size_t footprint = MemFootprint<TRACKED>::measure(tracked);
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)footprint : -(F64)footprint);
tracker.mMemFootprint -= footprint;
@@ -527,19 +541,18 @@ private:
{
static void claim(mem_trackable_t& tracker, TRACKED& tracked)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() + (F64)MemFootprint<TRACKED>::measure(tracked) : (F64)MemFootprint<TRACKED>::measure(tracked));
}
static void disclaim(mem_trackable_t& tracker, TRACKED& tracked)
{
- MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator();
+ MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator();
accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() - (F64)MemFootprint<TRACKED>::measure(tracked) : -(F64)MemFootprint<TRACKED>::measure(tracked));
}
};
};
-// 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("");
diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp
index ae769350b9..b234f43337 100644
--- a/indra/llcommon/lltraceaccumulators.cpp
+++ b/indra/llcommon/lltraceaccumulators.cpp
@@ -48,13 +48,13 @@ void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other)
other.mMemStats.reset(&mMemStats);
}
-void AccumulatorBufferGroup::makePrimary()
+void AccumulatorBufferGroup::makeCurrent()
{
- mCounts.makePrimary();
- mSamples.makePrimary();
- mEvents.makePrimary();
- mStackTimers.makePrimary();
- mMemStats.makePrimary();
+ mCounts.makeCurrent();
+ mSamples.makeCurrent();
+ mEvents.makeCurrent();
+ mStackTimers.makeCurrent();
+ mMemStats.makeCurrent();
ThreadRecorder* thread_recorder = get_thread_recorder().get();
AccumulatorBuffer<TimeBlockAccumulator>& timer_accumulator_buffer = mStackTimers;
@@ -70,18 +70,18 @@ void AccumulatorBufferGroup::makePrimary()
}
//static
-void AccumulatorBufferGroup::clearPrimary()
+void AccumulatorBufferGroup::resetCurrent()
{
- AccumulatorBuffer<CountAccumulator>::clearPrimary();
- AccumulatorBuffer<SampleAccumulator>::clearPrimary();
- AccumulatorBuffer<EventAccumulator>::clearPrimary();
- AccumulatorBuffer<TimeBlockAccumulator>::clearPrimary();
- AccumulatorBuffer<MemStatAccumulator>::clearPrimary();
+ AccumulatorBuffer<CountAccumulator>::resetCurrent();
+ AccumulatorBuffer<SampleAccumulator>::resetCurrent();
+ AccumulatorBuffer<EventAccumulator>::resetCurrent();
+ AccumulatorBuffer<TimeBlockAccumulator>::resetCurrent();
+ AccumulatorBuffer<MemStatAccumulator>::resetCurrent();
}
-bool AccumulatorBufferGroup::isPrimary() const
+bool AccumulatorBufferGroup::isCurrent() const
{
- return mCounts.isPrimary();
+ return mCounts.isCurrent();
}
void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other )
@@ -114,7 +114,7 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other)
void AccumulatorBufferGroup::sync()
{
- if (isPrimary())
+ if (isCurrent())
{
F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds();
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index 02af480b8a..e31058ab4b 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -75,7 +75,7 @@ namespace LLTrace
~AccumulatorBuffer()
{
- if (isPrimary())
+ if (isCurrent())
{
LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(NULL);
}
@@ -128,22 +128,22 @@ namespace LLTrace
}
}
- void makePrimary()
+ void makeCurrent()
{
LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(mStorage);
}
- bool isPrimary() const
+ bool isCurrent() const
{
return LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance() == mStorage;
}
- static void clearPrimary()
+ static void resetCurrent()
{
LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(NULL);
}
- LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage()
+ LL_FORCE_INLINE static ACCUMULATOR* getCurrentStorage()
{
ACCUMULATOR* accumulator = LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance();
return accumulator ? accumulator : getDefaultBuffer()->mStorage;
@@ -534,9 +534,9 @@ namespace LLTrace
AccumulatorBufferGroup();
void handOffTo(AccumulatorBufferGroup& other);
- void makePrimary();
- bool isPrimary() const;
- static void clearPrimary();
+ void makeCurrent();
+ bool isCurrent() const;
+ static void resetCurrent();
void append(const AccumulatorBufferGroup& other);
void merge(const AccumulatorBufferGroup& other);
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp
index 4129f1f889..8cddc49e71 100644
--- a/indra/llcommon/lltracethreadrecorder.cpp
+++ b/indra/llcommon/lltracethreadrecorder.cpp
@@ -69,13 +69,13 @@ void ThreadRecorder::init()
tree_node.mBlock = &time_block;
tree_node.mParent = &root_time_block;
- it->getPrimaryAccumulator().mParent = &root_time_block;
+ it->getCurrentAccumulator().mParent = &root_time_block;
}
mRootTimer = new BlockTimer(root_time_block);
timer_stack->mActiveTimer = mRootTimer;
- TimeBlock::getRootTimeBlock().getPrimaryAccumulator().mActiveCount = 1;
+ TimeBlock::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1;
}
@@ -135,7 +135,7 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand
}
mActiveRecordings.push_back(active_recording);
- mActiveRecordings.back()->mPartialRecording.makePrimary();
+ mActiveRecordings.back()->mPartialRecording.makeCurrent();
}
ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording )
@@ -186,19 +186,19 @@ void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording )
if (it != mActiveRecordings.rend())
{
active_recording_list_t::iterator recording_to_remove = (++it).base();
- bool was_primary = (*recording_to_remove)->mPartialRecording.isPrimary();
+ bool was_current = (*recording_to_remove)->mPartialRecording.isCurrent();
llassert((*recording_to_remove)->mTargetRecording == recording);
delete *recording_to_remove;
mActiveRecordings.erase(recording_to_remove);
- if (was_primary)
+ if (was_current)
{
if (mActiveRecordings.empty())
{
- AccumulatorBufferGroup::clearPrimary();
+ AccumulatorBufferGroup::resetCurrent();
}
else
{
- mActiveRecordings.back()->mPartialRecording.makePrimary();
+ mActiveRecordings.back()->mPartialRecording.makeCurrent();
}
}
}