Skip to content

Commit 7885d47

Browse files
committed
Add grid2
1 parent ea057f9 commit 7885d47

4 files changed

Lines changed: 191 additions & 3 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ sftp-config.json
2222
.lint-logs/
2323
# Python wheels
2424
*.whl
25+
26+
27+
28+
aggregated_results.csv
29+
grid_search/aggregated_results_conf_1.csv
30+
grid_search/grid_tasks
31+
grid_search/grid_tasks_conf2

grid_search/conf_2.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"ghost_to_main_thresh": {
3+
"0": "Hit & Promote"
4+
},
5+
"small_skip_ratio": {
6+
"0.0": "Off",
7+
"0.1": "Light Filter",
8+
"0.25": "Anti-Scan"
9+
},
10+
"ghost_size_ratio": {
11+
"3": "Fixed. Maximize history info.",
12+
"6": "Large. Maximize history info."
13+
},
14+
"small_size_ratio": {
15+
"0.01": "Extra Small",
16+
"0.05": "Static/Stable",
17+
"0.1": "Default",
18+
"0.2": "Dynamic/Churn"
19+
},
20+
"move_to_main_thresh": {
21+
"1": "Recency-friendly",
22+
"2": "Balanced",
23+
"4": "Scan-resistant"
24+
}
25+
}

grid_search/yield_tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
cachesim_path = "/mnt/cfs/_libCacheSim/_build/bin/cachesim"
88
trace_list_path = "/mnt/cfs/_libCacheSim/grid_search/trace_lists.txt"
9-
grid_config_path = "/mnt/cfs/_libCacheSim/grid_search/conf_1.json"
9+
grid_config_path = "/mnt/cfs/_libCacheSim/grid_search/conf_2.json"
1010

1111
with open(trace_list_path, 'r') as f:
1212
data_path_list = f.readlines()
@@ -26,7 +26,7 @@
2626
move_to_main_thresholds = [int(k) for k in grid_config.get("move_to_main_thresh", {}).keys()]
2727

2828
# Define cache size ratios (not in config file)
29-
cache_size_ratios = [0.001, 0.003, 0.01, 0.03, 0.1, 0.3]
29+
cache_size_ratios = [0.001, 0.01, 0.1]
3030

3131
# Generate all combinations
3232
for cache_size_ratio in cache_size_ratios:
@@ -36,4 +36,4 @@
3636
for move_to_main_threshold in move_to_main_thresholds:
3737
for ghost_to_main_threshold in ghost_to_main_thresholds:
3838
for small_skip_ratio in small_skip_ratios:
39-
print(f'shell:1:1:1:{cachesim_path} {trace_file} oracleGeneral s4fifo {str(cache_size_ratio)} -e "small-size-ratio={str(small_size_ratio)},ghost-size-ratio={str(ghost_size_ratio)},move-to-main-threshold={str(move_to_main_threshold)},ghost-to-main-threshold={str(ghost_to_main_threshold)},small-skip-ratio={str(small_skip_ratio)}" --ignore-obj-size 1 > /mnt/cfs/results/s4fifo_{os.path.basename(trace_file)}_c{str(cache_size_ratio)}_s{str(small_size_ratio)}_g{str(ghost_size_ratio)}_m{str(move_to_main_threshold)}_t{str(ghost_to_main_threshold)}_k{str(small_skip_ratio)}.log')
39+
print(f'shell:1:1:1:{cachesim_path} {trace_file} oracleGeneral s4fifo {str(cache_size_ratio)} -e "small-size-ratio={str(small_size_ratio)},ghost-size-ratio={str(ghost_size_ratio)},move-to-main-threshold={str(move_to_main_threshold)},ghost-to-main-threshold={str(ghost_to_main_threshold)},small-skip-ratio={str(small_skip_ratio)}" --ignore-obj-size 1 -o dummy > /mnt/cfs/results/s4fifo_{os.path.basename(trace_file)}_c{str(cache_size_ratio)}_s{str(small_size_ratio)}_g{str(ghost_size_ratio)}_m{str(move_to_main_threshold)}_t{str(ghost_to_main_threshold)}_k{str(small_skip_ratio)}.log')

