[m-rev.] diff: disable GC during startup

Peter Wang novalazy at gmail.com
Thu May 5 15:57:49 AEST 2011

[On my machine, this reduced the run time of an empty Mercury program in
the hlc.gc grade from 2.7 ms to 1.1 ms.  The equivalent C program takes
0.26 ms.  The Mercury libraries were statically linked.  Measured with a
simple C program which does fork/exec/wait in a loop to avoid shell
overhead.  CPU frequency scaling was disabled.]

Branches: main

Disable garbage collection during early runtime initialisation, when little or
no garbage is created anyway.

	As above.

diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index 1558f57..3972160 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -581,6 +581,10 @@ mercury_runtime_init(int argc, char **argv)
+#ifdef MR_BOEHM_GC
+    /* Disable GC during startup, when little or no garbage is created. */
+    GC_disable();
@@ -705,6 +709,10 @@ mercury_runtime_init(int argc, char **argv)
   #endif /* ! MR_LL_PARALLEL_CONJ */
 #endif /* ! 0 */
+#ifdef MR_BOEHM_GC
+    GC_enable();
     if (MR_memdebug) {

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