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

Unified Diff: third_party/tcmalloc/chromium/src/common.cc

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, 5 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
Index: third_party/tcmalloc/chromium/src/common.cc
===================================================================
--- third_party/tcmalloc/chromium/src/common.cc (revision 94429)
+++ third_party/tcmalloc/chromium/src/common.cc (working copy)
@@ -54,9 +54,9 @@
int AlignmentForSize(size_t size) {
int alignment = kAlignment;
- if (size >= 2048) {
- // Cap alignment at 256 for large sizes.
- alignment = 256;
+ if (size > kMaxSize) {
+ // Cap alignment at kPageSize for large sizes.
+ alignment = kPageSize;
} else if (size >= 128) {
// Space wasted due to alignment is at most 1/8, i.e., 12.5%.
alignment = (1 << LgFloor(size)) / 8;
@@ -65,6 +65,10 @@
// requirements for some SSE types.
alignment = 16;
}
+ // Maximum alignment allowed is page size alignment.
+ if (alignment > kPageSize) {
+ alignment = kPageSize;
+ }
CHECK_CONDITION(size < 16 || alignment >= 16);
CHECK_CONDITION((alignment & (alignment - 1)) == 0);
return alignment;
@@ -105,22 +109,23 @@
int sc = 1; // Next size class to assign
int alignment = kAlignment;
CHECK_CONDITION(kAlignment <= 16);
- int last_lg = -1;
for (size_t size = kAlignment; size <= kMaxSize; size += alignment) {
- int lg = LgFloor(size);
- if (lg > last_lg) {
- // Increase alignment every so often to reduce number of size classes.
- alignment = AlignmentForSize(size);
- last_lg = lg;
- }
+ alignment = AlignmentForSize(size);
CHECK_CONDITION((size % alignment) == 0);
- // Allocate enough pages so leftover is less than 1/8 of total.
- // This bounds wasted space to at most 12.5%.
- size_t psize = kPageSize;
- while ((psize % size) > (psize >> 3)) {
+ int blocks_to_move = NumMoveSize(size) / 4;
+ size_t psize = 0;
+ do {
psize += kPageSize;
- }
+ // Allocate enough pages so leftover is less than 1/8 of total.
+ // This bounds wasted space to at most 12.5%.
+ while ((psize % size) > (psize >> 3)) {
+ psize += kPageSize;
+ }
+ // Continue to add pages until there are at least as many objects in
jar (doing other things) 2011/07/31 08:19:39 I'm not clear on the justification for doing this.
+ // the span as are needed when moving objects from the central
+ // freelists and spans to the thread caches.
+ } while ((psize / size) < (blocks_to_move));
const size_t my_pages = psize >> kPageShift;
if (sc > 1 && my_pages == class_to_pages_[sc-1]) {

Powered by Google App Engine
This is Rietveld 408576698