more memory optimizations of lltrace

master
Richard Linden 2013-10-03 19:04:51 -07:00
parent 1821fa1283
commit f8a85003dd
7 changed files with 47 additions and 42 deletions

View File

@ -326,7 +326,7 @@ inline void claim_alloc(MemStatHandle& measurement, const T& value)
if(size == 0) return;
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mFootprintAllocations.record(size);
accumulator.mAllocations.record(size);
}
template<typename T>
@ -336,7 +336,7 @@ inline void disclaim_alloc(MemStatHandle& measurement, const T& value)
if(size == 0) return;
MemStatAccumulator& accumulator = measurement.getCurrentAccumulator();
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mFootprintDeallocations.add(size);
accumulator.mDeallocations.add(size);
}
template<typename DERIVED, size_t ALIGNMENT = LL_DEFAULT_HEAP_ALIGN>

View File

@ -48,7 +48,12 @@ AccumulatorBufferGroup::AccumulatorBufferGroup()
claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));
}
AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup&)
AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other)
: mCounts(other.mCounts),
mSamples(other.mSamples),
mEvents(other.mEvents),
mStackTimers(other.mStackTimers),
mMemStats(other.mMemStats)
{
claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator));
claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator));

View File

@ -266,8 +266,8 @@ namespace LLTrace
void sync(F64SecondsImplicit) {}
F64 getSum() const { return mSum; }
F64 getMin() const { return mMin; }
F64 getMax() const { return mMax; }
F32 getMin() const { return mMin; }
F32 getMax() const { return mMax; }
F64 getLastValue() const { return mLastValue; }
F64 getMean() const { return mMean; }
F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mNumSamples); }
@ -277,13 +277,14 @@ namespace LLTrace
private:
F64 mSum,
mMin,
mMax,
mLastValue;
F64 mMean,
mSumOfSquares;
F32 mMin,
mMax;
S32 mNumSamples;
};
@ -350,8 +351,8 @@ namespace LLTrace
}
F64 getSum() const { return mSum; }
F64 getMin() const { return mMin; }
F64 getMax() const { return mMax; }
F32 getMin() const { return mMin; }
F32 getMax() const { return mMax; }
F64 getLastValue() const { return mLastValue; }
F64 getMean() const { return mMean; }
F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); }
@ -362,12 +363,8 @@ namespace LLTrace
private:
F64 mSum,
mMin,
mMax,
mLastValue;
bool mHasValue; // distinct from mNumSamples, since we might have inherited an old sample
F64 mMean,
mSumOfSquares;
@ -375,7 +372,13 @@ namespace LLTrace
mLastSampleTimeStamp,
mTotalSamplingTime;
F32 mMin,
mMax;
S32 mNumSamples;
// distinct from mNumSamples, since we might have inherited a last value from
// a previous sampling period
bool mHasValue;
};
class CountAccumulator
@ -505,8 +508,8 @@ namespace LLTrace
void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type)
{
mFootprintAllocations.addSamples(other.mFootprintAllocations, append_type);
mFootprintDeallocations.addSamples(other.mFootprintDeallocations, append_type);
mAllocations.addSamples(other.mAllocations, append_type);
mDeallocations.addSamples(other.mDeallocations, append_type);
if (append_type == SEQUENTIAL)
{
@ -514,7 +517,7 @@ namespace LLTrace
}
else
{
F64 allocation_delta(other.mFootprintAllocations.getSum() - other.mFootprintDeallocations.getSum());
F64 allocation_delta(other.mAllocations.getSum() - other.mDeallocations.getSum());
mSize.sample(mSize.hasValue()
? mSize.getLastValue() + allocation_delta
: allocation_delta);
@ -524,8 +527,8 @@ namespace LLTrace
void reset(const MemStatAccumulator* other)
{
mSize.reset(other ? &other->mSize : NULL);
mFootprintAllocations.reset(other ? &other->mFootprintAllocations : NULL);
mFootprintDeallocations.reset(other ? &other->mFootprintDeallocations : NULL);
mAllocations.reset(other ? &other->mAllocations : NULL);
mDeallocations.reset(other ? &other->mDeallocations : NULL);
}
void sync(F64SecondsImplicit time_stamp)
@ -534,13 +537,14 @@ namespace LLTrace
}
SampleAccumulator mSize;
EventAccumulator mFootprintAllocations;
CountAccumulator mFootprintDeallocations;
EventAccumulator mAllocations;
CountAccumulator mDeallocations;
};
struct AccumulatorBufferGroup : public LLRefCount
{
AccumulatorBufferGroup();
AccumulatorBufferGroup(const AccumulatorBufferGroup&);
~AccumulatorBufferGroup();
void handOffTo(AccumulatorBufferGroup& other);

View File

@ -45,7 +45,7 @@ Recording::Recording(EPlayState state)
: mElapsedSeconds(0),
mInHandOff(false)
{
claim_alloc(gTraceMemStat, sizeof(*this));
claim_alloc(gTraceMemStat, this);
mBuffers = new AccumulatorBufferGroup();
claim_alloc(gTraceMemStat, mBuffers);
setPlayState(state);
@ -53,7 +53,7 @@ Recording::Recording(EPlayState state)
Recording::Recording( const Recording& other )
{
claim_alloc(gTraceMemStat, sizeof(*this));
claim_alloc(gTraceMemStat, this);
*this = other;
}
@ -79,7 +79,7 @@ Recording& Recording::operator = (const Recording& other)
Recording::~Recording()
{
disclaim_alloc(gTraceMemStat, sizeof(*this));
disclaim_alloc(gTraceMemStat, this);
disclaim_alloc(gTraceMemStat, mBuffers);
if (isStarted() && LLTrace::get_thread_recorder().notNull())
@ -209,32 +209,32 @@ F64Kilobytes Recording::getLastValue(const TraceType<MemStatAccumulator>& stat)
F64Kilobytes Recording::getSum(const TraceType<MemStatAccumulator::AllocationFacet>& stat)
{
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum());
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum());
}
F64Kilobytes Recording::getPerSec(const TraceType<MemStatAccumulator::AllocationFacet>& stat)
{
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum() / mElapsedSeconds.value());
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value());
}
S32 Recording::getSampleCount(const TraceType<MemStatAccumulator::AllocationFacet>& stat)
{
return mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSampleCount();
return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount();
}
F64Kilobytes Recording::getSum(const TraceType<MemStatAccumulator::DeallocationFacet>& stat)
{
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum());
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum());
}
F64Kilobytes Recording::getPerSec(const TraceType<MemStatAccumulator::DeallocationFacet>& stat)
{
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum() / mElapsedSeconds.value());
return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value());
}
S32 Recording::getSampleCount(const TraceType<MemStatAccumulator::DeallocationFacet>& stat)
{
return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount();
return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount();
}
F64 Recording::getSum( const TraceType<CountAccumulator>& stat )
@ -339,12 +339,12 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state)
mRecordingPeriods(num_periods ? num_periods : 1)
{
setPlayState(state);
claim_alloc(gTraceMemStat, sizeof(*this));
claim_alloc(gTraceMemStat, this);
}
PeriodicRecording::~PeriodicRecording()
{
disclaim_alloc(gTraceMemStat, sizeof(*this));
disclaim_alloc(gTraceMemStat, this);
}
void PeriodicRecording::nextPeriod()

