Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test spawning a lot of tasks #42975

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/profile_spawnmany_exec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Profile

function spawnmany(n)
if n > 2
m = n ÷ 2
t = Threads.@spawn spawnmany(m)
spawnmany(m)
wait(t)
end
end

@profile spawnmany(parse(Int, get(ENV, "NTASKS", "2000000")))
36 changes: 36 additions & 0 deletions test/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,39 @@ end

# We don't need the watchdog anymore
close(proc.in)

# https://github.com/JuliaLang/julia/pull/42973
@testset "spawn and wait *a lot* of tasks in @profile" begin
# Not using threads_exec.jl for better isolation, reproducibility, and a
# tighter timeout.
script = "profile_spawnmany_exec.jl"
cmd = `$(Base.julia_cmd()) --depwarn=error --rr-detach --startup-file=no $script`
@testset for n in [20000, 200000, 2000000]
proc = run(ignorestatus(setenv(cmd, "NTASKS" => n; dir = @__DIR__)); wait = false)
done = Threads.Atomic{Bool}(false)
timeout = false
timer = Timer(10) do _
timeout = true
for sig in [Base.SIGTERM, Base.SIGHUP, Base.SIGKILL]
for _ in 1:1000
kill(proc, sig)
if done[]
if sig != Base.SIGTERM
@warn "Terminating `$script` required signal $sig"
end
return
end
sleep(0.001)
end
end
end
try
wait(proc)
finally
done[] = true
close(timer)
end
@test success(proc)
@test !timeout
end
end