Skip to content

Commit 2b3811f

Browse files
authored
Create timestamped subdirectories for logs
2 parents a1adaf5 + 46e3e28 commit 2b3811f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/python/benchUtil.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
import datetime
1819
import math
1920
import os
2021
import pickle
@@ -946,13 +947,20 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac
946947
print(" cd %s" % s)
947948
os.chdir(s)
948949

950+
# Create timestamped log subdirectory to avoid conflicts between runs
951+
now = datetime.datetime.now()
952+
timeStamp = now.strftime("%Y.%m.%d.%H.%M.%S")
953+
runLogDir = f"{constants.LOGS_DIR}/{id}/{timeStamp}"
954+
os.makedirs(runLogDir, exist_ok=True)
955+
print(f" log dir {runLogDir}")
956+
949957
try:
950958
cmd = []
951959
cmd += index.javaCommand.split()
952960
w = lambda *xs: [cmd.append(str(x)) for x in xs]
953961
w("-classpath", classPathToString(getClassPath(index.checkout)))
954962

955-
jfrOutput = f"{constants.LOGS_DIR}/bench-index-{id}-{index.getName()}.jfr"
963+
jfrOutput = f"{runLogDir}/bench-index-{id}-{index.getName()}.jfr"
956964

957965
# 77: always enable Java Flight Recorder profiling
958966
w(
@@ -1048,16 +1056,16 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac
10481056
if index.quantizeKNNGraph:
10491057
w("-quantizeKNNGraph")
10501058

1051-
fullLogFile = "%s/%s.%s.log" % (constants.LOGS_DIR, id, index.getName())
1059+
fullLogFile = "%s/%s.%s.log" % (runLogDir, id, index.getName())
10521060

10531061
print(" log %s" % fullLogFile)
10541062

10551063
t0 = time.time()
10561064
if VMSTAT_PATH is not None:
1057-
vmstatLogFile = f"{constants.LOGS_DIR}/{id}.vmstat.log"
1065+
vmstatLogFile = f"{runLogDir}/{id}.vmstat.log"
10581066
else:
10591067
vmstatLogFile = None
1060-
topLogFile = f"{constants.LOGS_DIR}/{id}.top.log"
1068+
topLogFile = f"{runLogDir}/{id}.top.log"
10611069
run(cmd, fullLogFile, vmstatLogFile=vmstatLogFile, topLogFile=topLogFile)
10621070
t1 = time.time()
10631071
if printCharts and IndexChart.Gnuplot is not None:

src/python/ps_head.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, top_n, log_file_name, poll_interval_sec=5):
4848

4949
# edit: ok I asked Claude "what is the origin of the odd unix spelling daemon?":
5050

51-
'''
51+
"""
5252
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.
5353
5454
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):
5858
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.
5959
6060
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).
61-
'''
62-
61+
"""
62+
6363
self.thread = threading.Thread(target=self.__run_thread, daemon=True)
6464
self.thread.start()
6565

0 commit comments

Comments
 (0)