From 17441cc0d5b7b56f9900a33e11ebf212176c8db5 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 20 Jan 2025 07:36:35 -0500 Subject: [PATCH 1/4] make excluded threadunsafe tests threadsafe --- test/distributed_exec.jl | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/test/distributed_exec.jl b/test/distributed_exec.jl index d80d642..e11657a 100644 --- a/test/distributed_exec.jl +++ b/test/distributed_exec.jl @@ -159,18 +159,6 @@ function _getenv_include_thread_unsafe() return b end const _env_include_thread_unsafe = _getenv_include_thread_unsafe() -function include_thread_unsafe_tests() - if Threads.maxthreadid() > 1 - if _env_include_thread_unsafe - return true - end - msg = "Skipping a thread-unsafe test because `Threads.maxthreadid() > 1`" - @warn msg Threads.maxthreadid() - Test.@test_broken false - return false - end - return true -end # Distributed GC tests for Futures function test_futures_dgc(id) @@ -294,16 +282,14 @@ let wid1 = workers()[1], fstore = RemoteChannel(wid2) put!(fstore, rr) - if include_thread_unsafe_tests() - # timedwait() is necessary because wid1 is asynchronously informed of - # the existence of rr/rrid through the call to `put!(fstore, rr)`. - @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok - end + # timedwait() is necessary because wid1 is asynchronously informed of + # the existence of rr/rrid through the call to `put!(fstore, rr)`. + @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok + finalize(rr) # finalize locally yield() # flush gc msgs - if include_thread_unsafe_tests() - @test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true - end + @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok + remotecall_fetch(r -> (finalize(take!(r)); yield(); nothing), wid2, fstore) # finalize remotely sleep(0.5) # to ensure that wid2 messages have been executed on wid1 @test poll_while(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid)) From 30fa8b1d1ae54640fb3457596590d26a01058065 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 20 Jan 2025 07:37:01 -0500 Subject: [PATCH 2/4] ignore Manifest.toml --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d1d02a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +Manifest.toml From e57bd11cfe4058aa600187f92903be07930086c4 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 20 Jan 2025 08:36:24 -0500 Subject: [PATCH 3/4] Revert "make excluded threadunsafe tests threadsafe" This reverts commit 17441cc0d5b7b56f9900a33e11ebf212176c8db5. --- test/distributed_exec.jl | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/test/distributed_exec.jl b/test/distributed_exec.jl index e11657a..d80d642 100644 --- a/test/distributed_exec.jl +++ b/test/distributed_exec.jl @@ -159,6 +159,18 @@ function _getenv_include_thread_unsafe() return b end const _env_include_thread_unsafe = _getenv_include_thread_unsafe() +function include_thread_unsafe_tests() + if Threads.maxthreadid() > 1 + if _env_include_thread_unsafe + return true + end + msg = "Skipping a thread-unsafe test because `Threads.maxthreadid() > 1`" + @warn msg Threads.maxthreadid() + Test.@test_broken false + return false + end + return true +end # Distributed GC tests for Futures function test_futures_dgc(id) @@ -282,14 +294,16 @@ let wid1 = workers()[1], fstore = RemoteChannel(wid2) put!(fstore, rr) - # timedwait() is necessary because wid1 is asynchronously informed of - # the existence of rr/rrid through the call to `put!(fstore, rr)`. - @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok - + if include_thread_unsafe_tests() + # timedwait() is necessary because wid1 is asynchronously informed of + # the existence of rr/rrid through the call to `put!(fstore, rr)`. + @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok + end finalize(rr) # finalize locally yield() # flush gc msgs - @test timedwait(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid), 10) === :ok - + if include_thread_unsafe_tests() + @test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true + end remotecall_fetch(r -> (finalize(take!(r)); yield(); nothing), wid2, fstore) # finalize remotely sleep(0.5) # to ensure that wid2 messages have been executed on wid1 @test poll_while(() -> remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid)) From 8b64123442a25a327736a1ae5ed11908947e4666 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 20 Jan 2025 08:37:27 -0500 Subject: [PATCH 4/4] instead check the default threadpool size --- test/distributed_exec.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/distributed_exec.jl b/test/distributed_exec.jl index d80d642..b730df1 100644 --- a/test/distributed_exec.jl +++ b/test/distributed_exec.jl @@ -160,12 +160,12 @@ function _getenv_include_thread_unsafe() end const _env_include_thread_unsafe = _getenv_include_thread_unsafe() function include_thread_unsafe_tests() - if Threads.maxthreadid() > 1 + if Threads.threadpoolsize(:default) > 1 if _env_include_thread_unsafe return true end - msg = "Skipping a thread-unsafe test because `Threads.maxthreadid() > 1`" - @warn msg Threads.maxthreadid() + msg = "Skipping a thread-unsafe test because `Threads.threadpoolsize(:default) > 1`" + @warn msg Threads.threadpoolsize(:default) Test.@test_broken false return false end