summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp17
-rw-r--r--src/third_party/gperftools-2.5/src/page_heap.cc15
-rw-r--r--src/third_party/gperftools-2.5/src/page_heap.h14
-rw-r--r--src/third_party/gperftools-2.5/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 303076ba784..c215956c0b3 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -156,6 +156,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.5/src/page_heap.cc b/src/third_party/gperftools-2.5/src/page_heap.cc
index f52ae2af029..eaa33255f2c 100644
--- a/src/third_party/gperftools-2.5/src/page_heap.cc
+++ b/src/third_party/gperftools-2.5/src/page_heap.cc
@@ -245,16 +245,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;
@@ -441,6 +447,8 @@ void PageHeap::IncrementalScavenge(Length n) {
return;
}
+ ++stats_.scavenge_count;
+
Length released_pages = ReleaseAtLeastNPages(1);
if (released_pages == 0) {
@@ -616,9 +624,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.5/src/page_heap.h b/src/third_party/gperftools-2.5/src/page_heap.h
index 18abed1974a..5c6607bbf16 100644
--- a/src/third_party/gperftools-2.5/src/page_heap.h
+++ b/src/third_party/gperftools-2.5/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.5/src/tcmalloc.cc b/src/third_party/gperftools-2.5/src/tcmalloc.cc
index ba6c06e9d89..782123d91ad 100644
--- a/src/third_party/gperftools-2.5/src/tcmalloc.cc
+++ b/src/third_party/gperftools-2.5/src/tcmalloc.cc
@@ -703,6 +703,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();