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

RFC: Run each test in separate julia process to save memory #13567

Closed
wants to merge 1 commit 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
1 change: 0 additions & 1 deletion test/char.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

#tests for /base/char.jl

@test typemin(Char) == 0
@test ndims(Char) == 0
@test getindex('a', 1) == 'a'
Expand Down
28 changes: 25 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,35 @@ cd(dirname(@__FILE__)) do
n = 1
if net_on
n = min(8, CPU_CORES, length(tests))
n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
blas_set_num_threads(1)
# n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
# blas_set_num_threads(1)
end

@everywhere include("testdefs.jl")

reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true))
# reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true))
tr = Int[]
m = 0
while !isempty(tests)
if m < n
testi = shift!(tests)
m += 1
@schedule begin
push!(tr, !runtests(testi))
m -= 1
return nothing
end
else
sleep(0.5)
end
sleep(0.1)
end
while m > 0
wait()
end
if sum(tr) > 0
error("total number of errors was $(sum(tr))")
end

if compile_test
n > 1 && print("\tFrom worker 1:\t")
Expand Down
16 changes: 4 additions & 12 deletions test/testdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
using Base.Test

function runtests(name)
exename = joinpath(JULIA_HOME, Base.julia_exename())
testcmd = "using Base.Test; blas_set_num_threads(1); include(\"$name.jl\") " # use space to add single quotes when printed in shell
tt = @elapsed (r = success(pipeline(`$exename --check-bounds=yes --depwarn=error -e $testcmd`, stderr=STDERR)))
@printf(" \033[1m*\033[0m \033[31m%-21s\033[0m", name)
tt = @elapsed include("$name.jl")
@printf(" in %6.2f seconds\n", tt)
nothing
end

function propagate_errors(a,b)
if isa(a,Exception)
rethrow(a)
end
if isa(b,Exception)
rethrow(b)
end
nothing
return r
end

# looking in . messes things up badly
Expand Down