summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 00:33:42 +0000
committerkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 00:33:42 +0000
commit91fc247123c66d127ea4384907e7294fca2e9c53 (patch)
tree9f58597f5153433df3bd9c24c8960ca07c29b935 /third_party
parentf4e59db002be2b735b9b96b0b54ab3234851e6eb (diff)
downloadchromium_src-91fc247123c66d127ea4384907e7294fca2e9c53.zip
chromium_src-91fc247123c66d127ea4384907e7294fca2e9c53.tar.gz
chromium_src-91fc247123c66d127ea4384907e7294fca2e9c53.tar.bz2
1. A small fix of Windows VM size.
2. Re-format TCMalloc dump output (about:tcmalloc) BUG=130840 Review URL: https://chromiumcodereview.appspot.com/10499004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/tcmalloc/chromium/src/common.cc10
-rw-r--r--third_party/tcmalloc/chromium/src/common.h4
-rw-r--r--third_party/tcmalloc/chromium/src/pagemap.h8
-rw-r--r--third_party/tcmalloc/chromium/src/tcmalloc.cc30
4 files changed, 36 insertions, 16 deletions
diff --git a/third_party/tcmalloc/chromium/src/common.cc b/third_party/tcmalloc/chromium/src/common.cc
index dd175f2..5a55b39 100644
--- a/third_party/tcmalloc/chromium/src/common.cc
+++ b/third_party/tcmalloc/chromium/src/common.cc
@@ -193,6 +193,8 @@ void SizeMap::Init() {
// Metadata allocator -- keeps stats about how many bytes allocated.
static uint64_t metadata_system_bytes_ = 0;
+static uint64_t metadata_unmapped_bytes_ = 0;
+
void* MetaDataAlloc(size_t bytes) {
static size_t pagesize;
#ifdef HAVE_GETPAGESIZE
@@ -208,9 +210,13 @@ void* MetaDataAlloc(size_t bytes) {
}
uint64_t metadata_system_bytes() { return metadata_system_bytes_; }
+uint64_t metadata_unmapped_bytes() { return metadata_unmapped_bytes_; }
-void increment_metadata_system_bytes(size_t bytes) {
- metadata_system_bytes_ += bytes;
+void update_metadata_system_bytes(int diff) {
+ metadata_system_bytes_ += diff;
+}
+void update_metadata_unmapped_bytes(int diff) {
+ metadata_unmapped_bytes_ += diff;
}
} // namespace tcmalloc
diff --git a/third_party/tcmalloc/chromium/src/common.h b/third_party/tcmalloc/chromium/src/common.h
index 2d24218..c8ceb61 100644
--- a/third_party/tcmalloc/chromium/src/common.h
+++ b/third_party/tcmalloc/chromium/src/common.h
@@ -248,10 +248,12 @@ void* MetaDataAlloc(size_t bytes);
// Returns the total number of bytes allocated from the system.
// Requires pageheap_lock is held.
uint64_t metadata_system_bytes();
+uint64_t metadata_unmapped_bytes();
// Adjust metadata_system_bytes to indicate that bytes are actually committed.
// Requires pageheap_lock is held.
-void increment_metadata_system_bytes(size_t bytes);
+void update_metadata_system_bytes(int diff);
+void update_metadata_unmapped_bytes(int diff);
// size/depth are made the same size as a pointer so that some generic
// code below can conveniently cast them back and forth to void*.
diff --git a/third_party/tcmalloc/chromium/src/pagemap.h b/third_party/tcmalloc/chromium/src/pagemap.h
index 0db01c4..0186197 100644
--- a/third_party/tcmalloc/chromium/src/pagemap.h
+++ b/third_party/tcmalloc/chromium/src/pagemap.h
@@ -166,8 +166,11 @@ class TCMalloc_PageMap1_LazyCommit {
// TODO(jar): We need a reservation function, but current API to this class
// only provides an allocator.
// Get decommitted memory. We will commit as necessary.
+ size_t size = sizeof(*array_) << BITS;
array_ = reinterpret_cast<void**>(VirtualAlloc(
- NULL, sizeof(*array_) << BITS, MEM_RESERVE, PAGE_READWRITE));
+ NULL, size, MEM_RESERVE, PAGE_READWRITE));
+ tcmalloc::update_metadata_system_bytes(size);
+ tcmalloc::update_metadata_unmapped_bytes(size);
// Make sure we divided LENGTH evenly.
ASSERT(sizeof(committed_) * 8 == (LENGTH * sizeof(*array_)) >> kPageShift);
@@ -255,9 +258,8 @@ class TCMalloc_PageMap1_LazyCommit {
ASSERT(info.RegionSize >= length); // Entire length is uncommitted.
#endif
- // TODO(jar): We need a commit that automatically tallies metadata_bytes.
TCMalloc_SystemCommit(start, length);
- tcmalloc::increment_metadata_system_bytes(length);
+ tcmalloc::update_metadata_unmapped_bytes(-length);
#ifndef NDEBUG
result = VirtualQuery(start, &info, sizeof(info));
diff --git a/third_party/tcmalloc/chromium/src/tcmalloc.cc b/third_party/tcmalloc/chromium/src/tcmalloc.cc
index 219a370..aa29436 100644
--- a/third_party/tcmalloc/chromium/src/tcmalloc.cc
+++ b/third_party/tcmalloc/chromium/src/tcmalloc.cc
@@ -316,6 +316,8 @@ struct TCMallocStats {
uint64_t central_bytes; // Bytes in central cache
uint64_t transfer_bytes; // Bytes in central transfer cache
uint64_t metadata_bytes; // Bytes alloced for metadata
+ uint64_t metadata_unmapped_bytes; // Address space reserved for metadata
+ // but is not committed.
PageHeap::Stats pageheap; // Stats from page heap
};
@@ -342,6 +344,7 @@ static void ExtractStats(TCMallocStats* r, uint64_t* class_count,
SpinLockHolder h(Static::pageheap_lock());
ThreadCache::GetThreadStats(&r->thread_bytes, class_count);
r->metadata_bytes = tcmalloc::metadata_system_bytes();
+ r->metadata_unmapped_bytes = tcmalloc::metadata_unmapped_bytes();
r->pageheap = Static::pageheap()->stats();
if (small_spans != NULL) {
Static::pageheap()->GetSmallSpanStats(small_spans);
@@ -370,24 +373,30 @@ static void DumpStats(TCMalloc_Printer* out, int level) {
static const double MiB = 1048576.0;
+ const uint64_t physical_memory_used_by_metadata =
+ stats.metadata_bytes - stats.metadata_unmapped_bytes;
+ const uint64_t unmapped_bytes =
+ stats.pageheap.unmapped_bytes + stats.metadata_unmapped_bytes;
+
const uint64_t virtual_memory_used = (stats.pageheap.system_bytes
+ stats.metadata_bytes);
- const uint64_t physical_memory_used = (virtual_memory_used
- - stats.pageheap.unmapped_bytes);
+ const uint64_t physical_memory_used = virtual_memory_used - unmapped_bytes;
const uint64_t bytes_in_use_by_app = (physical_memory_used
- - stats.metadata_bytes
+ - physical_memory_used_by_metadata
- stats.pageheap.free_bytes
- stats.central_bytes
- stats.transfer_bytes
- stats.thread_bytes);
out->printf(
- "WASTE: %7.1f MiB committed but not used\n"
- "WASTE: %7.1f MiB bytes committed, %7.1f MiB bytes in use\n"
+ "WASTE: %7.1f MiB bytes in use\n"
+ "WASTE: + %7.1f MiB committed but not used\n"
+ "WASTE: ------------\n"
+ "WASTE: = %7.1f MiB bytes committed\n"
"WASTE: committed/used ratio of %f\n",
+ bytes_in_use_by_app / MiB,
(stats.pageheap.committed_bytes - bytes_in_use_by_app) / MiB,
stats.pageheap.committed_bytes / MiB,
- bytes_in_use_by_app / MiB,
stats.pageheap.committed_bytes / static_cast<double>(bytes_in_use_by_app)
);
#ifdef TCMALLOC_SMALL_BUT_SLOW
@@ -397,11 +406,12 @@ static void DumpStats(TCMalloc_Printer* out, int level) {
out->printf(
"------------------------------------------------\n"
"MALLOC: %12" PRIu64 " (%7.1f MiB) Bytes in use by application\n"
- "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes committed\n"
"MALLOC: + %12" PRIu64 " (%7.1f MiB) Bytes in page heap freelist\n"
"MALLOC: + %12" PRIu64 " (%7.1f MiB) Bytes in central cache freelist\n"
"MALLOC: + %12" PRIu64 " (%7.1f MiB) Bytes in transfer cache freelist\n"
"MALLOC: + %12" PRIu64 " (%7.1f MiB) Bytes in thread cache freelists\n"
+ "MALLOC: ------------\n"
+ "MALLOC: = %12" PRIu64 " (%7.1f MiB) Bytes committed\n"
"MALLOC: + %12" PRIu64 " (%7.1f MiB) Bytes in malloc metadata\n"
"MALLOC: ------------\n"
"MALLOC: = %12" PRIu64 " (%7.1f MiB) Actual memory used (physical + swap)\n"
@@ -418,14 +428,14 @@ static void DumpStats(TCMalloc_Printer* out, int level) {
"Bytes released to the OS take up virtual address space"
" but no physical memory.\n",
bytes_in_use_by_app, bytes_in_use_by_app / MiB,
- stats.pageheap.committed_bytes, stats.pageheap.committed_bytes / MiB,
stats.pageheap.free_bytes, stats.pageheap.free_bytes / MiB,
stats.central_bytes, stats.central_bytes / MiB,
stats.transfer_bytes, stats.transfer_bytes / MiB,
stats.thread_bytes, stats.thread_bytes / MiB,
- stats.metadata_bytes, stats.metadata_bytes / MiB,
+ stats.pageheap.committed_bytes, stats.pageheap.committed_bytes / MiB,
+ physical_memory_used_by_metadata , physical_memory_used_by_metadata / MiB,
physical_memory_used, physical_memory_used / MiB,
- stats.pageheap.unmapped_bytes, stats.pageheap.unmapped_bytes / MiB,
+ unmapped_bytes, unmapped_bytes / MiB,
virtual_memory_used, virtual_memory_used / MiB,
uint64_t(Static::span_allocator()->inuse()),
uint64_t(ThreadCache::HeapsInUse()),