From d89db24dd90d5ea2f846023e7fec2ad95ffd8896 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Wed, 25 Oct 2023 21:16:27 -0400 Subject: [PATCH 1/2] debug slow windows temp purge --- test/runtests.jl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index a7aeee73d0..ba78ba9c24 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -95,7 +95,28 @@ Logging.with_logger(hide_logs ? Logging.NullLogger() : Logging.current_logger()) end end -@showtime Base.Filesystem.temp_cleanup_purge(force=true) +function temp_cleanup_purge(; force::Bool=false) + @info "temp_cleanup_purge started" + need_gc = Sys.iswindows() + for (path, asap) in Base.Filesystem.TEMP_CLEANUP + @time path try + if (force || asap) && ispath(path) + need_gc && GC.gc(true) + need_gc = false + Base.Filesystem.prepare_for_deletion(path) + rm(path, recursive=true, force=true) + end + !ispath(path) && delete!(Base.Filesystem.TEMP_CLEANUP, path) + catch ex + @warn """ + Failed to clean up temporary path $(repr(path)) + $ex + """ _group=:file + end + end +end + +@showtime temp_cleanup_purge(force=true) end # module From 3f2de8b1a1503f0722cc51822e4cf6ea8e4e88f3 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Wed, 25 Oct 2023 22:35:34 -0400 Subject: [PATCH 2/2] more debug --- test/runtests.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index ba78ba9c24..f1f9c8c2b3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,9 +98,11 @@ end function temp_cleanup_purge(; force::Bool=false) @info "temp_cleanup_purge started" need_gc = Sys.iswindows() + contents = nothing for (path, asap) in Base.Filesystem.TEMP_CLEANUP - @time path try + t = @elapsed try if (force || asap) && ispath(path) + contents = isfile(path) ? "file" : readdir(path) need_gc && GC.gc(true) need_gc = false Base.Filesystem.prepare_for_deletion(path) @@ -113,6 +115,9 @@ function temp_cleanup_purge(; force::Bool=false) $ex """ _group=:file end + if t > 1 + @info "$path took $(t) seconds" contents + end end end