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

Changed Pkg.test to prioritise julia_args --threads over current process threads #4141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

stemann
Copy link

@stemann stemann commented Jan 25, 2025

Changed Pkg.test to prioritise julia_args --threads over current process threads

Ensures that tests run with threads, both when calling julia --project --threads=auto --eval 'using Pkg; Pkg.test()', and when calling julia --project --eval 'using Pkg; Pkg.test(; julia_args = ["--threads=auto"])'.

Similar to #4140

…ess threads

Ensures that tests run with threads, both when calling `julia --project --threads=auto --eval 'using Pkg; Pkg.test()'`, and when calling `julia --project --eval 'using Pkg; Pkg.test(; julia_args = ["--threads=auto"])'`.
@IanButterworth
Copy link
Member

Makes sense. Can you add a test

@stemann
Copy link
Author

stemann commented Jan 26, 2025

Not completely sure how to properly add this test, but what I am aiming for is something similar to running the following for the added TestThreads test package:

EXPECTED_NTHREADS=1 julia +nightly --project --eval 'using Pkg; Pkg.test()'

EXPECTED_NTHREADS=2 julia +nightly --project --threads=2 --eval 'using Pkg; Pkg.test()'

EXPECTED_NTHREADS=2 julia +nightly --project --eval 'using Pkg; Pkg.test(; julia_args=["--threads=2"])'

EXPECTED_NTHREADS=1 julia +nightly --project --threads=2 --eval 'using Pkg; Pkg.test(; julia_args=["--threads=1"])'

Edit: This is the behaviour on Julia 1.6, and 1.10.

@stemann
Copy link
Author

stemann commented Jan 26, 2025

I guess, one could also add:

EXPECTED_NTHREADS=2 JULIA_NUM_THREADS=2 julia +nightly --project --eval 'using Pkg; Pkg.test()'

EXPECTED_NTHREADS=2 julia +nightly --project --eval 'using Pkg; Pkg.test(; julia_args=Cmd(``; env=Dict("JULIA_NUM_THREADS" => 2)))'

EXPECTED_NTHREADS=1 JULIA_NUM_THREADS=2 julia +nightly --project --eval 'using Pkg; Pkg.test(; julia_args=Cmd(``; env=Dict("JULIA_NUM_THREADS" => 1)))'

@stemann
Copy link
Author

stemann commented Jan 30, 2025

Any suggestions for how to implement the tests?

@IanButterworth
Copy link
Member

Take a look at existing test packages and add one that can be called by Pkg.test in tests.

@IanButterworth
Copy link
Member

Just a passing comment that this should probably account for and test both threadpools

@stemann
Copy link
Author

stemann commented Feb 1, 2025

Did something change post-Julia-1.11, that remedied the issue with passing --threads=auto to the precompile process, as part of test? I.e., making the change in #4140 irrelevant for Julia 1.12+, cf. JuliaLang/julia#53572 (comment).

@@ -2276,7 +2276,7 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
printpkgstyle(ctx.io, :Testing, "Running tests...")
flush(ctx.io)
code = gen_test_code(source_path; test_args)
cmd = `$(Base.julia_cmd()) $(flags) --eval $code`
cmd = Cmd(`$(Base.julia_cmd()) $(flags) --eval $code`; env = julia_args.env)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the other parts of the julia_args Cmd?

Is it safe to ignore julia_args.cpus, julia_args.dir, julia_args.flags (!= flags), and julia_args.ignorestatus?

@stemann stemann force-pushed the feature/test_julia_args_threads branch from ad66721 to 304fffd Compare February 1, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants