Skip to content

Commit 4c9d0fb

Browse files
committed
Close perf when done to prevent too many files open error
1 parent 63e5cbe commit 4c9d0fb

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
@@ -596,19 +596,25 @@ function generate_benchmark_definition(
596596
__linux_perf_bench = BenchmarkTools.LinuxPerf.make_bench_threaded(
597597
__linux_perf_groups; threads=$(params.linux_perf_options.threads)
598598
)
599-
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
600-
# We'll just run it one time.
601-
__return_val_2 = $(invocation)
602-
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
603-
# trick the compiler not to eliminate the code
604-
if rand() < 0
605-
__linux_perf_stats = __return_val_2
606-
else
607-
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
608-
__linux_perf_bench
609-
)
599+
try
600+
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
601+
# We'll just run it one time.
602+
__return_val_2 = $(invocation)
603+
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
604+
# trick the compiler not to eliminate the code
605+
if rand() < 0
606+
__linux_perf_stats = __return_val_2
607+
else
608+
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
609+
__linux_perf_bench
610+
)
611+
end
612+
catch
613+
rethrow()
614+
finally
615+
close(__linux_perf_bench)
616+
$(teardown)
610617
end
611-
$(teardown)
612618
else
613619
__return_val_2 = nothing
614620
__linux_perf_stats = nothing

0 commit comments

Comments
 (0)