adjust PLT_INCREMENTAL_GC so it can disable generational GC

A value that starts "1", "y", or "Y" enabled incremental mode
permanently (any value was allowed formerly), while a value that
starts "0", "n", or "N" causes incremental-mode requests to be
ignored.
This commit is contained in:
Matthew Flatt 2015-12-20 08:04:55 -07:00
parent 3a99a19c56
commit 0553f191d7
5 changed files with 40 additions and 13 deletions

View File

@ -598,8 +598,9 @@ pause is as short as a minor collection's pause. Incremental mode
tends to run more slowly overall, but it can
provide much more consistent real-time behavior.
If the @envvar{PLT_INCREMENTAL_GC} environment variable is set when
Racket starts, incremental mode is permanently enabled. Since
If the @envvar{PLT_INCREMENTAL_GC} environment variable is set
to a value that starts with @litchar{1}, @litchar{y}, or @litchar{Y}
when Racket starts, incremental mode is permanently enabled. Since
incremental mode is only useful for certain parts of some programs,
however, and since the need for incremental mode is a property of a
program rather than its environment, the preferred way to enable

View File

@ -200,7 +200,8 @@ execution. Otherwise, @racket[#f] is returned.}
Set the @as-index{@envvar{PLTDISABLEGC}} environment variable (to any
value) before Racket starts to disable @tech{garbage collection}. Set
the @as-index{@envvar{PLT_INCREMENTAL_GC}} environment variable to
the @as-index{@envvar{PLT_INCREMENTAL_GC}} environment variable
to a value that starts with @litchar{1}, @litchar{y}, or @litchar{Y} to
request incremental mode at all times, but calling
@racket[(collect-garbage 'incremental)] in a program with a periodic
task is generally a better mechanism for requesting incremental mode.
@ -302,6 +303,7 @@ collection mode, the text has the format
@history[#:changed "6.3.0.7" @elem{Added @envvar{PLT_INCREMENTAL_GC}.}]
@defproc[(collect-garbage [request (or/c 'major 'minor 'incremental) 'major]) void?]{
Requests an immediate @tech{garbage collection} or requests a
@ -336,7 +338,11 @@ garbage-collection mode, depending on @racket[request]:
The intent of incremental mode is to significantly reduce pause
times due to major collections, but incremental mode typically
implies longer minor-collection times and higher memory use.}
implies longer minor-collection times and higher memory use.
If the @envvar{PLT_INCREMENTAL_GC} environment variable's value
starts with @litchar{0}, @litchar{n}, or @litchar{N} on
start-up, then incremental-mode requests are ignored.}
]

View File

@ -1542,8 +1542,23 @@ static int run_from_cmd_line(int argc, char *_argv[],
if (getenv("PLTDISABLEGC")) {
scheme_enable_garbage_collection(0);
}
if (getenv("PLT_INCREMENTAL_GC")) {
{
char *s;
s = getenv("PLT_INCREMENTAL_GC");
if (s) {
if ((s[0] == '0') || (s[0] == 'n') || (s[0] == 'N'))
scheme_incremental_garbage_collection(0);
else if ((s[0] == '1') || (s[0] == 'y') || (s[0] == 'Y'))
scheme_incremental_garbage_collection(1);
else {
PRINTF("%s: unrecognized value for PLT_INCREMENTAL_GC;\n"
" a value that starts \"1\", \"y\", or \"Y\" permanently enables incremental mode,\n"
" and a value that starts \"0\", \"n\", or \"N\" disables incremental mode,\n"
" and the default enables incremental mode as requested via `collect-garbage'\n"
" unrecognized value: %s\n",
prog, s);
}
}
}
#endif

View File

@ -176,7 +176,8 @@ GC2_EXTERN void GC_request_incremental_mode(void);
GC2_EXTERN void GC_set_incremental_mode(int on);
/*
Sets whether incremental mode is the default. */
Sets whether incremental mode is the default (1), always disabled (0),
or available on demand (-1). */
GC2_EXTERN void GC_free_all(void);
/*

View File

@ -257,6 +257,7 @@ MAYBE_UNUSED static void GCVERBOSEprintf(NewGC *gc, const char *fmt, ...) {
/* Incremental mode */
static int always_collect_incremental_on_minor = 0;
static int never_collect_incremental_on_minor = 0;
#define INCREMENTAL_COLLECT_FUEL_PER_100M (4 * 1024)
#define INCREMENTAL_REPAIR_FUEL_PER_100M 32
@ -3665,17 +3666,20 @@ void GC_gcollect_minor(void)
void GC_request_incremental_mode(void)
{
if (!never_collect_incremental_on_minor) {
NewGC *gc = GC_get_GC();
/* The request will expire gradually, so that an extra major GC will
be triggered if incremental mode hasn't been requested recently
enough: */
gc->incremental_requested = 8;
}
}
void GC_set_incremental_mode(int on)
{
always_collect_incremental_on_minor = 1;
always_collect_incremental_on_minor = (on > 0);
never_collect_incremental_on_minor = !on;
}
void GC_enable_collection(int on)