Commit 32395093 authored by Simon Marlow's avatar Simon Marlow

Implement a new heap-tuning option: -H

-H alone causes the RTS to use a larger nursery, but without exceeding
the amount of memory that the application is already using.  It trades
off GC time against locality: the default setting is to use a
fixed-size 512k nursery, but this is sometimes worse than using a very
large nursery despite the worse locality.

Not all programs get faster, but some programs that use large heaps do
much better with -H.  e.g. this helps a lot with #3061 (binary-trees),
though not as much as specifying -H<large>.  Typically using -H<large>
is better than plain -H, because the runtime doesn't know ahead of
time how much memory you want to use.

Should -H be on by default?  I'm not sure, it makes some programs go
slower, but others go faster.
parent f9d15f9f
......@@ -34,6 +34,7 @@ struct GC_FLAGS {
nat minAllocAreaSize; /* in *blocks* */
nat minOldGenSize; /* in *blocks* */
nat heapSizeSuggestion; /* in *blocks* */
rtsBool heapSizeSuggestionAuto;
double oldGenFactor;
double pcFreeHeap;
......
......@@ -70,6 +70,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE;
RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */
RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */
RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsFalse;
RtsFlags.GcFlags.pcFreeHeap = 3; /* 3% */
RtsFlags.GcFlags.oldGenFactor = 2;
RtsFlags.GcFlags.generations = 2;
......@@ -690,9 +691,13 @@ error = rtsTrue;
break;
case 'H':
RtsFlags.GcFlags.heapSizeSuggestion =
(nat)(decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) / BLOCK_SIZE);
break;
if (rts_argv[arg][2] == '\0') {
RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue;
} else {
RtsFlags.GcFlags.heapSizeSuggestion =
(nat)(decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) / BLOCK_SIZE);
}
break;
#ifdef RTS_GTK_FRONTPANEL
case 'f':
......
......@@ -1548,6 +1548,10 @@ resize_generations (void)
size = stg_max(live * RtsFlags.GcFlags.oldGenFactor,
RtsFlags.GcFlags.minOldGenSize);
if (RtsFlags.GcFlags.heapSizeSuggestionAuto) {
RtsFlags.GcFlags.heapSizeSuggestion = size;
}
// minimum size for generation zero
min_alloc = stg_max((RtsFlags.GcFlags.pcFreeHeap * max) / 200,
RtsFlags.GcFlags.minAllocAreaSize);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment