MCPcopy Create free account
hub / github.com/beefytech/Beef / ExtractStats

Function ExtractStats

BeefTools/BeefMem/gperftools/src/tcmalloc.cc:308–343  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

306// central cache, transfer cache, and per-thread caches. If small_spans
307// is non-NULL, it is filled. Same for large_spans.
308static void ExtractStats(TCMallocStats* r, uint64_t* class_count,
309 PageHeap::SmallSpanStats* small_spans,
310 PageHeap::LargeSpanStats* large_spans) {
311 r->central_bytes = 0;
312 r->transfer_bytes = 0;
313 for (int cl = 0; cl < kNumClasses; ++cl) {
314 const int length = Static::central_cache()[cl].length();
315 const int tc_length = Static::central_cache()[cl].tc_length();
316 const size_t cache_overhead = Static::central_cache()[cl].OverheadBytes();
317 const size_t size = static_cast<uint64_t>(
318 Static::sizemap()->ByteSizeForClass(cl));
319 r->central_bytes += (size * length) + cache_overhead;
320 r->transfer_bytes += (size * tc_length);
321 if (class_count) {
322 // Sum the lengths of all per-class freelists, except the per-thread
323 // freelists, which get counted when we call GetThreadStats(), below.
324 class_count[cl] = length + tc_length;
325 }
326
327 }
328
329 // Add stats from per-thread heaps
330 r->thread_bytes = 0;
331 { // scope
332 SpinLockHolder h(Static::pageheap_lock());
333 ThreadCache::GetThreadStats(&r->thread_bytes, class_count);
334 r->metadata_bytes = tcmalloc::metadata_system_bytes();
335 r->pageheap = Static::pageheap()->stats();
336 if (small_spans != NULL) {
337 Static::pageheap()->GetSmallSpanStats(small_spans);
338 }
339 if (large_spans != NULL) {
340 Static::pageheap()->GetLargeSpanStats(large_spans);
341 }
342 }
343}
344
345static double PagesToMiB(uint64_t pages) {
346 return (pages << kPageShift) / 1048576.0;

Callers 3

DumpStatsFunction · 0.70
GetNumericPropertyMethod · 0.70
do_mallinfoFunction · 0.70

Calls 7

metadata_system_bytesFunction · 0.70
lengthMethod · 0.45
tc_lengthMethod · 0.45
OverheadBytesMethod · 0.45
ByteSizeForClassMethod · 0.45
GetSmallSpanStatsMethod · 0.45
GetLargeSpanStatsMethod · 0.45

Tested by

no test coverage detected