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

Unified Diff: src/zone/accounting-allocator.h

Issue 2424393002: Constrain the zone segment pool size (Closed)
Patch Set: Reaction to comments Created 4 years, 2 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 | « src/api.cc ('k') | src/zone/accounting-allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone/accounting-allocator.h
diff --git a/src/zone/accounting-allocator.h b/src/zone/accounting-allocator.h
index f519c45db33637bbc78bbe3c0539269b17ab30db..70661cebe8e31075e76271d40a4a07a1ec70c69c 100644
--- a/src/zone/accounting-allocator.h
+++ b/src/zone/accounting-allocator.h
@@ -13,12 +13,18 @@
#include "src/base/platform/semaphore.h"
#include "src/base/platform/time.h"
#include "src/zone/zone-segment.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
namespace v8 {
namespace internal {
class V8_EXPORT_PRIVATE AccountingAllocator {
public:
+ static const size_t kMaxPoolSizeLowMemoryDevice = 8ul * KB;
+ static const size_t kMaxPoolSizeMediumMemoryDevice = 1ul * MB;
+ static const size_t kMaxPoolSizeHighMemoryDevice = 2ul * MB;
+ static const size_t kMaxPoolSizeHugeMemoryDevice = 3ul * MB;
+
AccountingAllocator();
virtual ~AccountingAllocator();
@@ -34,17 +40,26 @@ class V8_EXPORT_PRIVATE AccountingAllocator {
size_t GetCurrentPoolSize() const;
void MemoryPressureNotification(MemoryPressureLevel level);
+ // Configures the zone segment pool size limits so the pool does not
+ // grow bigger than max_pool_size.
+ // TODO(heimbuef): Do not accept segments to pool that are larger than
+ // their size class requires. Sometimes the zones generate weird segments.
+ void ConfigureSegmentPool(const size_t max_pool_size);
virtual void ZoneCreation(const Zone* zone) {}
virtual void ZoneDestruction(const Zone* zone) {}
private:
- static const uint8_t kMinSegmentSizePower = 13;
- static const uint8_t kMaxSegmentSizePower = 18;
- static const uint8_t kMaxSegmentsPerBucket = 5;
+ FRIEND_TEST(Zone, SegmentPoolConstraints);
+
+ static const size_t kMinSegmentSizePower = 13;
+ static const size_t kMaxSegmentSizePower = 18;
STATIC_ASSERT(kMinSegmentSizePower <= kMaxSegmentSizePower);
+ static const size_t kNumberBuckets =
+ 1 + kMaxSegmentSizePower - kMinSegmentSizePower;
+
// Allocates a new segment. Returns nullptr on failed allocation.
Segment* AllocateSegment(size_t bytes);
void FreeSegment(Segment* memory);
@@ -57,10 +72,10 @@ class V8_EXPORT_PRIVATE AccountingAllocator {
// Empties the pool and puts all its contents onto the garbage stack.
void ClearPool();
- Segment*
- unused_segments_heads_[1 + kMaxSegmentSizePower - kMinSegmentSizePower];
+ Segment* unused_segments_heads_[kNumberBuckets];
- size_t unused_segments_sizes[1 + kMaxSegmentSizePower - kMinSegmentSizePower];
+ size_t unused_segments_sizes_[kNumberBuckets];
+ size_t unused_segments_max_sizes_[kNumberBuckets];
base::Mutex unused_segments_mutex_;
« no previous file with comments | « src/api.cc ('k') | src/zone/accounting-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698