Skip to content

Commit

Permalink
feature/interactive-threadpool-warning (#213)
Browse files Browse the repository at this point in the history
added warning log that checks for empty interactive threadpools when running in parallel mode
  • Loading branch information
ndortega authored Sep 2, 2024
1 parent db7b535 commit 4b56baf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Dates
using Reexport
using RelocatableFolders
using DataStructures: CircularDeque
import Base.Threads: lock
import Base.Threads: lock, nthreads

include("util.jl"); @reexport using .Util
include("types.jl"); @reexport using .Types
Expand Down Expand Up @@ -51,6 +51,16 @@ function serverwelcome(host::String, port::Int, docs::Bool, metrics::Bool, paral
end
if parallel
@info "🚀 Running in parallel mode with $(Threads.nthreads()) threads"
# Check if the current julia version supports interactive threadpools
if hasmethod(getfield(Threads, Symbol("@spawn")), Tuple{LineNumberNode, Module, Symbol, Expr})
# Add a warnign if the interactive threadpool is empty when running in parallel mode
if nthreads(:interactive) == 0
@warn """
🚨 Interactive threadpool is empty. This can hurt performance when running in parallel mode.
Try launching julia like \"julia --threads 3,1\" to add 1 thread to the interactive threadpool.
"""
end
end
end
end

Expand Down

0 comments on commit 4b56baf

Please sign in to comment.