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

Side by Side Diff: src/zone/accounting-allocator.cc

Issue 2520903002: [zone] Fix zone segment pooling size limits (Closed)
Patch Set: Created 4 years 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
« 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/zone/accounting-allocator.h" 5 #include "src/zone/accounting-allocator.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #if V8_LIBC_BIONIC 9 #if V8_LIBC_BIONIC
10 #include <malloc.h> // NOLINT 10 #include <malloc.h> // NOLINT
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // This code will work best if the max_pool_size is a multiple of the 52 // This code will work best if the max_pool_size is a multiple of the
53 // full_size. If max_pool_size is no sum of segment sizes the actual pool 53 // full_size. If max_pool_size is no sum of segment sizes the actual pool
54 // size might be smaller then max_pool_size. Note that no actual memory gets 54 // size might be smaller then max_pool_size. Note that no actual memory gets
55 // wasted though. 55 // wasted though.
56 // TODO(heimbuef): Determine better strategy generating a segment sizes 56 // TODO(heimbuef): Determine better strategy generating a segment sizes
57 // distribution that is closer to real/benchmark usecases and uses the given 57 // distribution that is closer to real/benchmark usecases and uses the given
58 // max_pool_size more efficiently. 58 // max_pool_size more efficiently.
59 size_t total_size = fits_fully * full_size; 59 size_t total_size = fits_fully * full_size;
60 60
61 for (size_t power = 0; power < kNumberBuckets; ++power) { 61 for (size_t power = 0; power < kNumberBuckets; ++power) {
62 if (total_size + (size_t(1) << power) <= max_pool_size) { 62 if (total_size + (size_t(1) << (power + kMinSegmentSizePower)) <=
63 max_pool_size) {
63 unused_segments_max_sizes_[power] = fits_fully + 1; 64 unused_segments_max_sizes_[power] = fits_fully + 1;
64 total_size += size_t(1) << power; 65 total_size += size_t(1) << power;
65 } else { 66 } else {
66 unused_segments_max_sizes_[power] = fits_fully; 67 unused_segments_max_sizes_[power] = fits_fully;
67 } 68 }
68 } 69 }
69 } 70 }
70 71
71 Segment* AccountingAllocator::GetSegment(size_t bytes) { 72 Segment* AccountingAllocator::GetSegment(size_t bytes) {
72 Segment* result = GetSegmentFromPool(bytes); 73 Segment* result = GetSegmentFromPool(bytes);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Segment* next = current->next(); 194 Segment* next = current->next();
194 FreeSegment(current); 195 FreeSegment(current);
195 current = next; 196 current = next;
196 } 197 }
197 unused_segments_heads_[power] = nullptr; 198 unused_segments_heads_[power] = nullptr;
198 } 199 }
199 } 200 }
200 201
201 } // namespace internal 202 } // namespace internal
202 } // namespace v8 203 } // namespace v8
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