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

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

Issue 9717007: Try fixing virtual memory regression from new tcmalloc: use old kPageShift and kMaxSize w/ totally … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: using 61... the old value. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/chromium/src/common.cc
diff --git a/third_party/tcmalloc/chromium/src/common.cc b/third_party/tcmalloc/chromium/src/common.cc
index dd175f223692a5adb37048140b30422bae79fe40..30eaa2e85e545f7afdc6857b8c67f6b029dd1df9 100644
--- a/third_party/tcmalloc/chromium/src/common.cc
+++ b/third_party/tcmalloc/chromium/src/common.cc
@@ -58,9 +58,9 @@ static inline int LgFloor(size_t n) {
int AlignmentForSize(size_t size) {
int alignment = kAlignment;
- if (size > kMaxSize) {
- // Cap alignment at kPageSize for large sizes.
- alignment = kPageSize;
+ if (size >= 2048) {
+ // Cap alignment at 256 for large sizes.
+ alignment = 256;
} else if (size >= 128) {
// Space wasted due to alignment is at most 1/8, i.e., 12.5%.
alignment = (1 << LgFloor(size)) / 8;
@@ -69,10 +69,6 @@ int AlignmentForSize(size_t size) {
// 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;
@@ -115,23 +111,22 @@ void SizeMap::Init() {
int sc = 1; // Next size class to assign
int alignment = kAlignment;
CHECK_CONDITION(kAlignment <= 16);
+ int last_lg = -1;
for (size_t size = kMinClassSize; size <= kMaxSize; size += alignment) {
- alignment = AlignmentForSize(size);
+ 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;
+ }
CHECK_CONDITION((size % alignment) == 0);
- int blocks_to_move = NumMoveSize(size) / 4;
- size_t psize = 0;
- do {
+ // 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)) {
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/chromium/src/common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698