From 8436f1fa3996235bd492c0f4accb3473c1f7d7d1 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 5 May 2021 18:12:06 -0400 Subject: [PATCH 1/2] limit the default number of precomp tasks to 16 --- src/API.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/API.jl b/src/API.jl index 525758ebd5..c1505e2d33 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1009,6 +1009,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) From b064c8107e4412196f1f0fe6d02bf98b5c730e67 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 5 May 2021 18:12:27 -0400 Subject: [PATCH 2/2] add JULIA_NUM_PRECOMPILE_TASKS to docs --- src/Pkg.jl | 3 ++- src/REPLMode/command_declarations.jl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Pkg.jl b/src/Pkg.jl index a5fc85b4e5..e43f015bb3 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -144,7 +144,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 diff --git a/src/REPLMode/command_declarations.jl b/src/REPLMode/command_declarations.jl index 4585b0244e..0b4175799b 100644 --- a/src/REPLMode/command_declarations.jl +++ b/src/REPLMode/command_declarations.jl @@ -336,7 +336,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",