Skip to content

Commit b1ffedb

Browse files
author
Andrija Kolic
committed
[GR-65510] Set '--cmd-app-prefix-init-sleep' option in the Barista bench suite when registering 'energy' tracker
PullRequest: graal/21220
2 parents 2ec37d4 + 32c23a8 commit b1ffedb

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

compiler/ci/ci_common/benchmark-suites.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129

130130
barista_template(suite_version=null, suite_name="barista", max_jdk_version=null, cmd_app_prefix=["hwloc-bind --cpubind node:0.core:0-3.pu:0 --membind node:0"], non_prefix_barista_args=[]):: cc.compiler_benchmark + {
131131
suite:: suite_name,
132-
local barista_version = "v0.4.4",
132+
local barista_version = "v0.4.5",
133133
local suite_version_args = if suite_version != null then ["--bench-suite-version=" + suite_version] else [],
134134
local prefix_barista_arg = if std.length(cmd_app_prefix) > 0 then [std.format("--cmd-app-prefix=%s", std.join(" ", cmd_app_prefix))] else [],
135135
local all_barista_args = prefix_barista_arg + non_prefix_barista_args,

sdk/mx.sdk/mx_sdk_benchmark.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,7 +2815,7 @@ def rules(self, out, benchmarks, bmSuiteArgs):
28152815
# Should currently only contain round numbers due to the field incorrectly being indexed as integer in the DB (GR-57487)
28162816
"latency_percentiles": [50.0, 75.0, 90.0, 99.0, 100.0],
28172817
"rss_percentiles": [100, 99, 98, 97, 96, 95, 90, 75, 50, 25],
2818-
"disable_trackers": [mx_benchmark.RssTracker, mx_benchmark.PsrecordTracker, mx_benchmark.PsrecordMaxrssTracker, mx_benchmark.RssPercentilesTracker, mx_benchmark.RssPercentilesAndMaxTracker],
2818+
"supported_trackers": [mx_benchmark.EnergyConsumptionTracker],
28192819
}
28202820

28212821
class BaristaBenchmarkSuite(mx_benchmark.CustomHarnessBenchmarkSuite):
@@ -2828,9 +2828,8 @@ class BaristaBenchmarkSuite(mx_benchmark.CustomHarnessBenchmarkSuite):
28282828
def __init__(self, custom_harness_command: mx_benchmark.CustomHarnessCommand = None):
28292829
if custom_harness_command is None:
28302830
custom_harness_command = BaristaBenchmarkSuite.BaristaCommand()
2831-
super().__init__(custom_harness_command)
2831+
super().__init__(custom_harness_command, supported_trackers=_baristaConfig["supported_trackers"])
28322832
self._version = None
2833-
self._extra_run_options = []
28342833

28352834
def readBaristaVersionFromPyproject(self):
28362835
# tomllib was included in python standard library with version 3.11
@@ -2916,25 +2915,6 @@ def validateEnvironment(self):
29162915
def new_execution_context(self, vm: Vm, benchmarks: List[str], bmSuiteArgs: List[str]) -> SingleBenchmarkExecutionContext:
29172916
return SingleBenchmarkExecutionContext(self, vm, benchmarks, bmSuiteArgs)
29182917

2919-
def register_tracker(self, name, tracker_type):
2920-
if tracker_type in _baristaConfig["disable_trackers"]:
2921-
mx.log(f"Ignoring the registration of '{name}' tracker as it was disabled for {self.__class__.__name__}.")
2922-
return
2923-
if name == "energy":
2924-
if self.version() < "0.4.1":
2925-
mx.abort(
2926-
"The 'energy' tracker is not supported for barista benchmarks before Barista version '0.4.1'."
2927-
" Please update your Barista repository in order to use the 'energy' tracker! Aborting!"
2928-
)
2929-
# Allow for the baseline measurement before looking up the app process
2930-
self._extra_run_options += ["--cmd-app-prefix-init-timelimit", f"{tracker_type(self).baseline_duration + 5}"]
2931-
# Ensure that the workload is independent from the performance of the VM
2932-
# We want to track the energy needed for a set amount of work
2933-
self._extra_run_options += ["--startup-iteration-count", "0"]
2934-
self._extra_run_options += ["--warmup-iteration-count", "0"]
2935-
self._extra_run_options += ["--throughput-iteration-count", "0"]
2936-
super().register_tracker(name, tracker_type)
2937-
29382918
def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
29392919
# Pass the VM options, BaristaCommand will form the final command.
29402920
return self.vmArgs(bmSuiteArgs)
@@ -3149,6 +3129,29 @@ def _updateCommandOption(self, cmd, option_name, option_short_name, new_value):
31493129
new_value = f"{new_value} {existing_option_match.group(1)}"
31503130
cmd.append(f"{option_name}={new_value}")
31513131

