diff --git a/base/options.jl b/base/options.jl index e0e1750d14cae..a94936391fa8d 100644 --- a/base/options.jl +++ b/base/options.jl @@ -11,7 +11,6 @@ struct JLOptions cpu_target::Ptr{UInt8} nthreadpools::Int16 nthreads::Int16 - ngcthreads::Int16 nmarkthreads::Int16 nsweepthreads::Int8 nthreads_per_pool::Ptr{Int16} diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index 0854048e6b96c..b8a522be96d97 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -134,6 +134,7 @@ end Threads.ngcthreads() -> Int Returns the number of GC threads currently configured. +This includes both mark threads and concurrent sweep threads. """ ngcthreads() = Int(unsafe_load(cglobal(:jl_n_gcthreads, Cint))) + 1 diff --git a/src/jloptions.c b/src/jloptions.c index f82e46ca9a4a5..129ba9df2510e 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -40,7 +40,6 @@ JL_DLLEXPORT void jl_init_options(void) NULL, // cpu_target ("native", "core2", etc...) 0, // nthreadpools 0, // nthreads - 0, // ngcthreads 0, // nmarkthreads 0, // nsweepthreads NULL, // nthreads_per_pool diff --git a/src/jloptions.h b/src/jloptions.h index 9f74d520e59ff..8649c405112d7 100644 --- a/src/jloptions.h +++ b/src/jloptions.h @@ -15,7 +15,6 @@ typedef struct { const char *cpu_target; int8_t nthreadpools; int16_t nthreads; - int16_t ngcthreads; int16_t nmarkthreads; int8_t nsweepthreads; const int16_t *nthreads_per_pool; diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index 6dc6bd086df16..0c865b8d1b3a8 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -1331,6 +1331,14 @@ function get_threads_spec(opts) end end +function get_gcthreads_spec(opts) + if opts.markthreads > 0 || opts.sweepthreads > 0 + `--gcthreads=$(opts.markthreads),$(opts.sweepthreads)` + else + `` + end +end + # Starts workers specified by (-n|--procs) and --machine-file command line options function process_opts(opts) # startup worker. @@ -1346,7 +1354,8 @@ function process_opts(opts) # Propagate --threads to workers threads = get_threads_spec(opts) - gcthreads = opts.ngcthreads > 0 ? `--gcthreads=$(opts.ngcthreads)` : `` + # Propagate --gcthreads to workers + gcthreads = get_gcthreads_spec(opts) exeflags = `$threads $gcthreads` diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 21567468ffe9e..917031b57fe5f 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -362,12 +362,19 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no` withenv("JULIA_NUM_GC_THREADS" => nt) do @test read(`$exename --gcthreads=2 -e $code`, String) == "2" end + withenv("JULIA_NUM_GC_THREADS" => nt) do + @test read(`$exename --gcthreads=2,1 -e $code`, String) == "3" + end end withenv("JULIA_NUM_GC_THREADS" => 2) do @test read(`$exename -e $code`, String) == "2" end + withenv("JULIA_NUM_GC_THREADS" => "2,1") do + @test read(`$exename -e $code`, String) == "3" + end + # --machine-file # this does not check that machine file works, # only that the filename gets correctly passed to the option struct diff --git a/test/gc.jl b/test/gc.jl index ecf71fe51f6ad..861483bf246a3 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -5,9 +5,10 @@ using Test function run_gctest(file) let cmd = `$(Base.julia_cmd()) --depwarn=error --rr-detach --startup-file=no $file` @testset for test_nthreads in (1, 2, 4) + @testset for concurrent_sweep in (0, 1) new_env = copy(ENV) new_env["JULIA_NUM_THREADS"] = string(test_nthreads) - new_env["JULIA_NUM_GC_THREADS"] = string(test_nthreads) + new_env["JULIA_NUM_GC_THREADS"] = "$(test_nthreads),$(concurrent_sweep)" @test success(run(pipeline(setenv(cmd, new_env), stdout = stdout, stderr = stderr))) end end