ThreadPools.jl
ThreadPools.jl copied to clipboard
have bugs on Julia1.7
When I run https://github.com/jonathan-laurent/AlphaZero.jl on Julia 1.7, It will run out of cpu and dont progress.
Below is a minimal test(sometime it is ok, needs several times run). I think this may be sth with Julia 1.7 new task sheculers.
import Base.Threads: Atomic, atomic_add!
using ThreadPools
function test_threadpools(nworkers)
tasks = []
ret = []
done_n = Atomic()
nbg = 4
for i = 1:nworkers
tid = 2 + i % nbg
println("mapreduce before tspawnat: $i, $tid")
task = ThreadPools.@tspawnat tid begin
println("mapreduce in thread: $tid, $(Threads.threadid())")
t1 = time()
while time() - t1 < 0.01
end
atomic_add!(done_n, 1)
push!(ret, Threads.threadid())
end
push!(tasks, task)
end
wait.(tasks)
println("done_n: $done_n")
return ret
end
test_threadpools(64 * 10)
I test it on Ubuntu 18.04:
julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Julia 1.6.x is ok.
Passes unit tests and your example on 1.7.1. Still an issue for you?