Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hwbench/bench/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def __init__(self, engine_module: EngineModuleBase, parameters: BenchmarkParamet
self.engine_module = engine_module
self.skip = False

@property
def output_basename(self) -> str:
# Prefix the output files with the per-benchmark id used as the
# results.json key (get_name_with_position()). A single job expands via
# the scaling matrix (hosting_cpu_cores_scaling / stressor_range) into
# many runs that share the same engine `name`; without this prefix they
# all write into the same out_dir under the same filenames and only the
# last iteration survives.
return f"{self.parameters.get_name_with_position()}_{self.name}"
Comment thread
anisse marked this conversation as resolved.

def get_taskset(self, args):
# Let's pin the CPU if needed
if self.parameters.get_pinned_cpu():
Expand Down
5 changes: 3 additions & 2 deletions hwbench/bench/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
class Benchmarks:
"""A class to list and execute benchmarks to run."""

def __init__(self, out_dir, jobs_config) -> None:
def __init__(self, out_dir, jobs_config, verbose: bool = False) -> None:
self.jobs_config = jobs_config
self.out_dir = out_dir
self.verbose = verbose
self.benchs: list[Benchmark] = []
self.monitoring: Monitoring = None # type: ignore[assignment]
self.hardware: BaseHardware | None = None
Expand Down Expand Up @@ -175,7 +176,7 @@ def __schedule_benchmark(self, job, pinned_cpu, engine_module_parameter, validat
for pdu in self.get_hardware().vendor.get_pdus():
pdu.connect_redfish()
pdu.detect()
self.monitoring = Monitoring(self.out_dir, self.jobs_config, self.get_hardware())
self.monitoring = Monitoring(self.out_dir, self.jobs_config, self.get_hardware(), verbose=self.verbose)

# For each stressor, add a benchmark object to the list
for stressor_count in self.jobs_config.get_stressor_range(job):
Expand Down
9 changes: 6 additions & 3 deletions hwbench/bench/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def join(self):
class Monitoring:
"""A class to perform monitoring."""

def __init__(self, out_dir, config, hardware: BaseHardware):
def __init__(self, out_dir, config, hardware: BaseHardware, verbose: bool = False):
self.config = config
self.out_dir = out_dir
self.verbose = verbose
self.hardware = hardware
self.vendor = hardware.get_vendor()
self.metrics = MonitoringData()
Expand Down Expand Up @@ -114,7 +115,8 @@ def preup(self, precision_s: int):
if self.turbostat:
# Reinitialize turbostat metrics after reset (fast, doesn't run turbostat)
self.turbostat.reinitialize_metrics()
print("Monitoring/turbostat: starting background monitoring with EOL-triggered sampling")
if self.verbose:
print("Monitoring/turbostat: starting background monitoring with EOL-triggered sampling")
self.turbostat.start_background()

def predown(self):
Expand All @@ -124,7 +126,8 @@ def predown(self):
the background turbostat process.
"""
if self.turbostat:
print("Monitoring/turbostat: stopping background monitoring")
if self.verbose:
print("Monitoring/turbostat: stopping background monitoring")
self.turbostat.stop_background()

def __monitor_bmc(self):
Expand Down
9 changes: 9 additions & 0 deletions hwbench/bench/parameters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from __future__ import annotations

import pathlib
from typing import TYPE_CHECKING

from hwbench.environment.hardware import BaseHardware

from .monitoring import Monitoring

if TYPE_CHECKING:
from .benchmark import Benchmark

Comment thread
anisse marked this conversation as resolved.

class BenchmarkParameters:
"""A class to host parameters attached to a benchmark."""
Expand Down Expand Up @@ -38,6 +44,9 @@ def __init__(
self.skip_method = skip_method
self.sync_start = sync_start
self.custom_parameters: dict[str, str] = kwargs
# Set once the owning Benchmark is built (see set_benchmark); until then
# get_name_with_position() falls back to the bare job name.
self.benchmark: Benchmark | None = None
Comment thread
Keruspe marked this conversation as resolved.

def get_benchmark(self):
return self.benchmark
Expand Down
2 changes: 2 additions & 0 deletions hwbench/engines/stressng.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def run_cmd(self) -> list[str]:
"--timeout",
str(self.parameters.get_runtime()),
"--metrics",
"--yaml",
f"{self.output_basename}.yaml",
]

return self.get_taskset(args)
Expand Down
2 changes: 2 additions & 0 deletions hwbench/engines/stressng_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def run_cmd(self) -> list[str]:
"--timeout",
str(self.parameters.get_runtime()),
"--metrics",
"--yaml",
f"{self.name}.yaml",
Comment thread
anisse marked this conversation as resolved.
"--stream",
str(self.parameters.get_engine_instances_count()),
]
Expand Down
9 changes: 8 additions & 1 deletion hwbench/hwbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
init_logging(tuning_out_dir / "hwbench-tuning.log")

hwbench_config = config.Config(args.jobs_config)
benches = benchmarks.Benchmarks(out_dir, hwbench_config)
benches = benchmarks.Benchmarks(out_dir, hwbench_config, verbose=args.verbose)

problems = env_hw.check_requirements() + benches.check_requirements()

Expand Down Expand Up @@ -109,6 +109,13 @@ def parse_options():
default=True,
help="Enable or disable tuning: this is useful when you want to test the system as-is.",
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Enable verbose output",
)
return parser.parse_args()


Expand Down
5 changes: 5 additions & 0 deletions hwbench/tests/parsing/stressng/v02103b/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"bogo ops/s": 217929.51,
"effective_runtime": 14.95
}

Empty file.
11 changes: 11 additions & 0 deletions hwbench/tests/parsing/stressng/v02103b/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
stress-ng: info: [205686] setting to a 15 secs run per stressor
stress-ng: info: [205686] dispatching hogs: 640 cpu
stress-ng: info: [205686] note: boost is disabled and this may impact top performance; setting /sys/devices/system/cpu/cpufreq/boost to 1 may improve performance.
stress-ng: metrc: [205686] stressor bogo ops real time usr time sys time bogo ops/s bogo ops/s CPU used per RSS Max
stress-ng: metrc: [205686] (secs) (secs) (secs) (real time) (usr+sys time) instance (%) (KB)
stress-ng: metrc: [205686] cpu 3257280 14.95 9544.59 0.38 217929.51 341.26 99.78 0
stress-ng: info: [205686] skipped: 0
stress-ng: info: [205686] passed: 640: cpu (640)
stress-ng: info: [205686] failed: 0
stress-ng: info: [205686] metrics untrustworthy: 0
stress-ng: info: [205686] successful run completed in 15.02 secs
Loading
Loading