Skip to content

Commit a957995

Browse files
author
Taina Coleman
committed
Fixes mem/cpu run
1 parent 597e7a5 commit a957995

3 files changed

Lines changed: 76 additions & 3 deletions

File tree

wfcommons/wfperf/data_gen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from typing import List, Union
33
import glob
44
import os
5-
import pathlib
6-
import pathlib
5+
76

87

98
def generate_sys_data(num_files: int, file_total_size: int, test_mode: str = "seqwr"):

wfcommons/wfperf/perf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .data_gen import generate_sys_data, cleanup_sys_files
77
import pathlib
88
import json
9-
import numpy as np
109
import subprocess
1110

1211
class WorkflowBenchmark():

wfcommons/wfperf/sys_test.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import pathlib
2+
import argparse
3+
import subprocess
4+
import os
5+
import time
6+
7+
def get_parser() -> argparse.ArgumentParser:
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument("name", help="Task Name")
10+
parser.add_argument("--time", type=int, help="maximum compute time in seconds")
11+
parser.add_argument("--percent-cpu", type=float, help="percent of threads which will be cpu heavy")
12+
parser.add_argument("--save", type=pathlib.Path, help="directory to save to.")
13+
14+
return parser
15+
16+
def main():
17+
parser = get_parser()
18+
args, other = parser.parse_known_args()
19+
name = args.name
20+
save_dir = pathlib.Path(args.save)
21+
22+
23+
24+
# save_dir = [item for item in other if "save" in item][0]
25+
# save_dir = pathlib.Path(save_dir.split("=")[1])
26+
27+
28+
with save_dir.joinpath(f"{name}_cpu.txt").open("w+") as fp_cpu, save_dir.joinpath(f"{name}_memory.txt").open("w+") as fp_mem, save_dir.joinpath(f"{name}_ps.txt").open("w+") as fp_ps:
29+
num_cores = 1 #os.cpu_count()
30+
cpu_threads = 1 #int(args.percent_cpu*10)
31+
mem_threads = 1 #int(10 - cpu_threads)
32+
33+
34+
print("Starting CPU benchmark...")
35+
sysbench_cpu_args = [arg for arg in other if arg.startswith("--cpu")] + [f"--threads={cpu_threads}"]
36+
37+
for i in range(num_cores):
38+
39+
proc_cpu = subprocess.Popen(
40+
[
41+
"sysbench", "cpu",
42+
*sysbench_cpu_args, "run"
43+
],
44+
stdout=fp_cpu, stderr=fp_cpu,
45+
)
46+
47+
pid_1 = proc_cpu.pid
48+
print(pid_1)
49+
os.sched_setaffinity(pid_1, {i})
50+
51+
52+
print("Starting Memory benchmark...")
53+
sysbench_mem_args = [arg for arg in other if arg.startswith("--memory")] + [f"--time={args.time}", f"--threads={mem_threads}"]
54+
proc_mem = subprocess.Popen(
55+
[
56+
"sysbench", "memory","run",
57+
*sysbench_mem_args
58+
],
59+
stdout=fp_mem, stderr=fp_mem
60+
)
61+
62+
pid_2 = proc_mem.pid
63+
print(pid_2)
64+
os.sched_setaffinity(pid_2, {i})
65+
66+
proc = subprocess.Popen(["ps", "-o","pid,psr,comm,lstart"], stdout=fp_ps)
67+
proc.wait()
68+
proc_cpu.wait()
69+
print(time.time)
70+
subprocess.Popen(["killall", "sysbench"])
71+
72+
73+
74+
if __name__ == "__main__":
75+
main()

0 commit comments

Comments
 (0)