Skip to content

Commit afe1178

Browse files
author
Andrija Kolic
committed
Update graalos bench suite to be graalhost compatible: mount extra dirs, don't fail when run from graalos suites, wait for profile files.
1 parent e1a9a41 commit afe1178

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

substratevm/mx.substratevm/mx_substratevm_benchmark.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import re
3232
import json
3333
import datetime
34+
import time
3435
from glob import glob
3536
from pathlib import Path
3637
from typing import List, Optional
@@ -42,7 +43,7 @@
4243
from mx_benchmark import BenchmarkSuite, DataPoints, Rule, Vm, SingleBenchmarkExecutionContext
4344
from mx._impl.mx_codeowners import _load_toml_from_fd
4445
from mx_sdk_benchmark import SUCCESSFUL_STAGE_PATTERNS, parse_prefixed_args
45-
from mx_util import StageName, Layer
46+
from mx_util import Stage, StageName, Layer
4647

4748
_suite = mx.suite("substratevm")
4849

@@ -661,7 +662,13 @@ def _gos_scenarios_dir(self) -> Path:
661662

662663
def _vm_benchmarks_graalos_dir(self) -> Path:
663664
"""Returns the path to the directory containing the applications that comprise the scenarios."""
664-
return Path(mx.primary_suite().vc_dir) / "vm-benchmarks" / "graalos"
665+
vm_enterprise_suite = next(filter(lambda suite: suite.name == "vm-enterprise", mx.suites()), None)
666+
if vm_enterprise_suite is None:
667+
raise ValueError(f"Failed to find the vm-enterprise suite on which {self.__class__.__name__} relies on for locating the graal-enterpise repository!")
668+
vm_benchmarks_graalos_dir = Path(vm_enterprise_suite.vc_dir) / "vm-benchmarks" / "graalos"
669+
if not vm_benchmarks_graalos_dir.is_dir():
670+
raise ValueError(f"Failed to locate the benchmarks directory! No directory exists with path '{vm_benchmarks_graalos_dir}'!")
671+
return vm_benchmarks_graalos_dir
665672

666673
def _app_source_dir(self, app: str) -> Path:
667674
"""Returns the path to the source code directory of the application."""
@@ -891,6 +898,17 @@ def runAndReturnStdOut(self, benchmarks, bmSuiteArgs):
891898
self._ensure_dataplane_scenario_can_run()
892899
return retcode, out, dims
893900

901+
def run_stage(self, vm, stage: Stage, command, out, err, cwd, nonZeroIsFatal):
902+
retcode = super().run_stage(vm, stage, command, out, err, cwd, nonZeroIsFatal)
903+
if stage.stage_name == StageName.INSTRUMENT_RUN:
904+
# GraalOS Load Tester can exit before the app images have shutdown and generated the profile
905+
wait_for = 10
906+
sleep_duration = 0.5
907+
while wait_for >= 0 and not vm.config.profile_path.is_file():
908+
time.sleep(sleep_duration)
909+
wait_for -= sleep_duration
910+
return retcode
911+
894912
def _check_if_dataplane_scenario(self) -> bool:
895913
"""Returns whether the scenario uses 'dataplane' deployment."""
896914
return self._get_scenario_deployment() == "dataplane"
@@ -993,9 +1011,12 @@ def produceHarnessCommand(self, cmd: List[str], suite: BenchmarkSuite) -> List[s
9931011
app_cmd += parse_prefixed_args("-Dnative-image.benchmark.extra-run-arg=", bmSuiteArgs)
9941012

9951013
gos_cmd = [suite._gos_scenario_command(), f"{scenario}", "--local-load-testers", "--skip-upload"]
1014+
output_dir = suite.execution_context.virtual_machine.config.output_dir
1015+
gos_cmd += ["-p", f"extra_graalhost_dir_mounts='{output_dir}'"]
9961016
timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
9971017
gos_log_file_name = f"{timestamp}-gos-out.log"
998-
gos_cmd += ["--log-to", f"stdout,file:{gos_log_file_name}"]
1018+
gos_log_file_path = output_dir / gos_log_file_name
1019+
gos_cmd += ["--log-to", f"stdout,file:{gos_log_file_path}"]
9991020
if suite.execution_context.virtual_machine.graalhost_graalos:
10001021
gos_cmd += ["-p", f"deployment='nginx-tinyinit-graalhost'"]
10011022
app_cmd_str = " ".join(app_cmd)

0 commit comments

Comments
 (0)