Skip to content

Commit

Permalink
Precompilation: Limit the default number of tasks to 16 (#2552)
Browse files Browse the repository at this point in the history
* limit the default number of precomp tasks to 16

* add JULIA_NUM_PRECOMPILE_TASKS to docs

(cherry picked from commit d4089a2)
  • Loading branch information
IanButterworth authored and KristofferC committed Jun 10, 2021
1 parent 36f71aa commit cd8c5d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ function precompile(ctx::Context; internal_call::Bool=false, strict::Bool=false,
# Windows sometimes hits a ReadOnlyMemoryError, so we halve the default number of tasks. Issue #2323
# TODO: Investigate why this happens in windows and restore the full task limit
default_num_tasks = Sys.iswindows() ? div(Sys.CPU_THREADS::Int, 2) + 1 : Sys.CPU_THREADS::Int + 1
default_num_tasks = min(default_num_tasks, 16) # limit for better stability on shared resource systems

num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(default_num_tasks)))
parallel_limiter = Base.Semaphore(num_tasks)
Expand Down
3 changes: 2 additions & 1 deletion src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ Precompile all the dependencies of the project in parallel.
!!! note
This method is called automatically after any Pkg action that changes the manifest.
Any packages that have previously errored during precompilation won't be retried in auto mode
until they have changed. To disable automatic precompilation set `ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0`
until they have changed. To disable automatic precompilation set `ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0`.
To manually control the number of tasks used set `ENV["JULIA_NUM_PRECOMPILE_TASKS"]`.
!!! compat "Julia 1.3"
This function requires at least Julia 1.3. On earlier versions
Expand Down
3 changes: 2 additions & 1 deletion src/REPLMode/command_declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ not all manifest dependencies may be loaded by the top-level dependencies on the
This method is called automatically after any Pkg action that changes the manifest.
Any packages that have previously errored during precompilation won't be retried in auto mode
until they have changed. To disable automatic precompilation set the environment variable `JULIA_PKG_PRECOMPILE_AUTO=0`
until they have changed. To disable automatic precompilation set the environment variable `JULIA_PKG_PRECOMPILE_AUTO=0`.
To manually control the number of tasks used set the environment variable `JULIA_NUM_PRECOMPILE_TASKS`.
""",
],
PSA[:name => "status",
Expand Down

0 comments on commit cd8c5d0

Please sign in to comment.