Limit benching to 60s, before killing engines/threads and raising an exception (#225)
Adds a fourth possible OpenBenchBadBenchException exception during benching, for exceeding the max bench duration. This ensures that engines that infinitely stall, do not also lock up OpenBench clients. Additionally, make sure to clean up possible zombie processes that existed even in the case of a proper bench.
This commit is contained in:
1 parent
e2673c3cd1
commit
9e94da6b1f
3 files changed
+27
-9
No files matched your search
+19
-5
@@ -32,12 +32,16 @@
|
||||
|
||||
import multiprocessing
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from utils import kill_process_by_name
|
||||
from utils import OpenBenchBadBenchException
|
||||
|
||||
MAX_BENCH_TIME_SECONDS = 60
|
||||
|
||||
def parse_stream_output(stream):
|
||||
|
||||
nps = bench = None # Search through output Stream
|
||||
@@ -88,13 +92,23 @@ def multi_core_bench(binary, network, private, threads):
|
||||
|
||||
processes = [
|
||||
multiprocessing.Process(
|
||||
target=single_core_bench,
|
||||
args=(binary, network, private, outqueue)
|
||||
) for ii in range(threads)
|
||||
target=single_core_bench, args=(binary, network, private, outqueue))
|
||||
for ii in range(threads)
|
||||
]
|
||||
|
||||
for process in processes: process.start()
|
||||
return [outqueue.get() for ii in range(threads)]
|
||||
for process in processes:
|
||||
process.start()
|
||||
|
||||
try: # Every process deposits exactly one result into the Queue
|
||||
return [outqueue.get(timeout=MAX_BENCH_TIME_SECONDS) for ii in range(threads)]
|
||||
|
||||
except queue.Empty: # Force kill the engine, thus causing the processes to finish
|
||||
kill_process_by_name(binary)
|
||||
raise OpenBenchBadBenchException('[%s] Bench Exceeded Max Duration' % (binary))
|
||||
|
||||
finally: # Join everything to avoid zombie processes
|
||||
for process in processes:
|
||||
process.join()
|
||||
|
||||
def run_benchmark(binary, network, private, threads, sets, expected=None):
|
||||
|
||||
|
||||
+2
-2
@@ -21,10 +21,10 @@
|
||||
# The sole purpose of this module is to invoke create_genfens_opening_book().
|
||||
#
|
||||
# This will execute engines with commands like the following:
|
||||
# ./engine "genfens N seed S book <None|Books/book.epd> <?exta>" "quit"
|
||||
# ./engine "genfens N seed S book <None|Books/book.epd> <?extra>" "quit"
|
||||
#
|
||||
# This work is split over many engines. If a workload requires 1024 openings,
|
||||
# and there are 16 threads, then each thread will generate 128 openings. The
|
||||
# and there are 16 threads, then each thread will generate 64 openings. The
|
||||
# openings are saved to Books/openbench.genfens.epd
|
||||
#
|
||||
# create_genfens_opening_book() may raise utils.OpenBenchFailedGenfensException.
|
||||
|
||||
Reference in new issue
Block a user