summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2017-11-03 16:47:21 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2017-12-04 13:30:00 -0500
commitf34fbd1a04dc2bc99057a2fb2f47ea097d11b746 (patch)
tree377c282443a6f989420fa8d0321674ebacac4d51 /src
parente8d4c699706448df0137def23532b5bc015f772d (diff)
downloadmongo-f34fbd1a04dc2bc99057a2fb2f47ea097d11b746.tar.gz
SERVER-31380 Add metrics related to tcmalloc acquiring and decommitting memory from system
(cherry picked from commit acfa4b77e4c03dc73b54baedae652478e43740a5)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp17
-rw-r--r--src/third_party/gperftools-2.2/src/page_heap.cc15
-rw-r--r--src/third_party/gperftools-2.2/src/page_heap.h14
-rw-r--r--src/third_party/gperftools-2.2/src/tcmalloc.cc48
4 files changed, 93 insertions, 1 deletions
diff --git a/src/mongo/util/tcmalloc_server_status_section.cpp b/src/mongo/util/tcmalloc_server_status_section.cpp
index cc2d6725d9b..8b43b8b4a66 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -153,6 +153,23 @@ public:
appendNumericPropertyIfAvailable(
sub, "aggressive_memory_decommit", "tcmalloc.aggressive_memory_decommit");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_committed_bytes", "tcmalloc.pageheap_committed_bytes");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_scavenge_count", "tcmalloc.pageheap_scavenge_count");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_commit_count", "tcmalloc.pageheap_commit_count");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_total_commit_bytes", "tcmalloc.pageheap_total_commit_bytes");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_decommit_count", "tcmalloc.pageheap_decommit_count");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_total_decommit_bytes", "tcmalloc.pageheap_total_decommit_bytes");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_reserve_count", "tcmalloc.pageheap_reserve_count");
+ appendNumericPropertyIfAvailable(
+ sub, "pageheap_total_reserve_bytes", "tcmalloc.pageheap_total_reserve_bytes");
+
#if MONGO_HAVE_GPERFTOOLS_SIZE_CLASS_STATS
if (verbosity >= 2) {
// Size class information
diff --git a/src/third_party/gperftools-2.2/src/page_heap.cc b/src/third_party/gperftools-2.2/src/page_heap.cc
index a60df4a49b9..48db5b7c064 100644
--- a/src/third_party/gperftools-2.2/src/page_heap.cc
+++ b/src/third_party/gperftools-2.2/src/page_heap.cc
@@ -238,16 +238,22 @@ Span* PageHeap::Split(Span* span, Length n) {
}
void PageHeap::CommitSpan(Span* span) {
+ ++stats_.commit_count;
+
TCMalloc_SystemCommit(reinterpret_cast<void*>(span->start << kPageShift),
static_cast<size_t>(span->length << kPageShift));
stats_.committed_bytes += span->length << kPageShift;
+ stats_.total_commit_bytes += (span->length << kPageShift);
}
bool PageHeap::DecommitSpan(Span* span) {
+ ++stats_.decommit_count;
+
bool rv = TCMalloc_SystemRelease(reinterpret_cast<void*>(span->start << kPageShift),
static_cast<size_t>(span->length << kPageShift));
if (rv) {
stats_.committed_bytes -= span->length << kPageShift;
+ stats_.total_decommit_bytes += (span->length << kPageShift);
}
return rv;
@@ -434,6 +440,8 @@ void PageHeap::IncrementalScavenge(Length n) {
return;
}
+ ++stats_.scavenge_count;
+
Length released_pages = ReleaseAtLeastNPages(1);
if (released_pages == 0) {
@@ -609,9 +617,16 @@ bool PageHeap::GrowHeap(Length n) {
ask = actual_size >> kPageShift;
RecordGrowth(ask << kPageShift);
+ ++stats_.reserve_count;
+ ++stats_.commit_count;
+
uint64_t old_system_bytes = stats_.system_bytes;
stats_.system_bytes += (ask << kPageShift);
stats_.committed_bytes += (ask << kPageShift);
+
+ stats_.total_commit_bytes += (ask << kPageShift);
+ stats_.total_reserve_bytes += (ask << kPageShift);
+
const PageID p = reinterpret_cast<uintptr_t>(ptr) >> kPageShift;
ASSERT(p > 0);
diff --git a/src/third_party/gperftools-2.2/src/page_heap.h b/src/third_party/gperftools-2.2/src/page_heap.h
index 18abed1974a..5c6607bbf16 100644
--- a/src/third_party/gperftools-2.2/src/page_heap.h
+++ b/src/third_party/gperftools-2.2/src/page_heap.h
@@ -143,12 +143,24 @@ class PERFTOOLS_DLL_DECL PageHeap {
// Page heap statistics
struct Stats {
- Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0), committed_bytes(0) {}
+ Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0), committed_bytes(0),
+ scavenge_count(0), commit_count(0), decommit_count(0),
+ total_commit_bytes(0), total_decommit_bytes(0),
+ reserve_count(0), total_reserve_bytes(0) {}
uint64_t system_bytes; // Total bytes allocated from system
uint64_t free_bytes; // Total bytes on normal freelists
uint64_t unmapped_bytes; // Total bytes on returned freelists
uint64_t committed_bytes; // Bytes committed, always <= system_bytes_.
+ uint64_t scavenge_count; // Number of times scavagened flush pages
+
+ uint64_t commit_count; // Number of virtual memory commits
+ uint64_t total_commit_bytes; // Bytes committed in lifetime of process
+ uint64_t decommit_count; // Number of virtual memory decommits
+ uint64_t total_decommit_bytes; // Bytes decommitted in lifetime of process
+
+ uint64_t reserve_count; // Number of virtual memory reserves
+ uint64_t total_reserve_bytes; // Bytes reserved in lifetime of process
};
inline Stats stats() const { return stats_; }
diff --git a/src/third_party/gperftools-2.2/src/tcmalloc.cc b/src/third_party/gperftools-2.2/src/tcmalloc.cc
index 0bc8baa5fd8..688dd92abfb 100644
--- a/src/third_party/gperftools-2.2/src/tcmalloc.cc
+++ b/src/third_party/gperftools-2.2/src/tcmalloc.cc
@@ -712,6 +712,54 @@ class TCMallocImplementation : public MallocExtension {
return true;
}
+ if (strcmp(name, "tcmalloc.pageheap_committed_bytes") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().committed_bytes;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_scavenge_count") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().scavenge_count;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_commit_count") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().commit_count;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_total_commit_bytes") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().total_commit_bytes;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_decommit_count") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().decommit_count;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_total_decommit_bytes") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().total_decommit_bytes;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_reserve_count") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().reserve_count;
+ return true;
+ }
+
+ if (strcmp(name, "tcmalloc.pageheap_total_reserve_bytes") == 0) {
+ SpinLockHolder l(Static::pageheap_lock());
+ *value = Static::pageheap()->stats().total_reserve_bytes;
+ return true;
+ }
+
if (strcmp(name, "tcmalloc.max_total_thread_cache_bytes") == 0) {
SpinLockHolder l(Static::pageheap_lock());
*value = ThreadCache::overall_thread_cache_size();