Skip to content

Commit

Permalink
Use correct threads specification for subprocess (JuliaLang#3467)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9f277c4)
  • Loading branch information
kpamnany authored and IanButterworth committed May 17, 2023
1 parent b426fb8 commit 2c8408c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,20 @@ function gen_test_precompile_code(source_path::String; coverage, julia_args::Cmd
return gen_subprocess_cmd(code, source_path; coverage, julia_args)
end

@static if VERSION >= v"1.9.0" # has threadpools
function get_threads_spec()
if Threads.nthreads(:interactive) > 0
"$(Threads.nthreads(:default)),$(Threads.nthreads(:interactive))"
else
"$(Threads.nthreads(:default))"
end
end
else # no threadpools
function get_threads_spec()
"$(Threads.nthreads())"
end
end

function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_args)
coverage_arg = if coverage isa Bool
coverage ? string("@", source_path) : "none"
Expand All @@ -1677,7 +1691,7 @@ function gen_subprocess_cmd(code::String, source_path::String; coverage, julia_a
--inline=$(Bool(Base.JLOptions().can_inline) ? "yes" : "no")
--startup-file=$(Base.JLOptions().startupfile == 1 ? "yes" : "no")
--track-allocation=$(("none", "user", "all")[Base.JLOptions().malloc_log + 1])
--threads=$(Threads.nthreads())
--threads=$(get_threads_spec())
$(julia_args)
--eval $(code)
```
Expand Down

0 comments on commit 2c8408c

Please sign in to comment.