Skip to content

Commit 89614fe

Browse files
committed
Close perf when done to prevent too many files open error
1 parent 7e9bfba commit 89614fe

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
@@ -589,19 +589,25 @@ function generate_benchmark_definition(
589589
__linux_perf_bench = BenchmarkTools.LinuxPerf.make_bench_threaded(
590590
__linux_perf_groups; threads=$(params.linux_perf_options.threads)
591591
)
592-
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
593-
# We'll just run it one time.
594-
__return_val_2 = $(invocation)
595-
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
596-
# trick the compiler not to eliminate the code
597-
if rand() < 0
598-
__linux_perf_stats = __return_val_2
599-
else
600-
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
601-
__linux_perf_bench
602-
)
592+
try
593+
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
594+
# We'll just run it one time.
595+
__return_val_2 = $(invocation)
596+
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
597+
# trick the compiler not to eliminate the code
598+
if rand() < 0
599+
__linux_perf_stats = __return_val_2
600+
else
601+
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
602+
__linux_perf_bench
603+
)
604+
end
605+
catch
606+
rethrow()
607+
finally
608+
close(__linux_perf_bench)
609+
$(teardown)
603610
end
604-
$(teardown)
605611
else
606612
__return_val_2 = nothing
607613
__linux_perf_stats = nothing

0 commit comments

Comments
 (0)