From 137fdcb69e0adb589d63fd8c010b35782207b7eb Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 22 Jun 2007 17:29:15 -0600 Subject: [PATCH] specify a more conservative initial capacity in initNextGen{1,2}() --- src/common.h | 6 ++++++ src/heap.cpp | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index 6dcf4a4cb0..4b05fbbcfe 100644 --- a/src/common.h +++ b/src/common.h @@ -39,6 +39,12 @@ min(unsigned a, unsigned b) return (a < b ? a : b); } +inline unsigned +avg(unsigned a, unsigned b) +{ + return (a + b) / 2; +} + inline unsigned pad(unsigned n) { diff --git a/src/heap.cpp b/src/heap.cpp index f6fd612c60..2610ed66a4 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -285,7 +285,7 @@ class Segment { if (p == 0) { if (capacity > minimum) { - capacity = minimum + ((capacity - minimum) / 2); + capacity = avg(minimum, capacity); } else { abort(s->context); } @@ -597,7 +597,7 @@ void initNextGen1(Context* c) { unsigned minimum = MinimumGen1SizeInBytes / BytesPerWord; - unsigned desired = max(minimum, nextPowerOfTwo(c->gen1.position())); + unsigned desired = max(minimum, avg(c->gen1.position(), c->gen1.capacity())); new (&(c->nextAgeMap)) Segment::Map (&(c->nextGen1), log(TenureThreshold), 1, 0, false); @@ -634,7 +634,7 @@ void initNextGen2(Context* c) { unsigned minimum = MinimumGen2SizeInBytes / BytesPerWord; - unsigned desired = max(minimum, nextPowerOfTwo(c->gen2.position())); + unsigned desired = max(minimum, avg(c->gen2.position(), c->gen2.capacity())); new (&(c->nextPointerMap)) Segment::Map(&(c->nextGen2)); new (&(c->nextPageMap)) Segment::Map