Skip to content

Commit 9f277c4

Browse files
authored
Use correct threads specification for subprocess (#3467)
1 parent 7c754dc commit 9f277c4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Operations.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,20 @@ function gen_test_precompile_code(source_path::String; coverage, julia_args::Cmd
16601660
return gen_subprocess_cmd(code, source_path; coverage, julia_args)
16611661
end
16621662

1663+
@static if VERSION >= v"1.9.0" # has threadpools
1664+
function get_threads_spec()
1665+
if Threads.nthreads(:interactive) > 0
1666+
"$(Threads.nthreads(:default)),$(Threads.nthreads(:interactive))"
1667+
else
1668+
"$(Threads.nthreads(:default))"
1669+
end
1670+
end
1671+
else # no threadpools
1672+
function get_threads_spec()
1673+
"$(Threads.nthreads())"
1674+
end
1675+
end
1676+
16631677
function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_args)
16641678
coverage_arg = if coverage isa Bool
16651679
coverage ? string("@", source_path) : "none"
@@ -1679,7 +1693,7 @@ function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_a
16791693
--inline=$(Bool(Base.JLOptions().can_inline) ? "yes" : "no")
16801694
--startup-file=$(Base.JLOptions().startupfile == 1 ? "yes" : "no")
16811695
--track-allocation=$(("none", "user", "all")[Base.JLOptions().malloc_log + 1])
1682-
--threads=$(Threads.nthreads())
1696+
--threads=$(get_threads_spec())
16831697
$(julia_args)
16841698
--eval $(code)
16851699
```

0 commit comments

Comments
 (0)