Skip to content

Commit 35fcfda

Browse files
authored
Close uv_idle handles when we're done with them (#39268)
uv_idle handles are a bit dangerous because the essentially prevent the uv loop from going to sleep, so if there's no work to be done on the julia side, it just turns into a busy loop. We start such an idle callback in the threads.jl test. We make sure it goes out of scope, so the GC will eventually close it, but in the meantime they keep the loop spinning. Now, unfortunately, the next test in line is the Distributed test, which runs everything in a subprocess, so it never builds up enough memory pressure to actually run the GC, so the idle handles never get closed. This isn't too big a deal, as the worst thing that happens is that it hogs one CPU core on CI while the threads test is running, but we don't have enough parallelism there anyway, so I don't expect a meaningful impact on CI. It does however blow up our rr traces and apparently causes significantly problems when trying to replay them on pernosco. This is easy to fix by just closing these handles once we're done with them.
1 parent f813257 commit 35fcfda

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/threads.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ function Base.uvfinalize(t::UvTestIdle)
100100
nothing
101101
end
102102

103+
function Base.close(idle::UvTestIdle)
104+
Base.uvfinalize(idle)
105+
end
106+
103107
function Base.wait(idle::UvTestIdle)
104108
Base.iolock_begin()
105109
Base.preserve_handle(idle)
@@ -129,12 +133,14 @@ proc = open(pipeline(`$(Base.julia_cmd()) -e $cmd`; stderr=stderr); write=true)
129133

130134
let idle=UvTestIdle()
131135
wait(idle)
136+
close(idle)
132137
end
133138

134139
using Base.Threads
135140
@threads for i = 1:1
136141
let idle=UvTestIdle()
137142
wait(idle)
143+
close(idle)
138144
end
139145
end
140146

0 commit comments

Comments
 (0)