Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmurthy committed Oct 14, 2015
1 parent ef6b3a2 commit bcdd3ee
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ DLLEXPORT size_t jl_maxrss()
GetProcessMemoryInfo( GetCurrentProcess( ), &counter, sizeof(counter) );
return (size_t)counter.PeakWorkingSetSize;

#elif defined(_OS_LINUX_) || defined(_OS_DARWIN_)
#elif defined(_OS_LINUX_) || defined(_OS_DARWIN_) || defined (_OS_FREEBSD_)
struct rusage rusage;
getrusage( RUSAGE_SELF, &rusage );

Expand Down
9 changes: 4 additions & 5 deletions test/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ end
dc_path = joinpath(dir, "dictchannel.jl")
include(dc_path)

w_set=filter!(x->x != myid(), workers())
pid = length(w_set) > 0 ? w_set[1] : myid()

remotecall_fetch(pid, dc_path) do f
# Run the remote on pid 1, since runtests may terminate workers
# at any time depending on memory usage
remotecall_fetch(1, dc_path) do f
include(f)
nothing
end
dc=RemoteRef(()->DictChannel(), pid)
dc=RemoteRef(()->DictChannel(), 1)
@test typeof(dc) == RemoteRef{DictChannel}

@test isready(dc) == false
Expand Down
32 changes: 24 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,46 @@ cd(dirname(@__FILE__)) do

@everywhere include("testdefs.jl")

const max_worker_rss = parse(Int, get(ENV, "JULIA_TEST_MAXRSS_MB", "200"))
results=[]
max_worker_rss = parse(Int, get(ENV, "JULIA_TEST_MAXRSS_MB", "500"))
@sync begin
for p in workers()
@async begin
while length(tests) > 0
test = shift!(tests)
resp = remotecall_fetch(t -> (runtests(t); Sys.maxrss()), p, test)
local resp
try
resp = remotecall_fetch(t -> runtests(t), p, test)
catch e
resp = e
end
push!(results, (test, resp))

if isa(resp, Integer)
if resp > max_worker_rss * 2^20
if (isa(resp, Integer) && (resp > max_worker_rss * 2^20)) || isa(resp, Exception)
if n > 1
rmprocs(p, waitfor=0.5)
p = addprocs(1; exeflags=`--check-bounds=yes --depwarn=error`)[1]
remotecall_fetch(()->include("testdefs.jl"), p)
else
# single process testing, bail if mem limit reached, or on an exception.
isa(resp, Exception) ? rethrow(resp) : error("Halting tests. memory limit reached : $(resp) > $(max_worker_rss * 2^20)")
end
elseif isa(resp, Exception)
rethrow(resp)
else
error("Unknown error $resp while executing test $test")
end
end
end
end
end

errors = filter(x->isa(x[2], Exception), results)
if length(errors) > 0
for err in errors
println("Exception running test $(err[1]) :")
showerror(STDERR, err[2])
println()
end
error("Some tests exited with errors.")
end

if compile_test
n > 1 && print("\tFrom worker 1:\t")
runtests("compile")
Expand Down
6 changes: 3 additions & 3 deletions test/testdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using Base.Test
function runtests(name)
@printf(" \033[1m*\033[0m \033[31m%-21s\033[0m", name)
tt = @elapsed include("$name.jl")
@printf(" in %6.2f seconds, maxrss %7.2f MB\n", tt, Sys.maxrss() / 2^20)

nothing
rss = Sys.maxrss()
@printf(" in %6.2f seconds, maxrss %7.2f MB\n", tt, rss / 2^20)
rss
end

# looking in . messes things up badly
Expand Down

0 comments on commit bcdd3ee

Please sign in to comment.