Skip to content

Commit 267fce3

Browse files
committed
Periodically recycle workers to avoid handle exhaustion.
1 parent 3f1f039 commit 267fce3

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/compiler/compilation.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ end
5353
end
5454

5555
# compile to executable machine code
56+
const compilations = Threads.Atomic{Int}(0)
5657
function compile(@nospecialize(job::CompilerJob))
5758
# TODO: this creates a context; cache those.
5859
obj, meta = JuliaContext() do ctx
5960
GPUCompiler.compile(:obj, job)
6061
end
62+
compilations[] += 1
6163

6264
(obj, entry=LLVM.name(meta.entry))
6365
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ try
280280
p = recycle_worker(p)
281281
else
282282
print_testworker_stats(test, wrkr, resp)
283+
284+
compilations = resp[7]
285+
if Sys.iswindows() && compilations > 100
286+
# XXX: restart to avoid handle exhaustion
287+
# (see pocl/pocl#1941)
288+
@warn "Restarting worker $wrkr to avoid handle exhaustion"
289+
p = recycle_worker(p)
290+
end
283291
end
284292
end
285293

test/setup.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function runtests(f, name, platform_filter)
114114

115115
# process results
116116
cpu_rss = Sys.maxrss()
117+
compilations = OpenCL.compilations[]
117118
if VERSION >= v"1.11.0-DEV.1529"
118119
tc = Test.get_test_counts(data[1])
119120
passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken =
@@ -130,7 +131,7 @@ function runtests(f, name, platform_filter)
130131
data[4],
131132
data[5])
132133
end
133-
res = vcat(collect(data), cpu_rss)
134+
res = vcat(collect(data), cpu_rss, compilations)
134135

135136
GC.gc(true)
136137
res

0 commit comments

Comments
 (0)