[m-rev.] for post-commit review: Explicitly start parallel marker threads.
Peter Wang
novalazy at gmail.com
Mon Aug 7 13:00:15 AEST 2023
As of Boehm GC v8.2.2 (commit b8ee3ca626d6bd67c8c2c94d517f2f7da7cd5a8c)
parallel marker threads are not started during GC_INIT(). Instead, the
marker threads are only started when the client program creates the
first (user) thread, or if GC_start_mark_threads() is called explicitly.
runtime/mercury_wrapper.c:
Call GC_allow_register_threads() as part of GC initialisation.
This will enable parallel marking in par.gc C grades from the start
of the Mercury program, even if the program has not created any
threads (yet).
---
runtime/mercury_wrapper.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index d5015bfa0..44cd8d4c9 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -843,6 +843,13 @@ MR_init_conservative_GC(void)
GC_set_oom_fn(MR_oom_func);
+ #ifdef MR_THREAD_SAFE
+ // Explicitly put the GC into multithreaded mode. This also launches any
+ // parallel marker threads. Without this, parallel marker threads will not
+ // be started until the first user thread is created.
+ GC_allow_register_threads();
+ #endif // MR_THREAD_SAFE
+
#endif // MR_BOEHM_GC
}
#endif // MR_CONSERVATIVE_GC
--
2.39.0
More information about the reviews
mailing list