Skip to content

Commit

Permalink
halve the default number of precompilation tasks in windows to avoid J…
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 28, 2021
1 parent 76402b8 commit 5514b1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,12 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
Context!(ctx; kwargs...)
instantiate(ctx; allow_autoprecomp=false, kwargs...)
time_start = time_ns()
num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(Sys.CPU_THREADS::Int + 1)))

# 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() ? round(Int, Sys.CPU_THREADS::Int / 2) + 1 : Sys.CPU_THREADS::Int + 1

num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(default_num_tasks)))
parallel_limiter = Base.Semaphore(num_tasks)
io = ctx.io
fancyprint = can_fancyprint(io)
Expand Down

0 comments on commit 5514b1f

Please sign in to comment.