set minimum value for initial nextGen2 capacity; profile support

This commit is contained in:
Joel Dice 2007-08-18 16:42:11 -06:00
parent 3bbc119516
commit 747e7b0371
2 changed files with 35 additions and 9 deletions

View File

@ -17,7 +17,7 @@ classpath = classpath
test = test test = test
jscheme = /tmp/jscheme jscheme = /tmp/jscheme
input = $(cls)/GC.class input = $(cls)/References.class
cxx = g++ cxx = g++
cc = gcc cc = gcc
@ -34,6 +34,8 @@ thread-lflags = -lpthread
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \ cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
-I$(src) -I$(bld) $(thread-cflags) -D__STDC_LIMIT_MACROS -I$(src) -I$(bld) $(thread-cflags) -D__STDC_LIMIT_MACROS
lflags = $(thread-lflags) -ldl -lm
ifeq ($(mode),debug) ifeq ($(mode),debug)
cflags += -O0 -g3 cflags += -O0 -g3
endif endif
@ -46,8 +48,10 @@ endif
ifeq ($(mode),fast) ifeq ($(mode),fast)
cflags += -Os -DNDEBUG -DMONOLITHIC cflags += -Os -DNDEBUG -DMONOLITHIC
endif endif
ifeq ($(mode),profile)
lflags = $(thread-lflags) -ldl -lm cflags += -Os -pg -DNDEBUG -DMONOLITHIC
lflags += -pg
endif
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x))) cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%.o,$(x))) asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%.o,$(x)))
@ -141,6 +145,10 @@ $(input): $(classpath-objects)
run: $(executable) $(input) run: $(executable) $(input)
LD_LIBRARY_PATH=$(bld) $(<) $(args) LD_LIBRARY_PATH=$(bld) $(<) $(args)
.PHONY: run-jscheme
run-jscheme: $(executable) $(input)
LD_LIBRARY_PATH=$(bld) $(<) -cp $(cls):$(jscheme) jscheme/REPL
.PHONY: debug .PHONY: debug
debug: $(executable) $(input) debug: $(executable) $(input)
LD_LIBRARY_PATH=$(bld) gdb --args $(<) $(args) LD_LIBRARY_PATH=$(bld) gdb --args $(<) $(args)
@ -159,6 +167,11 @@ vg-jscheme: $(executable) $(input)
LD_LIBRARY_PATH=$(bld) $(vg) $(<) -cp $(cls):$(jscheme) \ LD_LIBRARY_PATH=$(bld) $(vg) $(<) -cp $(cls):$(jscheme) \
jscheme/REPL jscheme/REPL
.PHONY: profile-jscheme
profile-jscheme: $(executable) $(input)
echo '(+ 5 6)' | LD_LIBRARY_PATH=$(bld) $(<) -cp $(cls):$(jscheme) \
jscheme/REPL
.PHONY: test .PHONY: test
test: $(executable) $(classpath-objects) $(test-classes) test: $(executable) $(classpath-objects) $(test-classes)
LD_LIBRARY_PATH=$(bld) /bin/bash $(test)/test.sh \ LD_LIBRARY_PATH=$(bld) /bin/bash $(test)/test.sh \

View File

@ -12,7 +12,10 @@ const unsigned TenureThreshold = 3;
const unsigned Top = ~static_cast<unsigned>(0); const unsigned Top = ~static_cast<unsigned>(0);
const unsigned InitialGen2CapacityInBytes = 4 * 1024 * 1024;
const bool Verbose = true; const bool Verbose = true;
const bool Verbose2 = false;
const bool Debug = false; const bool Debug = false;
class Context; class Context;
@ -285,7 +288,6 @@ class Segment {
map(map) map(map)
{ {
if (desired) { if (desired) {
assert(context, minimum > 0);
assert(context, desired >= minimum); assert(context, desired >= minimum);
capacity_ = desired; capacity_ = desired;
@ -297,6 +299,9 @@ class Segment {
if (data == 0) { if (data == 0) {
if (capacity_ > minimum) { if (capacity_ > minimum) {
capacity_ = avg(minimum, capacity_); capacity_ = avg(minimum, capacity_);
if (capacity_ == 0) {
break;
}
} else { } else {
abort(context); abort(context);
} }
@ -489,7 +494,7 @@ initNextGen1(Context* c, unsigned footprint)
new (&(c->nextGen1)) Segment(c, &(c->nextAgeMap), desired, minimum); new (&(c->nextGen1)) Segment(c, &(c->nextAgeMap), desired, minimum);
if (Verbose) { if (Verbose2) {
fprintf(stderr, "init nextGen1 to %d bytes\n", fprintf(stderr, "init nextGen1 to %d bytes\n",
c->nextGen1.capacity() * BytesPerWord); c->nextGen1.capacity() * BytesPerWord);
} }
@ -509,11 +514,12 @@ initNextGen2(Context* c)
(&(c->nextGen2), 1, c->pageMap.scale * 1024, &(c->nextPageMap), true); (&(c->nextGen2), 1, c->pageMap.scale * 1024, &(c->nextPageMap), true);
unsigned minimum = c->gen2.position() + c->tenureFootprint + c->gen2padding; unsigned minimum = c->gen2.position() + c->tenureFootprint + c->gen2padding;
unsigned desired = minimum * 2; unsigned desired = max
(minimum * 2, InitialGen2CapacityInBytes / BytesPerWord);
new (&(c->nextGen2)) Segment(c, &(c->nextHeapMap), desired, minimum); new (&(c->nextGen2)) Segment(c, &(c->nextHeapMap), desired, minimum);
if (Verbose) { if (Verbose2) {
fprintf(stderr, "init nextGen2 to %d bytes\n", fprintf(stderr, "init nextGen2 to %d bytes\n",
c->nextGen2.capacity() * BytesPerWord); c->nextGen2.capacity() * BytesPerWord);
} }
@ -1051,12 +1057,15 @@ collect(Context* c, unsigned footprint)
c->mode = Heap::MajorCollection; c->mode = Heap::MajorCollection;
} }
int64_t then;
if (Verbose) { if (Verbose) {
if (c->mode == Heap::MajorCollection) { if (c->mode == Heap::MajorCollection) {
fprintf(stderr, "major collection\n"); fprintf(stderr, "major collection ");
} else { } else {
fprintf(stderr, "minor collection\n"); fprintf(stderr, "minor collection ");
} }
then = c->system->now();
} }
initNextGen1(c, footprint); initNextGen1(c, footprint);
@ -1070,6 +1079,10 @@ collect(Context* c, unsigned footprint)
if (c->mode == Heap::MajorCollection) { if (c->mode == Heap::MajorCollection) {
c->gen2.replaceWith(&(c->nextGen2)); c->gen2.replaceWith(&(c->nextGen2));
} }
if (Verbose) {
fprintf(stderr, "- " LLD "ms\n", (c->system->now() - then));
}
} }
class MyHeap: public Heap { class MyHeap: public Heap {