issue-466: Clarified stats output and comments for ExtractStats() and GetThreadStats()

git-svn-id: http://gperftools.googlecode.com/svn/trunk@188 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
This commit is contained in:
chappedm@gmail.com 2012-12-22 19:06:35 +00:00
parent 09d97533b0
commit a5dacccd6a
2 changed files with 16 additions and 7 deletions

View File

@ -299,7 +299,10 @@ struct TCMallocStats {
PageHeap::Stats pageheap; // Stats from page heap
};
// Get stats into "r". Also get per-size-class counts if class_count != NULL
// Get stats into "r". Also, if class_count != NULL, class_count[k]
// will be set to the total number of objects of size class k in the
// central cache, transfer cache, and per-thread caches. If small_spans
// is non-NULL, it is filled. Same for large_spans.
static void ExtractStats(TCMallocStats* r, uint64_t* class_count,
PageHeap::SmallSpanStats* small_spans,
PageHeap::LargeSpanStats* large_spans) {
@ -313,7 +316,12 @@ static void ExtractStats(TCMallocStats* r, uint64_t* class_count,
Static::sizemap()->ByteSizeForClass(cl));
r->central_bytes += (size * length) + cache_overhead;
r->transfer_bytes += (size * tc_length);
if (class_count) class_count[cl] = length + tc_length;
if (class_count) {
// Sum the lengths of all per-class freelists, except the per-thread
// freelists, which get counted when we call GetThreadStats(), below.
class_count[cl] = length + tc_length;
}
}
// Add stats from per-thread heaps
@ -402,7 +410,8 @@ static void DumpStats(TCMalloc_Printer* out, int level) {
if (level >= 2) {
out->printf("------------------------------------------------\n");
out->printf("Size class breakdown\n");
out->printf("Total size of freelists for per-thread caches,\n");
out->printf("transfer cache, and central cache, by size class\n");
out->printf("------------------------------------------------\n");
uint64_t cumulative = 0;
for (int cl = 0; cl < kNumClasses; ++cl) {

View File

@ -123,10 +123,10 @@ class ThreadCache {
// Return the number of thread heaps in use.
static inline int HeapsInUse();
// Writes to total_bytes the total number of bytes used by all thread heaps.
// class_count must be an array of size kNumClasses. Writes the number of
// items on the corresponding freelist. class_count may be NULL.
// The storage of both parameters must be zero intialized.
// Adds to *total_bytes the total number of bytes used by all thread heaps.
// Also, if class_count is not NULL, it must be an array of size kNumClasses,
// and this function will increment each element of class_count by the number
// of items in all thread-local freelists of the corresponding size class.
// REQUIRES: Static::pageheap_lock is held.
static void GetThreadStats(uint64_t* total_bytes, uint64_t* class_count);