Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1384)

Unified Diff: third_party/tcmalloc/chromium/src/thread_cache.h

Issue 9212025: Support use of third party time function to profiler (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/tcmalloc/chromium/src/tcmalloc.cc ('k') | third_party/tcmalloc/chromium/src/thread_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/chromium/src/thread_cache.h
===================================================================
--- third_party/tcmalloc/chromium/src/thread_cache.h (revision 121705)
+++ third_party/tcmalloc/chromium/src/thread_cache.h (working copy)
@@ -96,6 +96,17 @@
// should be sampled
bool SampleAllocation(size_t k);
+ // Record additional bytes allocated.
+ void AddToByteAllocatedTotal(size_t k) { total_bytes_allocated_ += k; }
+
+ // Return the total number of bytes allocated from this heap. The value will
+ // wrap when there is an overflow, and so only the differences between two
+ // values should be relied on (and even then, modulo 2^32).
+ uint32 GetTotalBytesAllocated() const;
+
+ // On the current thread, return GetTotalBytesAllocated().
+ static uint32 GetBytesAllocatedOnCurrentThread();
+
static void InitModule();
static void InitTSD();
static ThreadCache* GetThreadHeap();
@@ -291,6 +302,14 @@
size_t size_; // Combined size of data
size_t max_size_; // size_ > max_size_ --> Scavenge()
+ // The following is the tally of bytes allocated on a thread as a response to
+ // any flavor of malloc() call. The aggegated amount includes all padding to
+ // the smallest class that can hold the request, or to the nearest whole page
+ // when a large allocation is made without using a class. This sum is
+ // currently used for Chromium profiling, where tallies are kept of the amount
+ // of memory allocated during the running of each task on each thread.
+ uint32 total_bytes_allocated_; // Total, modulo 2^32.
+
// We sample allocations, biased by the size of the allocation
Sampler sampler_; // A sampler
@@ -327,6 +346,10 @@
return sampler_.SampleAllocation(k);
}
+inline uint32 ThreadCache::GetTotalBytesAllocated() const {
+ return total_bytes_allocated_;
+}
+
inline void* ThreadCache::Allocate(size_t size, size_t cl) {
ASSERT(size <= kMaxSize);
ASSERT(size == Static::sizemap()->ByteSizeForClass(cl));
« no previous file with comments | « third_party/tcmalloc/chromium/src/tcmalloc.cc ('k') | third_party/tcmalloc/chromium/src/thread_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698