scripts/aggregate_results.py

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Aggregate results from /mnt/cfs/results directory.
4+
Each log file contains one line with format:
5+
<trace> <algorithm> cache size <size>, <num_req> req, miss ratio <miss_ratio>, throughput <throughput> MQPS
6+
"""
7+
8+
import os
9+
import re
10+
import csv
11+
from pathlib import Path
12+
from collections import defaultdict
13+
import argparse
14+
15+
16+
def parse_log_file(filepath):
17+
"""Parse a single log file and extract information."""
18+
try:
19+
with open(filepath, 'r') as f:
20+
line = f.read().strip()
21+
22+
if not line:
23+
return None
24+
25+
# Parse the log line
26+
# Example: /mnt/cfs/oracleReuse/systor/2016_LUN0.oracleGeneral.zst S4FIFO-0.0500-1 cache size 64548, 552023811 req, miss ratio 0.7538, throughput 1.55 MQPS
27+
28+
# Extract trace path
29+
parts = line.split()
30+
if len(parts) < 10:
31+
return None
32+
33+
trace = parts[0]
34+
algorithm = parts[1]
35+
36+
# Extract cache size
37+
cache_size_match = re.search(r'cache size\s+(\d+)', line)
38+
cache_size = int(cache_size_match.group(1)) if cache_size_match else None
39+
40+
# Extract number of requests
41+
req_match = re.search(r'(\d+)\s+req', line)
42+
num_req = int(req_match.group(1)) if req_match else None
43+
44+
# Extract miss ratio
45+
miss_ratio_match = re.search(r'miss ratio\s+([\d.]+)', line)
46+
miss_ratio = float(miss_ratio_match.group(1)) if miss_ratio_match else None
47+
48+
# Extract throughput
49+
throughput_match = re.search(r'throughput\s+([\d.]+)\s+MQPS', line)
50+
throughput = float(throughput_match.group(1)) if throughput_match else None
51+
52+
# Parse filename to extract parameters
53+
filename = os.path.basename(filepath)
54+
# Example: s4fifo_2016_LUN0.oracleGeneral.zst_c0.001_s0.05_g0.9_m1_t0_k0.0.log
55+
param_match = re.search(r'_c([\d.]+)_s([\d.]+)_g([\d.]+)_m(\d+)_t(\d+)_k([\d.]+)\.log$', filename)
56+
57+
if param_match:
58+
c_param = float(param_match.group(1))
59+
s_param = float(param_match.group(2))
60+
g_param = float(param_match.group(3))
61+
m_param = int(param_match.group(4))
62+
t_param = int(param_match.group(5))
63+
k_param = float(param_match.group(6))
64+
else:
65+
c_param = s_param = g_param = m_param = t_param = k_param = None
66+
67+
return {
68+
'filename': filename,
69+
'trace': trace,
70+
'algorithm': algorithm,
71+
'cache_size': cache_size,
72+
'num_req': num_req,
73+
'miss_ratio': miss_ratio,
74+
'throughput': throughput,
75+
'c_param': c_param,
76+
's_param': s_param,
77+
'g_param': g_param,
78+
'm_param': m_param,
79+
't_param': t_param,
80+
'k_param': k_param,
81+
}
82+
83+
except Exception as e:
84+
print(f"Error parsing {filepath}: {e}")
85+
return None
86+
87+
88+
def aggregate_results(results_dir, output_file):
89+
"""Aggregate all results from the directory."""
90+
results = []
91+
92+
results_path = Path(results_dir)
93+
log_files = list(results_path.glob('*.log'))
94+
95+
print(f"Found {len(log_files)} log files")
96+
97+
total = len(log_files)
98+
processed = 0
99+
100+
for log_file in log_files:
101+
data = parse_log_file(log_file)
102+
if data:
103+
results.append(data)
104+
105+
processed += 1
106+
if processed % 10000 == 0:
107+
print(f"Processed {processed}/{total} files ({100*processed/total:.1f}%)")
108+
109+
print(f"Successfully parsed {len(results)} files")
110+
111+
# Write to CSV
112+
if results:
113+
fieldnames = [
114+
'filename', 'trace', 'algorithm', 'cache_size', 'num_req',
115+
'miss_ratio', 'throughput', 'c_param', 's_param', 'g_param',
116+
'm_param', 't_param', 'k_param'
117+
]
118+
119+
with open(output_file, 'w', newline='') as f:
120+
writer = csv.DictWriter(f, fieldnames=fieldnames)
121+
writer.writeheader()
122+
writer.writerows(results)
123+
124+
print(f"Results written to {output_file}")
125+
126+
# Print summary statistics
127+
print("\n=== Summary Statistics ===")
128+
print(f"Total results: {len(results)}")
129+
130+
traces = set(r['trace'] for r in results)
131+
print(f"Unique traces: {len(traces)}")
132+
133+
algorithms = set(r['algorithm'] for r in results)
134+
print(f"Unique algorithms: {len(algorithms)}")
135+
136+
if results[0]['miss_ratio'] is not None:
137+
miss_ratios = [r['miss_ratio'] for r in results if r['miss_ratio'] is not None]
138+
if miss_ratios:
139+
print(f"Miss ratio range: {min(miss_ratios):.4f} - {max(miss_ratios):.4f}")
140+
print(f"Average miss ratio: {sum(miss_ratios)/len(miss_ratios):.4f}")
141+
142+
143+
def main():
144+
parser = argparse.ArgumentParser(description='Aggregate S4FIFO experiment results')
145+
parser.add_argument('--results-dir', default='/mnt/cfs/results',
146+
help='Directory containing result log files')
147+
parser.add_argument('--output', default='aggregated_results.csv',
148+
help='Output CSV file')
149+
150+
args = parser.parse_args()
151+
152+
aggregate_results(args.results_dir, args.output)
153+
154+
155+
if __name__ == '__main__':
156+
main()

0 commit comments

Comments
 (0)