qchbai / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Expose a few additional stats through MallocExtension's getNumericProperty() function #410

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Expose the central cache free list size, transfer
cache free list size, and meta data overhead size.

SVN Patch:

Index: src/tcmalloc.cc
===================================================================
--- src/tcmalloc.cc     (revision 145)
+++ src/tcmalloc.cc     (working copy)
@@ -656,6 +656,27 @@
       return true;
     }

+    if (strcmp(name, "tcmalloc.central_cache_free_bytes") == 0) {
+      TCMallocStats stats;
+      ExtractStats(&stats, NULL, NULL, NULL);
+      *value = stats.central_bytes;
+      return true;
+    }
+
+    if (strcmp(name, "tcmalloc.transfer_cache_free_bytes") == 0) {
+      TCMallocStats stats;
+      ExtractStats(&stats, NULL, NULL, NULL);
+      *value = stats.transfer_bytes;
+      return true;
+    }
+
+    if (strcmp(name, "tcmalloc.thread_cache_free_bytes") == 0) {
+      TCMallocStats stats;
+      ExtractStats(&stats, NULL, NULL, NULL);
+      *value = stats.thread_bytes;
+      return true;
+    }
+
     if (strcmp(name, "tcmalloc.pageheap_free_bytes") == 0) {
       SpinLockHolder l(Static::pageheap_lock());
       *value = Static::pageheap()->stats().free_bytes;
Index: src/gperftools/malloc_extension.h
===================================================================
--- src/gperftools/malloc_extension.h   (revision 145)
+++ src/gperftools/malloc_extension.h   (working copy)
@@ -169,6 +169,26 @@
   //      Number of bytes used across all thread caches.
   //      This property is not writable.
   //
+  // "tcmalloc.central_cache_free_bytes"
+  //      Number of free bytes in the central cache that have been
+  //      assigned to size classes. They always count towards virtual
+  //      memory usage, and unless the underlying memory is swapped
out
+  //      by the OS, they also count towards physical memory usage.
+  //      This property is not writable.
+  //
+  // "tcmalloc.transfer_cache_free_bytes"
+  //      Number of free bytes that are waiting to be transfered
between
+  //      the central cache and a thread cache. They always count
+  //      towards virtual memory usage, and unless the underlying
memory
+  //      is swapped out by the OS, they also count towards physical
+  //      memory usage. This property is not writable.
+  //
+  // "tcmalloc.thread_cache_free_bytes"
+  //      Number of free bytes in thread caches. They always count
+  //      towards virtual memory usage, and unless the underlying
memory
+  //      is swapped out by the OS, they also count towards physical
+  //      memory usage. This property is not writable.
+  //
   // "tcmalloc.pageheap_free_bytes"
   //      Number of bytes in free, mapped pages in page heap.  These
   //      bytes can be used to fulfill allocation requests.  They

Original issue reported on code.google.com by chapp...@gmail.com on 2 Mar 2012 at 5:45

GoogleCodeExporter commented 9 years ago
Committed to current svn development trunk. Will close off upon next release.

Original comment by chapp...@gmail.com on 2 Mar 2012 at 6:06

GoogleCodeExporter commented 9 years ago

Original comment by chapp...@gmail.com on 18 Sep 2012 at 2:53