From 1179c8ee7c55d4831a0607401376b0d5de7262c1 Mon Sep 17 00:00:00 2001 From: d-netto Date: Thu, 16 Nov 2023 13:51:53 -0300 Subject: [PATCH] cap the number of GC threads to number of cpu cores --- src/threading.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/threading.c b/src/threading.c index 18c502cf94387..962274401d57b 100644 --- a/src/threading.c +++ b/src/threading.c @@ -709,6 +709,13 @@ void jl_init_threading(void) else { jl_n_markthreads = (nthreads / 2) - 1; } + // if `--gcthreads` or ENV[NUM_GCTHREADS_NAME] was not specified, + // cap the number of threads that may run the mark phase to + // the number of CPU cores + int cpu = jl_cpu_threads(); + if (jl_n_markthreads + 1 >= cpu) { + jl_n_markthreads = cpu - 1; + } } } int16_t ngcthreads = jl_n_markthreads + jl_n_sweepthreads;