From 0cf9036d307ffcf6690851b114607b7571706799 Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Mon, 23 Jun 2014 21:26:39 -0700 Subject: [PATCH] Change max gen to GC to 3; add inteface to set it. * lisp/gencgc.c * Set number of generations to GC to 3 instead of NUM_GENERATIONS - 1. * Add simple interface to allow user to set the number of generations and return the old value. * code/gc.lisp: * Add Lisp interface to set the number of generations to GC. --- src/code/gc.lisp | 3 +++ src/lisp/gencgc.c | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/code/gc.lisp b/src/code/gc.lisp index 5c200d48e..b12dabaf3 100644 --- a/src/code/gc.lisp +++ b/src/code/gc.lisp @@ -612,4 +612,7 @@ (gen c-call:int) (trigger-age c-call:int)) (alien:def-alien-routine set-min-mem-age c-call:void (gen c-call:int) (min-mem-age c-call:double)) +(alien:def-alien-routine set-max-gen-to-gc c-call:unsigned-int + (gen c-call:int)) + ) diff --git a/src/lisp/gencgc.c b/src/lisp/gencgc.c index cdc95e0ac..cc071dda8 100644 --- a/src/lisp/gencgc.c +++ b/src/lisp/gencgc.c @@ -594,7 +594,8 @@ struct generation_stats { * The oldest generation that will currently be GCed by default. * Valid values are: 0, 1, ... (NUM_GENERATIONS - 1) * - * The default of (NUM_GENERATIONS - 1) enables GC on all generations. + * A value of NUM_GENERATIONS - 1 enables GC on all generations; the + * default is less. * * Setting this to 0 effectively disables the generational nature of * the GC. In some applications generational GC may not be useful @@ -604,7 +605,9 @@ struct generation_stats { * into an older generation so an unnecessary GC of this long-lived * data can be avoided. */ -unsigned int gencgc_oldest_gen_to_gc = NUM_GENERATIONS - 1; +#define DEFAULT_OLDEST_GEN_TO_GC 3 + +unsigned int gencgc_oldest_gen_to_gc = DEFAULT_OLDEST_GEN_TO_GC; /* @@ -8433,3 +8436,23 @@ get_page_table_info(int page, int* flags, int* bytes) *flags = page_table[page].flags; *bytes = page_table[page].bytes_used; } + +/* + * Set the oldest generation to gc to the given value. If the value + * is illegal, the appropriate limit is used instead. The old value + * is returned. + */ +unsigned int set_max_gen_to_gc(int gen) +{ + unsigned int previous = gencgc_oldest_gen_to_gc; + + if (gen < 0) { + gencgc_oldest_gen_to_gc = 0; + } else if (gen >= NUM_GENERATIONS - 1) { + gencgc_oldest_gen_to_gc = NUM_GENERATIONS - 1; + } else { + gencgc_oldest_gen_to_gc = gen; + } + + return previous; +} -- GitLab