From 32fc6150b5515fb7774981390af31ee61eebee70 Mon Sep 17 00:00:00 2001 From: Christian <28689358+christiangnrd@users.noreply.github.com> Date: Sun, 20 Sep 2026 21:26:48 -0300 Subject: [PATCH] Only warn about slow init times when they exceed 10 seconds Co-Authored-By: Claude Fable 5.1 --- src/ParallelTestRunner.jl | 8 ++++++-- test/workers.jl | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 5d8a2854..18d954b1 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -149,8 +149,11 @@ function init_time(rec::AbstractTestRecord) return base.total_time - base.time end -# the user is warned once a warm worker's init time exceeds this multiple of the cold-start cost +# the user is warned once a warm worker's init time exceeds this multiple of the cold-start cost... const SLOW_INIT_FACTOR = 2 +# ... but only if it also exceeds this many seconds, to avoid false positives in test suites +# with a short cold worker init +const SLOW_INIT_MIN_TIME = 10.0 function Base.getindex(rec::AbstractTestRecord) return parent(rec).value @@ -1574,7 +1577,8 @@ function _runtests(mod::Module, args::ParsedArgs; # the pre-test full GC has become much slower than spawning a # new worker, which typically means there are too many workers # for the available memory (e.g. macOS memory pressure, #124) - slow_init = wrkr === p && !fresh_worker && init_time(result) > SLOW_INIT_FACTOR * cold_init_time[] + slow_init = wrkr === p && !fresh_worker && + init_time(result) > max(SLOW_INIT_FACTOR * cold_init_time[], SLOW_INIT_MIN_TIME) # recycle a pool worker so future tests start with a smaller working # set, or so that a failing test that may have left the worker in a # bad state (e.g. a wedged GPU driver) cannot poison later tests diff --git a/test/workers.jl b/test/workers.jl index 92d00018..78220c2b 100644 --- a/test/workers.jl +++ b/test/workers.jl @@ -218,7 +218,8 @@ end end # every test after the first on the worker is slow to init - slow_init = ceil(Int, 1.5 * ParallelTestRunner.SLOW_INIT_FACTOR * cold_init_time[]) + 1 + slow_init = ceil(Int, max(1.5 * ParallelTestRunner.SLOW_INIT_FACTOR * cold_init_time[], + ParallelTestRunner.SLOW_INIT_MIN_TIME)) + 1 init_code = quote Main.slow_init_counter[] += 1 Main.slow_init_counter[] > 1 && sleep($slow_init)