Skip to content

Commit c6f495c

Browse files
IanButterworthfredrikekre
authored andcommitted
Precomp: Halve the default number of precompilation tasks in windows to avoid ReadOnlyMemoryError (#2366)
* halve the default number of precompilation tasks in windows to avoid #2323 Co-authored-by: Fredrik Ekre <[email protected]> (cherry picked from commit 320ec76)
1 parent 2941aab commit c6f495c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/API.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,12 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
914914
Context!(ctx; kwargs...)
915915
instantiate(ctx; allow_autoprecomp=false, kwargs...)
916916
time_start = time_ns()
917-
num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(Sys.CPU_THREADS::Int + 1)))
917+
918+
# Windows sometimes hits a ReadOnlyMemoryError, so we halve the default number of tasks. Issue #2323
919+
# TODO: Investigate why this happens in windows and restore the full task limit
920+
default_num_tasks = Sys.iswindows() ? div(Sys.CPU_THREADS::Int, 2) + 1 : Sys.CPU_THREADS::Int + 1
921+
922+
num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(default_num_tasks)))
918923
parallel_limiter = Base.Semaphore(num_tasks)
919924
io = ctx.io
920925
fancyprint = can_fancyprint(io)

0 commit comments

Comments
 (0)