Skip to content

Commit da0cd4d

Browse files
authored
Merge branch 'main' into issue31
2 parents 8559885 + 9897e58 commit da0cd4d

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

graph/graph.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,24 @@ def generic_graph(
298298
continue
299299
if sensor not in data2_serie:
300300
data2_serie[sensor] = []
301-
data2_serie[sensor].append(measure.get_mean()[sample])
301+
if len(measure.get_mean()) <= sample:
302+
# If the user didn't explictely agreed to be replaced by 0, let's be fatal
303+
if not args.ignore_missing_datapoint:
304+
fatal(
305+
f"{trace.get_name()}/{bench.get_bench_name()}: second axis of {sensor}: {measure.get_full_name()} is missing the {sample+1}th data point.\
306+
Use --ignore-missing-datapoint to ignore this case. Generated graphs will be partially incorrect."
307+
)
308+
else:
309+
# User is fine with a missing data to be replaced.
310+
# Let's do that so we can render things properly.
311+
if args.ignore_missing_datapoint == "last":
312+
# Let's pick the last known value
313+
data2_serie[sensor].append(measure.get_mean()[-1])
314+
else:
315+
# Replace it by a zero
316+
data2_serie[sensor].append(0)
317+
else: # the actual data
318+
data2_serie[sensor].append(measure.get_mean()[sample])
302319
# If we are plotting the power consumption, having the PSUs would be useful to compare with.
303320
if second_axis == Metrics.POWER_CONSUMPTION:
304321
psus = bench.get_psu_power()

hwbench/hwbench.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@
2020

2121

2222
def main():
23-
if not is_root():
24-
h.fatal("hwbench is not running as effective uid 0.")
25-
2623
# Let's ensure no one is running below the expected python release
2724
min_python_release = "3.9"
2825
if Version(platform.python_version()) < Version(min_python_release):
2926
h.fatal(
3027
f"Current python version {platform.python_version()} is below minimal supported release : {min_python_release}"
3128
)
3229

33-
out_dir, tuning_out_dir = create_output_directory()
3430
args = parse_options()
31+
if not is_root():
32+
h.fatal("hwbench is not running as effective uid 0.")
33+
34+
out_dir, tuning_out_dir = create_output_directory(args.output_directory)
3535

3636
# configure logging
3737
init_logging(tuning_out_dir / "hwbench-tuning.log")
3838

39-
tuning_setup.Tuning(tuning_out_dir).apply()
39+
tuning_setup.Tuning(tuning_out_dir).apply(args.tuning)
4040
env = env_soft.Environment(out_dir)
4141
hw = env_hw.Hardware(out_dir, args.monitoring_config)
4242

@@ -56,8 +56,12 @@ def is_root():
5656
return os.geteuid() == 0
5757

5858

59-
def create_output_directory() -> tuple[pathlib.Path, pathlib.Path]:
60-
out_dir = pathlib.Path(f"hwbench-out-{time.strftime('%Y%m%d%H%M%S')}")
59+
def create_output_directory(directory) -> tuple[pathlib.Path, pathlib.Path]:
60+
out_dir = pathlib.Path(directory or f"hwbench-out-{time.strftime('%Y%m%d%H%M%S')}")
61+
if out_dir.exists():
62+
h.fatal(
63+
f"Directory {out_dir} already exists, please give a non-existent directory."
64+
)
6165
out_dir.mkdir()
6266
tuning_out_dir = out_dir / "tuning"
6367
tuning_out_dir.mkdir()
@@ -69,6 +73,7 @@ def parse_options():
6973
parser = argparse.ArgumentParser(
7074
prog="hwbench",
7175
description="Criteo Hardware Benchmarking tool",
76+
epilog="Note that hwbench needs to run as root, for many reasons: system-wide tuning, local IPMI link to the BMC, x86 performance with turbostat, devices access with fio, etc.",
7277
)
7378
parser.add_argument(
7479
"-j",
@@ -81,6 +86,17 @@ def parse_options():
8186
"--monitoring-config",
8287
help="Specify the file containing the credentials to monitor the BMC",
8388
)
89+
parser.add_argument(
90+
"-o",
91+
"--output-directory",
92+
help="Specify the directory used to put all results and collected information",
93+
)
94+
parser.add_argument(
95+
"--tuning",
96+
action=argparse.BooleanOptionalAction,
97+
default=True,
98+
help="Enable or disable tuning: this is useful when you want to test the system as-is.",
99+
)
84100
return parser.parse_args()
85101

86102

hwbench/tuning/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
from .scheduler import MQDeadlineIOScheduler
44
from .turbo_boost import IntelTurboBoost, TurboBoost
55
from ..utils.external import External_Simple
6+
from ..utils.hwlogging import tunninglog
67

78

89
class Tuning:
910
def __init__(self, out_dir):
1011
self.out_dir = out_dir
1112

12-
def apply(self):
13+
def apply(self, apply_tuning: bool):
14+
if not apply_tuning:
15+
tunninglog().info("Tunning has been disabled on the hwbench command line")
16+
return
1317
External_Simple(self.out_dir, ["sync"])
1418
SysctlDropCaches(self.out_dir).run()
1519
PerformancePowerProfile(self.out_dir).run()

0 commit comments

Comments
 (0)