Skip to content

Commit

Permalink
Merge branch 'main' into issue31
Browse files Browse the repository at this point in the history
  • Loading branch information
beorn- authored Dec 20, 2024
2 parents 8559885 + 9897e58 commit da0cd4d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
19 changes: 18 additions & 1 deletion graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,24 @@ def generic_graph(
continue
if sensor not in data2_serie:
data2_serie[sensor] = []
data2_serie[sensor].append(measure.get_mean()[sample])
if len(measure.get_mean()) <= sample:
# If the user didn't explictely agreed to be replaced by 0, let's be fatal
if not args.ignore_missing_datapoint:
fatal(
f"{trace.get_name()}/{bench.get_bench_name()}: second axis of {sensor}: {measure.get_full_name()} is missing the {sample+1}th data point.\
Use --ignore-missing-datapoint to ignore this case. Generated graphs will be partially incorrect."
)
else:
# User is fine with a missing data to be replaced.
# Let's do that so we can render things properly.
if args.ignore_missing_datapoint == "last":
# Let's pick the last known value
data2_serie[sensor].append(measure.get_mean()[-1])
else:
# Replace it by a zero
data2_serie[sensor].append(0)
else: # the actual data
data2_serie[sensor].append(measure.get_mean()[sample])
# If we are plotting the power consumption, having the PSUs would be useful to compare with.
if second_axis == Metrics.POWER_CONSUMPTION:
psus = bench.get_psu_power()
Expand Down
30 changes: 23 additions & 7 deletions hwbench/hwbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@


def main():
if not is_root():
h.fatal("hwbench is not running as effective uid 0.")

# Let's ensure no one is running below the expected python release
min_python_release = "3.9"
if Version(platform.python_version()) < Version(min_python_release):
h.fatal(
f"Current python version {platform.python_version()} is below minimal supported release : {min_python_release}"
)

out_dir, tuning_out_dir = create_output_directory()
args = parse_options()
if not is_root():
h.fatal("hwbench is not running as effective uid 0.")

out_dir, tuning_out_dir = create_output_directory(args.output_directory)

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

tuning_setup.Tuning(tuning_out_dir).apply()
tuning_setup.Tuning(tuning_out_dir).apply(args.tuning)
env = env_soft.Environment(out_dir)
hw = env_hw.Hardware(out_dir, args.monitoring_config)

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


def create_output_directory() -> tuple[pathlib.Path, pathlib.Path]:
out_dir = pathlib.Path(f"hwbench-out-{time.strftime('%Y%m%d%H%M%S')}")
def create_output_directory(directory) -> tuple[pathlib.Path, pathlib.Path]:
out_dir = pathlib.Path(directory or f"hwbench-out-{time.strftime('%Y%m%d%H%M%S')}")
if out_dir.exists():
h.fatal(
f"Directory {out_dir} already exists, please give a non-existent directory."
)
out_dir.mkdir()
tuning_out_dir = out_dir / "tuning"
tuning_out_dir.mkdir()
Expand All @@ -69,6 +73,7 @@ def parse_options():
parser = argparse.ArgumentParser(
prog="hwbench",
description="Criteo Hardware Benchmarking tool",
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.",
)
parser.add_argument(
"-j",
Expand All @@ -81,6 +86,17 @@ def parse_options():
"--monitoring-config",
help="Specify the file containing the credentials to monitor the BMC",
)
parser.add_argument(
"-o",
"--output-directory",
help="Specify the directory used to put all results and collected information",
)
parser.add_argument(
"--tuning",
action=argparse.BooleanOptionalAction,
default=True,
help="Enable or disable tuning: this is useful when you want to test the system as-is.",
)
return parser.parse_args()


Expand Down
6 changes: 5 additions & 1 deletion hwbench/tuning/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
from .scheduler import MQDeadlineIOScheduler
from .turbo_boost import IntelTurboBoost, TurboBoost
from ..utils.external import External_Simple
from ..utils.hwlogging import tunninglog


class Tuning:
def __init__(self, out_dir):
self.out_dir = out_dir

def apply(self):
def apply(self, apply_tuning: bool):
if not apply_tuning:
tunninglog().info("Tunning has been disabled on the hwbench command line")
return
External_Simple(self.out_dir, ["sync"])
SysctlDropCaches(self.out_dir).run()
PerformancePowerProfile(self.out_dir).run()
Expand Down

0 comments on commit da0cd4d

Please sign in to comment.