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

Side by Side Diff: third_party/tcmalloc/chromium/src/common.h

Issue 7430007: Merge tcmalloc r111 (perftools v. 1.8) with the chromium/ branch. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Deallocation may speed up by a factor as the page map gets 8x smaller, so 56 // Deallocation may speed up by a factor as the page map gets 8x smaller, so
57 // lookups in the page map result in fewer L2 cache misses, which translates to 57 // lookups in the page map result in fewer L2 cache misses, which translates to
58 // speedup for application/platform combinations with high L2 cache pressure. 58 // speedup for application/platform combinations with high L2 cache pressure.
59 // As the number of size classes increases with large pages, we increase 59 // As the number of size classes increases with large pages, we increase
60 // the thread cache allowance to avoid passing more free ranges to and from 60 // the thread cache allowance to avoid passing more free ranges to and from
61 // central lists. Also, larger pages are less likely to get freed. 61 // central lists. Also, larger pages are less likely to get freed.
62 // These two factors cause a bounded increase in memory use. 62 // These two factors cause a bounded increase in memory use.
63 63
64 #if defined(TCMALLOC_LARGE_PAGES) 64 #if defined(TCMALLOC_LARGE_PAGES)
65 static const size_t kPageShift = 15; 65 static const size_t kPageShift = 15;
66 static const size_t kNumClasses = 95; 66 static const size_t kNumClasses = 78;
67 #else
68 static const size_t kPageShift = 13;
jar (doing other things) 2011/07/31 08:19:39 This is the change to 8K pages from 4K. The recen
69 static const size_t kNumClasses = 86;
70 #endif
67 static const size_t kMaxThreadCacheSize = 4 << 20; 71 static const size_t kMaxThreadCacheSize = 4 << 20;
jar (doing other things) 2011/07/31 08:19:39 This looks like another change (for us, since we d
68 #else
69 static const size_t kPageShift = 12;
70 static const size_t kNumClasses = 61;
71 static const size_t kMaxThreadCacheSize = 2 << 20;
72 #endif
73 72
74 static const size_t kPageSize = 1 << kPageShift; 73 static const size_t kPageSize = 1 << kPageShift;
75 static const size_t kMaxSize = 8u * kPageSize; 74 static const size_t kMaxSize = 256 * 1024;
jar (doing other things) 2011/07/31 08:19:39 This is a big tuning change, upping the cutoff poi
76 static const size_t kAlignment = 8; 75 static const size_t kAlignment = 8;
77 // For all span-lengths < kMaxPages we keep an exact-size list. 76 // For all span-lengths < kMaxPages we keep an exact-size list.
78 static const size_t kMaxPages = 1 << (20 - kPageShift); 77 static const size_t kMaxPages = 1 << (20 - kPageShift);
79 78
80 // Default bound on the total amount of thread caches. 79 // Default bound on the total amount of thread caches.
81 #ifdef TCMALLOC_SMALL_BUT_SLOW 80 #ifdef TCMALLOC_SMALL_BUT_SLOW
82 // Make the overall thread cache no bigger than that of a single thread 81 // Make the overall thread cache no bigger than that of a single thread
83 // for the small memory footprint case. 82 // for the small memory footprint case.
84 static const size_t kDefaultOverallThreadCacheSize = kMaxThreadCacheSize; 83 static const size_t kDefaultOverallThreadCacheSize = kMaxThreadCacheSize;
85 #else 84 #else
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // ------------------------------------------------------- 157 // -------------------------------------------------------
159 // 0 (0 + 7) / 8 0 158 // 0 (0 + 7) / 8 0
160 // 1 (1 + 7) / 8 1 159 // 1 (1 + 7) / 8 1
161 // ... 160 // ...
162 // 1024 (1024 + 7) / 8 128 161 // 1024 (1024 + 7) / 8 128
163 // 1025 (1025 + 127 + (120<<7)) / 128 129 162 // 1025 (1025 + 127 + (120<<7)) / 128 129
164 // ... 163 // ...
165 // 32768 (32768 + 127 + (120<<7)) / 128 376 164 // 32768 (32768 + 127 + (120<<7)) / 128 376
166 static const int kMaxSmallSize = 1024; 165 static const int kMaxSmallSize = 1024;
167 static const size_t kClassArraySize = 166 static const size_t kClassArraySize =
168 (((1 << kPageShift) * 8u + 127 + (120 << 7)) >> 7) + 1; 167 ((kMaxSize + 127 + (120 << 7)) >> 7) + 1;
169 unsigned char class_array_[kClassArraySize]; 168 unsigned char class_array_[kClassArraySize];
170 169
171 // Compute index of the class_array[] entry for a given size 170 // Compute index of the class_array[] entry for a given size
172 static inline int ClassIndex(int s) { 171 static inline int ClassIndex(int s) {
173 ASSERT(0 <= s); 172 ASSERT(0 <= s);
174 ASSERT(s <= kMaxSize); 173 ASSERT(s <= kMaxSize);
175 const bool big = (s > kMaxSmallSize); 174 const bool big = (s > kMaxSmallSize);
176 const int add_amount = big ? (127 + (120<<7)) : 7; 175 const int add_amount = big ? (127 + (120<<7)) : 7;
177 const int shift_amount = big ? 7 : 3; 176 const int shift_amount = big ? 7 : 3;
178 return (s + add_amount) >> shift_amount; 177 return (s + add_amount) >> shift_amount;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 static const int kMaxStackDepth = 31; 243 static const int kMaxStackDepth = 31;
245 struct StackTrace { 244 struct StackTrace {
246 uintptr_t size; // Size of object 245 uintptr_t size; // Size of object
247 uintptr_t depth; // Number of PC values stored in array below 246 uintptr_t depth; // Number of PC values stored in array below
248 void* stack[kMaxStackDepth]; 247 void* stack[kMaxStackDepth];
249 }; 248 };
250 249
251 } // namespace tcmalloc 250 } // namespace tcmalloc
252 251
253 #endif // TCMALLOC_COMMON_H_ 252 #endif // TCMALLOC_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698