diff --git a/src/python/benchUtil.py b/src/python/benchUtil.py index 5fd8ca9f..5620b846 100644 --- a/src/python/benchUtil.py +++ b/src/python/benchUtil.py @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import datetime import math import os import pickle @@ -946,13 +947,20 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac print(" cd %s" % s) os.chdir(s) + # Create timestamped log subdirectory to avoid conflicts between runs + now = datetime.datetime.now() + timeStamp = now.strftime("%Y.%m.%d.%H.%M.%S") + runLogDir = f"{constants.LOGS_DIR}/{id}/{timeStamp}" + os.makedirs(runLogDir, exist_ok=True) + print(f" log dir {runLogDir}") + try: cmd = [] cmd += index.javaCommand.split() w = lambda *xs: [cmd.append(str(x)) for x in xs] w("-classpath", classPathToString(getClassPath(index.checkout))) - jfrOutput = f"{constants.LOGS_DIR}/bench-index-{id}-{index.getName()}.jfr" + jfrOutput = f"{runLogDir}/bench-index-{id}-{index.getName()}.jfr" # 77: always enable Java Flight Recorder profiling w( @@ -1048,16 +1056,16 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac if index.quantizeKNNGraph: w("-quantizeKNNGraph") - fullLogFile = "%s/%s.%s.log" % (constants.LOGS_DIR, id, index.getName()) + fullLogFile = "%s/%s.%s.log" % (runLogDir, id, index.getName()) print(" log %s" % fullLogFile) t0 = time.time() if VMSTAT_PATH is not None: - vmstatLogFile = f"{constants.LOGS_DIR}/{id}.vmstat.log" + vmstatLogFile = f"{runLogDir}/{id}.vmstat.log" else: vmstatLogFile = None - topLogFile = f"{constants.LOGS_DIR}/{id}.top.log" + topLogFile = f"{runLogDir}/{id}.top.log" run(cmd, fullLogFile, vmstatLogFile=vmstatLogFile, topLogFile=topLogFile) t1 = time.time() if printCharts and IndexChart.Gnuplot is not None: diff --git a/src/python/ps_head.py b/src/python/ps_head.py index 92941014..c43e5e13 100644 --- a/src/python/ps_head.py +++ b/src/python/ps_head.py @@ -48,7 +48,7 @@ def __init__(self, top_n, log_file_name, poll_interval_sec=5): # edit: ok I asked Claude "what is the origin of the odd unix spelling daemon?": - ''' + """ The Unix spelling "daemon" has a fascinating origin that predates computing entirely. It comes from ancient Greek mythology, where a "daemon" (δαίμων) referred to a supernatural being or spirit that worked in the background, often as an intermediary between gods and humans - neither good nor evil, just quietly doing its job. The computing use was coined at MIT's Project MAC in 1963. According to Fernando J. Corbató (who worked on the project), they deliberately chose this spelling over "demon" to avoid any negative connotations. The team liked the metaphor of these helpful background spirits that quietly performed tasks without direct human interaction. @@ -58,8 +58,8 @@ def __init__(self, top_n, log_file_name, poll_interval_sec=5): This naming choice reflects the playful academic culture at MIT and other early computing centers, where classical education often influenced technical terminology. The researchers appreciated how perfectly the mythological concept mapped to these background processes - invisible helpers doing necessary work behind the scenes, starting up when needed and running continuously without human intervention. It's one of many examples where Unix culture embraced clever wordplay and literary references (like "grep" from "g/re/p" - globally search for regular expression and print). -''' - +""" + self.thread = threading.Thread(target=self.__run_thread, daemon=True) self.thread.start()