diff options
author | Aliaksey Kandratsenka <alkondratenko@gmail.com> | 2017-02-21 00:41:43 -0800 |
---|---|---|
committer | Aliaksey Kandratsenka <alkondratenko@gmail.com> | 2017-05-14 19:04:55 -0700 |
commit | 27da4ade70d45312bfdf334aa8cf0d63bf78df14 (patch) | |
tree | 5e27c52a77fd94def4b7f04a998a988ee070de4c | |
parent | 335f09d4e43a8413642e17e5ac374f925906c4e3 (diff) | |
download | gperftools-27da4ade70d45312bfdf334aa8cf0d63bf78df14.tar.gz |
reduce size of class_to_size_ array
Since 32-bit int is enough and accessing smaller array will use a bit
less of cache.
-rw-r--r-- | src/common.h | 6 | ||||
-rw-r--r-- | src/tcmalloc.cc | 6 | ||||
-rw-r--r-- | src/thread_cache.cc | 2 | ||||
-rw-r--r-- | src/thread_cache.h | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h index fe09d5b..d137084 100644 --- a/src/common.h +++ b/src/common.h @@ -222,7 +222,7 @@ class SizeMap { int NumMoveSize(size_t size); // Mapping from size class to max size storable in that class - size_t class_to_size_[kNumClasses]; + int32 class_to_size_[kNumClasses]; // Mapping from size class to number of pages to allocate at a time size_t class_to_pages_[kNumClasses]; @@ -253,12 +253,12 @@ class SizeMap { } // Get the byte-size for a specified class - inline size_t ByteSizeForClass(size_t cl) { + inline int32 ByteSizeForClass(size_t cl) { return class_to_size_[cl]; } // Mapping from size class to max size storable in that class - inline size_t class_to_size(size_t cl) { + inline int32 class_to_size(size_t cl) { return class_to_size_[cl]; } diff --git a/src/tcmalloc.cc b/src/tcmalloc.cc index 0438b69..2db0efe 100644 --- a/src/tcmalloc.cc +++ b/src/tcmalloc.cc @@ -434,12 +434,12 @@ static void DumpStats(TCMalloc_Printer* out, int level) { uint64_t cumulative = 0; for (int cl = 0; cl < kNumClasses; ++cl) { if (class_count[cl] > 0) { - uint64_t class_bytes = - class_count[cl] * Static::sizemap()->ByteSizeForClass(cl); + size_t cl_size = Static::sizemap()->ByteSizeForClass(cl); + uint64_t class_bytes = class_count[cl] * cl_size; cumulative += class_bytes; out->printf("class %3d [ %8" PRIuS " bytes ] : " "%8" PRIu64 " objs; %5.1f MiB; %5.1f cum MiB\n", - cl, Static::sizemap()->ByteSizeForClass(cl), + cl, cl_size, class_count[cl], class_bytes / MiB, cumulative / MiB); diff --git a/src/thread_cache.cc b/src/thread_cache.cc index 82474e6..f0f6bfc 100644 --- a/src/thread_cache.cc +++ b/src/thread_cache.cc @@ -115,7 +115,7 @@ void ThreadCache::Cleanup() { // Remove some objects of class "cl" from central cache and add to thread heap. // On success, return the first object for immediate use; otherwise return NULL. -void* ThreadCache::FetchFromCentralCache(size_t cl, size_t byte_size) { +void* ThreadCache::FetchFromCentralCache(size_t cl, int32_t byte_size) { FreeList* list = &list_[cl]; ASSERT(list->empty()); const int batch_size = Static::sizemap()->num_objects_to_move(cl); diff --git a/src/thread_cache.h b/src/thread_cache.h index c6e3eb4..ad5ce3e 100644 --- a/src/thread_cache.h +++ b/src/thread_cache.h @@ -231,7 +231,7 @@ class ThreadCache { // Gets and returns an object from the central cache, and, if possible, // also adds some objects of that size class to this thread cache. - void* FetchFromCentralCache(size_t cl, size_t byte_size); + void* FetchFromCentralCache(size_t cl, int32_t byte_size); // Releases some number of items from src. Adjusts the list's max_length // to eventually converge on num_objects_to_move(cl). |