Skip to content

Commit 1f9b1f9

Browse files
committed
Close perf when done to prevent too many files open error
1 parent 6e76888 commit 1f9b1f9

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/execution.jl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,19 +594,25 @@ function generate_benchmark_definition(
594594
__linux_perf_bench = BenchmarkTools.LinuxPerf.make_bench_threaded(
595595
__linux_perf_groups; threads=$(params.linux_perf_options.threads)
596596
)
597-
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
598-
# We'll just run it one time.
599-
__return_val_2 = $(invocation)
600-
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
601-
# trick the compiler not to eliminate the code
602-
if rand() < 0
603-
__linux_perf_stats = __return_val_2
604-
else
605-
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
606-
__linux_perf_bench
607-
)
597+
try
598+
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
599+
# We'll just run it one time.
600+
__return_val_2 = $(invocation)
601+
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
602+
# trick the compiler not to eliminate the code
603+
if rand() < 0
604+
__linux_perf_stats = __return_val_2
605+
else
606+
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
607+
__linux_perf_bench
608+
)
609+
end
610+
catch
611+
rethrow()
612+
finally
613+
close(__linux_perf_bench)
614+
$(teardown)
608615
end
609-
$(teardown)
610616
else
611617
__return_val_2 = nothing
612618
__linux_perf_stats = nothing

0 commit comments

Comments
 (0)