Skip to content

Commit cdc21b8

Browse files
Lower max RSS value on low memory systems (#88)
1 parent bf1e35a commit cdc21b8

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,20 @@ Malt.isrunning(wrkr::PTRWorker) = Malt.isrunning(wrkr.w)
4545
Malt.stop(wrkr::PTRWorker) = Malt.stop(wrkr.w)
4646

4747
#Always set the max rss so that if tests add large global variables (which they do) we don't make the GC's life too hard
48-
if Sys.WORD_SIZE == 64
49-
const JULIA_TEST_MAXRSS_MB = 3800
50-
else
51-
# Assume that we only have 3.5GB available to a single process, and that a single
52-
# test can take up to 2GB of RSS. This means that we should instruct the test
53-
# framework to restart any worker that comes into a test set with 1.5GB of RSS.
54-
const JULIA_TEST_MAXRSS_MB = 1536
48+
function get_max_worker_rss()
49+
mb = if haskey(ENV, "JULIA_TEST_MAXRSS_MB")
50+
parse(Int, ENV["JULIA_TEST_MAXRSS_MB"])
51+
elseif Sys.WORD_SIZE == 64
52+
Sys.total_memory() > 8*2^30 ? 3800 : 3000
53+
else
54+
# Assume that we only have 3.5GB available to a single process, and that a single
55+
# test can take up to 2GB of RSS. This means that we should instruct the test
56+
# framework to restart any worker that comes into a test set with 1.5GB of RSS.
57+
1536
58+
end
59+
return mb * 2^20
5560
end
5661

57-
const max_worker_rss = JULIA_TEST_MAXRSS_MB * 2^20
58-
5962
function with_testset(f, testset)
6063
@static if VERSION >= v"1.13.0-DEV.1044"
6164
Test.@with_testset testset f()
@@ -666,7 +669,8 @@ end
666669
init_worker_code = :(),
667670
test_worker = Returns(nothing),
668671
stdout = Base.stdout,
669-
stderr = Base.stderr)
672+
stderr = Base.stderr,
673+
max_worker_rss = get_max_worker_rss())
670674
runtests(mod::Module, ARGS; ...)
671675
672676
Run Julia tests in parallel across multiple worker processes.
@@ -689,6 +693,7 @@ Several keyword arguments are also supported:
689693
- `test_worker`: Optional function that takes a test name and `init_worker_code` if `init_worker_code` is defined and returns a specific worker.
690694
When returning `nothing`, the test will be assigned to any available default worker.
691695
- `stdout` and `stderr`: I/O streams to write to (default: `Base.stdout` and `Base.stderr`)
696+
- `max_worker_rss`: RSS threshold where a worker will be restarted once it is reached.
692697
693698
## Command Line Options
694699
@@ -764,7 +769,7 @@ issues during long test runs. The memory limit is set based on system architectu
764769
function runtests(mod::Module, args::ParsedArgs;
765770
testsuite::Dict{String,Expr} = find_tests(pwd()),
766771
init_code = :(), init_worker_code = :(), test_worker = Returns(nothing),
767-
stdout = Base.stdout, stderr = Base.stderr)
772+
stdout = Base.stdout, stderr = Base.stderr, max_worker_rss = get_max_worker_rss())
768773
#
769774
# set-up
770775
#

0 commit comments

Comments
 (0)