From 8529b058dbd3fc4da41cb1886cb98e0e63dce2dd Mon Sep 17 00:00:00 2001 From: Nathan Ortega Date: Mon, 2 Sep 2024 11:37:28 -0400 Subject: [PATCH] added warning log that checks for empty interactive threadpools when running in parallel mode --- src/core.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core.jl b/src/core.jl index 111c5698..d85144a1 100644 --- a/src/core.jl +++ b/src/core.jl @@ -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 @@ -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