3132+
def _energyTrackerExtraOptions(self, suite: BaristaBenchmarkSuite):
3133+
"""Returns extra options necessary for correct benchmark results when using the 'energy' tracker."""
3134+
if not isinstance(suite._tracker, mx_benchmark.EnergyConsumptionTracker):
3135+
return []
3136+
3137+
required_barista_version = "0.4.5"
3138+
if mx.VersionSpec(suite.version()) < mx.VersionSpec(required_barista_version):
3139+
mx.abort(
3140+
f"The 'energy' tracker is not supported for barista benchmarks before Barista version '{required_barista_version}'."
3141+
" Please update your Barista repository in order to use the 'energy' tracker! Aborting!"
3142+
)
3143+
3144+
extra_options = []
3145+
# If baseline has to be measured, wait for the measurement duration before looking up the app process
3146+
if suite._tracker.baseline_power is None:
3147+
extra_options += ["--cmd-app-prefix-init-sleep", f"{suite._tracker.baseline_duration}"]
3148+
# Ensure that the workload is independent from the performance of the VM
3149+
# We want to track the energy needed for a set amount of work
3150+
extra_options += ["--startup-iteration-count", "0"]
3151+
extra_options += ["--warmup-iteration-count", "0"]
3152+
extra_options += ["--throughput-iteration-count", "0"]
3153+
return extra_options
3154+
31523155
def produceHarnessCommand(self, cmd, suite):
31533156
"""Maps a JVM command into a command tailored for the Barista harness.
31543157
@@ -3173,7 +3176,7 @@ def produceHarnessCommand(self, cmd, suite):
31733176
jvm_vm_options = jvm_cmd[index_of_java_exe + 1:]
31743177

31753178
# Verify that the run arguments don't already contain a "--mode" option
3176-
run_args = suite.runArgs(suite.execution_context.bmSuiteArgs) + suite._extra_run_options
3179+
run_args = suite.runArgs(suite.execution_context.bmSuiteArgs) + self._energyTrackerExtraOptions(suite)
31773180
mode_pattern = r"^(?:-m|--mode)(=.*)?$"
31783181
mode_match = self._regexFindInCommand(run_args, mode_pattern)
31793182
if mode_match:

substratevm/mx.substratevm/mx_substratevm_benchmark.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def produceHarnessCommand(self, cmd, suite):
466466
# Make agent run short
467467
cmd += self._short_load_testing_phases()
468468
# Add explicit agent stage args
469-
cmd += suite._extra_run_options
469+
cmd += self._energyTrackerExtraOptions(suite)
470470
cmd += parse_prefixed_args("-Dnative-image.benchmark.extra-jvm-arg=", suite.execution_context.bmSuiteArgs)
471471
cmd += parse_prefixed_args("-Dnative-image.benchmark.extra-agent-run-arg=", suite.execution_context.bmSuiteArgs)
472472
return cmd
@@ -489,7 +489,7 @@ def produceHarnessCommand(self, cmd, suite):
489489
ni_barista_cmd = [suite.baristaHarnessPath(), "--mode", "native", "--app-executable", app_image]
490490
if barista_workload is not None:
491491
ni_barista_cmd.append(f"--config={barista_workload}")
492-
ni_barista_cmd += suite.runArgs(suite.execution_context.bmSuiteArgs) + suite._extra_run_options
492+
ni_barista_cmd += suite.runArgs(suite.execution_context.bmSuiteArgs) + self._energyTrackerExtraOptions(suite)
493493
ni_barista_cmd += parse_prefixed_args("-Dnative-image.benchmark.extra-jvm-arg=", suite.execution_context.bmSuiteArgs)
494494
if stage.is_instrument():
495495
# Make instrument run short
@@ -734,9 +734,6 @@ def new_execution_context(self, vm: Vm, benchmarks: List[str], bmSuiteArgs: List
734734
def default_stages(self) -> List[str]:
735735
return ["instrument-image", "instrument-run", "image", "run"]
736736

737-
def register_tracker(self, name, tracker_type):
738-
mx.log(f"Ignoring the registration of '{name}' tracker as it was disabled for {self.__class__.__name__}.")
739-
740737
def all_command_line_args_are_vm_args(self):
741738
return True
742739

0 commit comments

Comments
 (0)