mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
set minimum value for initial nextGen2 capacity; profile support
This commit is contained in:
parent
3bbc119516
commit
747e7b0371
19
makefile
19
makefile
@ -17,7 +17,7 @@ classpath = classpath
|
||||
test = test
|
||||
jscheme = /tmp/jscheme
|
||||
|
||||
input = $(cls)/GC.class
|
||||
input = $(cls)/References.class
|
||||
|
||||
cxx = g++
|
||||
cc = gcc
|
||||
@ -34,6 +34,8 @@ thread-lflags = -lpthread
|
||||
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
|
||||
-I$(src) -I$(bld) $(thread-cflags) -D__STDC_LIMIT_MACROS
|
||||
|
||||
lflags = $(thread-lflags) -ldl -lm
|
||||
|
||||
ifeq ($(mode),debug)
|
||||
cflags += -O0 -g3
|
||||
endif
|
||||
@ -46,8 +48,10 @@ endif
|
||||
ifeq ($(mode),fast)
|
||||
cflags += -Os -DNDEBUG -DMONOLITHIC
|
||||
endif
|
||||
|
||||
lflags = $(thread-lflags) -ldl -lm
|
||||
ifeq ($(mode),profile)
|
||||
cflags += -Os -pg -DNDEBUG -DMONOLITHIC
|
||||
lflags += -pg
|
||||
endif
|
||||
|
||||
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
|
||||
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%.o,$(x)))
|
||||
@ -141,6 +145,10 @@ $(input): $(classpath-objects)
|
||||
run: $(executable) $(input)
|
||||
LD_LIBRARY_PATH=$(bld) $(<) $(args)
|
||||
|
||||
.PHONY: run-jscheme
|
||||
run-jscheme: $(executable) $(input)
|
||||
LD_LIBRARY_PATH=$(bld) $(<) -cp $(cls):$(jscheme) jscheme/REPL
|
||||
|
||||
.PHONY: debug
|
||||
debug: $(executable) $(input)
|
||||
LD_LIBRARY_PATH=$(bld) gdb --args $(<) $(args)
|
||||
@ -159,6 +167,11 @@ vg-jscheme: $(executable) $(input)
|
||||
LD_LIBRARY_PATH=$(bld) $(vg) $(<) -cp $(cls):$(jscheme) \
|
||||
jscheme/REPL
|
||||
|
||||
.PHONY: profile-jscheme
|
||||
profile-jscheme: $(executable) $(input)
|
||||
echo '(+ 5 6)' | LD_LIBRARY_PATH=$(bld) $(<) -cp $(cls):$(jscheme) \
|
||||
jscheme/REPL
|
||||
|
||||
.PHONY: test
|
||||
test: $(executable) $(classpath-objects) $(test-classes)
|
||||
LD_LIBRARY_PATH=$(bld) /bin/bash $(test)/test.sh \
|
||||
|
25
src/heap.cpp
25
src/heap.cpp
@ -12,7 +12,10 @@ const unsigned TenureThreshold = 3;
|
||||
|
||||
const unsigned Top = ~static_cast<unsigned>(0);
|
||||
|
||||
const unsigned InitialGen2CapacityInBytes = 4 * 1024 * 1024;
|
||||
|
||||
const bool Verbose = true;
|
||||
const bool Verbose2 = false;
|
||||
const bool Debug = false;
|
||||
|
||||
class Context;
|
||||
@ -285,7 +288,6 @@ class Segment {
|
||||
map(map)
|
||||
{
|
||||
if (desired) {
|
||||
assert(context, minimum > 0);
|
||||
assert(context, desired >= minimum);
|
||||
|
||||
capacity_ = desired;
|
||||
@ -297,6 +299,9 @@ class Segment {
|
||||
if (data == 0) {
|
||||
if (capacity_ > minimum) {
|
||||
capacity_ = avg(minimum, capacity_);
|
||||
if (capacity_ == 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
abort(context);
|
||||
}
|
||||
@ -489,7 +494,7 @@ initNextGen1(Context* c, unsigned footprint)
|
||||
|
||||
new (&(c->nextGen1)) Segment(c, &(c->nextAgeMap), desired, minimum);
|
||||
|
||||
if (Verbose) {
|
||||
if (Verbose2) {
|
||||
fprintf(stderr, "init nextGen1 to %d bytes\n",
|
||||
c->nextGen1.capacity() * BytesPerWord);
|
||||
}
|
||||
@ -509,11 +514,12 @@ initNextGen2(Context* c)
|
||||
(&(c->nextGen2), 1, c->pageMap.scale * 1024, &(c->nextPageMap), true);
|
||||
|
||||
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);
|
||||
|
||||
if (Verbose) {
|
||||
if (Verbose2) {
|
||||
fprintf(stderr, "init nextGen2 to %d bytes\n",
|
||||
c->nextGen2.capacity() * BytesPerWord);
|
||||
}
|
||||
@ -1051,12 +1057,15 @@ collect(Context* c, unsigned footprint)
|
||||
c->mode = Heap::MajorCollection;
|
||||
}
|
||||
|
||||
int64_t then;
|
||||
if (Verbose) {
|
||||
if (c->mode == Heap::MajorCollection) {
|
||||
fprintf(stderr, "major collection\n");
|
||||
fprintf(stderr, "major collection ");
|
||||
} else {
|
||||
fprintf(stderr, "minor collection\n");
|
||||
fprintf(stderr, "minor collection ");
|
||||
}
|
||||
|
||||
then = c->system->now();
|
||||
}
|
||||
|
||||
initNextGen1(c, footprint);
|
||||
@ -1070,6 +1079,10 @@ collect(Context* c, unsigned footprint)
|
||||
if (c->mode == Heap::MajorCollection) {
|
||||
c->gen2.replaceWith(&(c->nextGen2));
|
||||
}
|
||||
|
||||
if (Verbose) {
|
||||
fprintf(stderr, "- " LLD "ms\n", (c->system->now() - then));
|
||||
}
|
||||
}
|
||||
|
||||
class MyHeap: public Heap {
|
||||
|
Loading…
Reference in New Issue
Block a user