summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltraceaccumulators.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-09-23 16:07:32 -0700
committerRichard Linden <none@none>2013-09-23 16:07:32 -0700
commite25b5a359faaf4bb51186235567fcb1fea15e440 (patch)
tree8af498e5753aa49a56fe6b88224f89cda89d19ad /indra/llcommon/lltraceaccumulators.h
parentb16fb80906b4098b68d8f555998f42a3017ee095 (diff)
refactored lltrace mem tracking to store allocation and deallocation sizes
at the same time and work better with threads
Diffstat (limited to 'indra/llcommon/lltraceaccumulators.h')
-rw-r--r--indra/llcommon/lltraceaccumulators.h58
1 files changed, 41 insertions, 17 deletions
diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h
index c5a0693fef..37a35f4e23 100644
--- a/indra/llcommon/lltraceaccumulators.h
+++ b/indra/llcommon/lltraceaccumulators.h
@@ -475,40 +475,62 @@ namespace LLTrace
typedef MemStatAccumulator self_t;
// fake classes that allows us to view different facets of underlying statistic
- struct AllocationCountFacet
+ struct AllocationFacet
{
- typedef U32 value_t;
+ typedef F64Bytes value_t;
};
- struct DeallocationCountFacet
+ struct DeallocationFacet
{
- typedef U32 value_t;
+ typedef F64Bytes value_t;
};
- struct ShadowMemFacet
+ struct ShadowAllocationFacet
{
typedef F64Bytes value_t;
};
- MemStatAccumulator()
- : mAllocatedCount(0),
- mDeallocatedCount(0)
- {}
+ struct ShadowDeallocationFacet
+ {
+ typedef F64Bytes value_t;
+ };
+
+ struct ShadowMemFacet
+ {
+ typedef F64Bytes value_t;
+ };
void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type)
{
- mSize.addSamples(other.mSize, append_type);
- mShadowSize.addSamples(other.mShadowSize, append_type);
- mAllocatedCount += other.mAllocatedCount;
- mDeallocatedCount += other.mDeallocatedCount;
+ mAllocated.addSamples(other.mAllocated, append_type);
+ mDeallocated.addSamples(other.mDeallocated, append_type);
+ if (append_type == SEQUENTIAL)
+ {
+ mSize.addSamples(other.mSize, SEQUENTIAL);
+ mShadowSize.addSamples(other.mShadowSize, SEQUENTIAL);
+ }
+ else
+ {
+ F64 allocation_delta(other.mAllocated.getSum() - other.mDeallocated.getSum());
+ mSize.sample(mSize.hasValue()
+ ? mSize.getLastValue() + allocation_delta
+ : allocation_delta);
+
+ F64 shadow_allocation_delta(other.mShadowAllocated.getSum() - other.mShadowDeallocated.getSum());
+ mShadowSize.sample(mShadowSize.hasValue()
+ ? mShadowSize.getLastValue() + shadow_allocation_delta
+ : shadow_allocation_delta);
+ }
}
void reset(const MemStatAccumulator* other)
{
mSize.reset(other ? &other->mSize : NULL);
mShadowSize.reset(other ? &other->mShadowSize : NULL);
- mAllocatedCount = 0;
- mDeallocatedCount = 0;
+ mAllocated.reset(other ? &other->mAllocated : NULL);
+ mDeallocated.reset(other ? &other->mDeallocated : NULL);
+ mShadowAllocated.reset(other ? &other->mShadowAllocated : NULL);
+ mShadowDeallocated.reset(other ? &other->mShadowDeallocated : NULL);
}
void sync(F64SecondsImplicit time_stamp)
@@ -519,8 +541,10 @@ namespace LLTrace
SampleAccumulator mSize,
mShadowSize;
- int mAllocatedCount,
- mDeallocatedCount;
+ CountAccumulator mAllocated,
+ mDeallocated,
+ mShadowAllocated,
+ mShadowDeallocated;
};
struct AccumulatorBufferGroup : public LLRefCount