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

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

Issue 9699084: Try fixing virtual memory regression by new tcmalloc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 (tcmalloc::kSupportsDoublyLinkedList ? 2 : 1); 72 (tcmalloc::kSupportsDoublyLinkedList ? 2 : 1);
73 static const size_t kLinkSize = kNumFreeListPointers * sizeof(void *); 73 static const size_t kLinkSize = kNumFreeListPointers * sizeof(void *);
74 static const size_t kMinClassSize = 74 static const size_t kMinClassSize =
75 (kLinkSize > kAlignment ? kLinkSize : kAlignment); 75 (kLinkSize > kAlignment ? kLinkSize : kAlignment);
76 static const size_t kSkippedClasses = (kAlignment < kMinClassSize ? 1 : 0); 76 static const size_t kSkippedClasses = (kAlignment < kMinClassSize ? 1 : 0);
77 77
78 #if defined(TCMALLOC_LARGE_PAGES) 78 #if defined(TCMALLOC_LARGE_PAGES)
79 static const size_t kPageShift = 15; 79 static const size_t kPageShift = 15;
80 static const size_t kNumClasses = 78 - kSkippedClasses; 80 static const size_t kNumClasses = 78 - kSkippedClasses;
81 #else 81 #else
82 static const size_t kPageShift = 13; 82 // Chromium tunes kPageShift: 13 -> 12. (page size 8k -> 4k)
83 static const size_t kPageShift = 12;
83 static const size_t kNumClasses = 86 - kSkippedClasses; 84 static const size_t kNumClasses = 86 - kSkippedClasses;
jar (doing other things) 2012/03/15 19:36:49 I have the recollection we used to have fewer clas
Dai Mikurube (NOT FULLTIME) 2012/03/15 20:17:32 It fails at an assertion in common.cc... I sent a
84 #endif 85 #endif
85 static const size_t kMaxThreadCacheSize = 4 << 20; 86 static const size_t kMaxThreadCacheSize = 4 << 20;
86 87
87 static const size_t kPageSize = 1 << kPageShift; 88 static const size_t kPageSize = 1 << kPageShift;
88 // TODO(dmikurube): We Chromium may want to tune this kMaxSize. 89 // Chromium tunes kMaxSize: 256 * 1024 -> 8u * kPageSize (256k -> 32k)
jar (doing other things) 2012/03/15 19:36:49 Please use prose, rather than the symbolic "->" to
Dai Mikurube (NOT FULLTIME) 2012/03/15 20:17:32 Done.
89 static const size_t kMaxSize = 256 * 1024; 90 static const size_t kMaxSize = 8u * kPageSize;
90 // For all span-lengths < kMaxPages we keep an exact-size list. 91 // For all span-lengths < kMaxPages we keep an exact-size list.
91 static const size_t kMaxPages = 1 << (20 - kPageShift); 92 static const size_t kMaxPages = 1 << (20 - kPageShift);
92 93
93 // Default bound on the total amount of thread caches. 94 // Default bound on the total amount of thread caches.
94 #ifdef TCMALLOC_SMALL_BUT_SLOW 95 #ifdef TCMALLOC_SMALL_BUT_SLOW
95 // Make the overall thread cache no bigger than that of a single thread 96 // Make the overall thread cache no bigger than that of a single thread
96 // for the small memory footprint case. 97 // for the small memory footprint case.
97 static const size_t kDefaultOverallThreadCacheSize = kMaxThreadCacheSize; 98 static const size_t kDefaultOverallThreadCacheSize = kMaxThreadCacheSize;
98 #else 99 #else
99 static const size_t kDefaultOverallThreadCacheSize = 8u * kMaxThreadCacheSize; 100 static const size_t kDefaultOverallThreadCacheSize = 8u * kMaxThreadCacheSize;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Size Expression Index 171 // Size Expression Index
171 // ------------------------------------------------------- 172 // -------------------------------------------------------
172 // 0 (0 + 7) / 8 0 173 // 0 (0 + 7) / 8 0
173 // 1 (1 + 7) / 8 1 174 // 1 (1 + 7) / 8 1
174 // ... 175 // ...
175 // 1024 (1024 + 7) / 8 128 176 // 1024 (1024 + 7) / 8 128
176 // 1025 (1025 + 127 + (120<<7)) / 128 129 177 // 1025 (1025 + 127 + (120<<7)) / 128 129
177 // ... 178 // ...
178 // 32768 (32768 + 127 + (120<<7)) / 128 376 179 // 32768 (32768 + 127 + (120<<7)) / 128 376
179 static const int kMaxSmallSize = 1024; 180 static const int kMaxSmallSize = 1024;
181 // Chromium tunes kClassArraySize.
180 static const size_t kClassArraySize = 182 static const size_t kClassArraySize =
181 ((kMaxSize + 127 + (120 << 7)) >> 7) + 1; 183 (((1 << kPageShift) * 8u + 127 + (120 << 7)) >> 7) + 1;
jar (doing other things) 2012/03/15 19:36:49 I don't think you need to change this line. I thi
Dai Mikurube (NOT FULLTIME) 2012/03/15 20:17:32 I thought keeping the original code implies the or
182 unsigned char class_array_[kClassArraySize]; 184 unsigned char class_array_[kClassArraySize];
183 185
184 // Compute index of the class_array[] entry for a given size 186 // Compute index of the class_array[] entry for a given size
185 static inline int ClassIndex(int s) { 187 static inline int ClassIndex(int s) {
186 ASSERT(0 <= s); 188 ASSERT(0 <= s);
187 ASSERT(s <= kMaxSize); 189 ASSERT(s <= kMaxSize);
188 const bool big = (s > kMaxSmallSize); 190 const bool big = (s > kMaxSmallSize);
189 const int add_amount = big ? (127 + (120<<7)) : 7; 191 const int add_amount = big ? (127 + (120<<7)) : 7;
190 const int shift_amount = big ? 7 : 3; 192 const int shift_amount = big ? 7 : 3;
191 return (s + add_amount) >> shift_amount; 193 return (s + add_amount) >> shift_amount;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 static const int kMaxStackDepth = 31; 256 static const int kMaxStackDepth = 31;
255 struct StackTrace { 257 struct StackTrace {
256 uintptr_t size; // Size of object 258 uintptr_t size; // Size of object
257 uintptr_t depth; // Number of PC values stored in array below 259 uintptr_t depth; // Number of PC values stored in array below
258 void* stack[kMaxStackDepth]; 260 void* stack[kMaxStackDepth];
259 }; 261 };
260 262
261 } // namespace tcmalloc 263 } // namespace tcmalloc
262 264
263 #endif // TCMALLOC_COMMON_H_ 265 #endif // TCMALLOC_COMMON_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698