Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct threads specification for subprocess #3467

Merged
merged 2 commits into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,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 @@ -1679,7 +1693,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