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

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

Issue 7430002: Update the tcmalloc vendor branch to r111 (perftools version 1.8) (Closed) 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
« no previous file with comments | « third_party/tcmalloc/vendor/src/common.h ('k') | third_party/tcmalloc/vendor/src/config.h.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/vendor/src/common.cc
===================================================================
--- third_party/tcmalloc/vendor/src/common.cc (revision 92996)
+++ third_party/tcmalloc/vendor/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
+ // 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]) {
« no previous file with comments | « third_party/tcmalloc/vendor/src/common.h ('k') | third_party/tcmalloc/vendor/src/config.h.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698