[m-rev.] for review: add --boehm-gc-free-space-divisor option
Peter Wang
novalazy at gmail.com
Mon Jul 14 11:23:36 AEST 2008
Branches: main
Add `--boehm-gc-free-space-divisor <n>' option for MERCURY_OPTIONS.
This sets the value of a tunable parameter in Boehm GC to trade off heap
size for collection time.
runtime/mercury_wrapper.c:
Add the option.
doc/user_guide.texi:
Add documentation.
scripts/mdprof.in:
Add some sample code to enable the option when calling the deep
profiler CGI program.
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index d4a749c..8a78c79 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -9834,6 +9834,14 @@ garbage collector, and requires @samp{--enable-gc-munmap} to be passed to
@samp{configure}. (This may not work with all platforms).
@sp 1
+ at item --boehm-gc-free-space-divisor=@var{N}
+ at findex --boehm-gc-free-space-divisor=@var{N}
+This option sets the value of the free space divisor in the Boehm garbage
+collector to @var{N}. The default value is 3. Increasing its value will reduce
+heap space but increase collection time.
+See the Boehm GC documentation for details.
+
+ at sp 1
@item --boehm-gc-calc-time
@findex --boehm-gc-calc-time
This option enables code in the Boehm garbage collector to calculate
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index 912e731..5a4de9d 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -1214,6 +1214,7 @@ enum MR_long_option {
MR_TRACE_COUNT_FILE,
MR_MEM_USAGE_REPORT,
MR_BOEHM_GC_MUNMAP,
+ MR_BOEHM_GC_FREE_SPACE_DIVISOR,
MR_BOEHM_GC_CALC_TIME
};
@@ -1314,6 +1315,7 @@ struct MR_option MR_long_opts[] = {
{ "trace-count-summary-max", 1, 0, MR_TRACE_COUNT_SUMMARY_MAX_OPT },
{ "mem-usage-report", 1, 0, MR_MEM_USAGE_REPORT },
{ "boehm-gc-munmap", 0, 0, MR_BOEHM_GC_MUNMAP },
+ { "boehm-gc-free-space-divisor", 1, 0, MR_BOEHM_GC_FREE_SPACE_DIVISOR },
{ "boehm-gc-calc-time", 0, 0, MR_BOEHM_GC_CALC_TIME },
/* This needs to be kept at the end. */
@@ -1845,6 +1847,20 @@ MR_process_options(int argc, char **argv)
#endif
break;
+ case MR_BOEHM_GC_FREE_SPACE_DIVISOR:
+ if (sscanf(MR_optarg, "%lu", &size) != 1) {
+ MR_usage();
+ }
+
+ if (size < 1) {
+ MR_usage();
+ }
+
+#ifdef MR_BOEHM_GC
+ GC_set_free_space_divisor(size);
+#endif
+ break;
+
case MR_BOEHM_GC_CALC_TIME:
#ifdef MR_BOEHM_GC
GC_mercury_calc_gc_time = MR_TRUE;
diff --git a/scripts/mdprof.in b/scripts/mdprof.in
index 6b16ce5..5d2462c 100644
--- a/scripts/mdprof.in
+++ b/scripts/mdprof.in
@@ -17,4 +17,14 @@
PATH=@prefix@/bin:$PATH
export PATH
+
+# Use less heap at the expense of increased time spent in the GC.
+# The value is "experimentally determined" (guessed).
+if false
+then
+ MERCURY_OPTIONS_mdprof_cgi="--boehm-gc-free-space-divisor 10 \
+ ${MERCURY_OPTIONS_mdprof_cgi}"
+ export MERCURY_OPTIONS_mdprof_cgi
+fi
+
exec mdprof_cgi
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list