View File

@ -62,7 +62,7 @@ static const S32 MAX_VISIBLE_HISTORY = 12;
static const S32 LINE_GRAPH_HEIGHT = 240;
static const S32 MIN_BAR_HEIGHT = 3;
static const S32 RUNNING_AVERAGE_WIDTH = 100;
static const S32 NUM_FRAMES_HISTORY = 256;
static const S32 NUM_FRAMES_HISTORY = 200;
std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)

View File

@ -87,12 +87,12 @@ private:
mFirstChild(false),
mLastChild(false)
{}
F32Seconds mTotalTime,
mSelfTime,
mChildrenStart,
mChildrenEnd,
mSelfStart,
mSelfEnd;
F32Seconds mTotalTime,
mSelfTime,
mChildrenStart,
mChildrenEnd,
mSelfStart,
mSelfEnd;
LLTrace::TimeBlock* mTimeBlock;
bool mVisible,
mFirstChild,

View File

@ -2176,10 +2176,6 @@ bool idle_startup()
// reset keyboard focus to sane state of pointing at world
gFocusMgr.setKeyboardFocus(NULL);
#if 0 // sjb: enable for auto-enabling timer display
gDebugView->mFastTimerView->setVisible(TRUE);
#endif
LLAppViewer::instance()->handleLoginComplete();
LLAgentPicksInfo::getInstance()->requestNumberOfPicks();