From f1c089fe811e7beb994fbfa9bee50203fc0d5c4e Mon Sep 17 00:00:00 2001 From: Zixian Cai Date: Thu, 23 May 2024 13:21:07 +1000 Subject: [PATCH] Allow runbms skipping emitting heapsize modifiers for some configs --- docs/src/changelog.md | 2 + docs/src/references/modifier.md | 11 +++ src/running/command/runbms.py | 70 ++++++++++++++------ src/running/config/runbms_example.yml | 39 +++-------- src/running/config/runbms_example_probes.yml | 38 +++++++++++ src/running/modifier.py | 9 +++ src/running/util.py | 10 +++ tests/test_modifier.py | 21 ++++++ 8 files changed, 151 insertions(+), 49 deletions(-) create mode 100644 src/running/config/runbms_example_probes.yml diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 6ac53e0..a3d19e6 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -1,6 +1,8 @@ # Changelog ## Unreleased ### Added +#### Modifiers +- `NoImplicitHeapsizeModifier` ### Changed diff --git a/docs/src/references/modifier.md b/docs/src/references/modifier.md index e5d3309..cde3601 100644 --- a/docs/src/references/modifier.md +++ b/docs/src/references/modifier.md @@ -96,3 +96,14 @@ If a companion program also exist for the benchmark suite you use, this companio `val`: a single string with [shell-like syntax](https://docs.python.org/3/library/shlex.html#shlex.split). Multiple arguments are space separated. Environment variables will be expanded. + +## `NoImplicitHeapsizeModifier` (preview ⚠️) +`runbms` specific. + +### Description +Normally `runbms` will iterate through a set of heap sizes, either specific multiples of the minheap of each benchmark via `-s`, or spreading the multiples across 1~`heap_range` (using `N` and optionally `ns`). + +This modifier prevents `runbms` from applying the heap sizes for certain configs, which is useful, for example, for running `NoGC` or `EpsilonGC`. + +### Keys +No argument is allowed. diff --git a/src/running/command/runbms.py b/src/running/command/runbms.py index 4ee664a..2ffc095 100644 --- a/src/running/command/runbms.py +++ b/src/running/command/runbms.py @@ -20,6 +20,7 @@ get_logged_in_users, config_index_to_chr, config_str_encode, + dont_emit_heapsize_modifier, ) import socket from datetime import datetime @@ -453,6 +454,42 @@ def run(args): p.set_runbms_dir(runbms_dir) p.set_log_dir(log_dir) + configs_no_heapsize = [ + c for c in configs if dont_emit_heapsize_modifier(configuration, c) + ] + configs_with_heapsize = [ + c for c in configs if not dont_emit_heapsize_modifier(configuration, c) + ] + + # Simple case + if not slice and N is None: + # run all configs without specifying heap size + run_one_hfac( + invocations, + None, # not specifying heap size + suites, + benchmarks, + configs, + Path(runbms_dir), + log_dir, + ) + # early return + return True + + # In all other cases, we will first run configs that don't want + # implicit + logging.info("Running all configs with NoImplicitHeapSizeModifier set") + run_one_hfac( + invocations, + None, # not specifying heap size + suites, + benchmarks, + configs_no_heapsize, + Path(runbms_dir), + log_dir, + ) + + # Helper function for running benchmarks using multiple heap factors def run_hfacs(hfacs): logging.info( "hfacs: {}".format(", ".join([hfac_str(hfac) for hfac in hfacs])) @@ -463,35 +500,30 @@ def run_hfacs(hfacs): hfac, suites, benchmarks, - configs, + configs_with_heapsize, Path(runbms_dir), log_dir, ) print() + # Helper function for using the heap factor spreading algorithm def run_N_ns(N, ns): hfacs = get_hfacs(heap_range, spread_factor, N, ns) run_hfacs(hfacs) - if slice: + if slice: # specified -s, we respect that first + if N is not None: + logging.warning( + "You specified both N={} and -s {}, N is ignored.", + N, + ",".join([str(s) for s in slice]), + ) run_hfacs(slice) - return True - - if N is None: - run_one_hfac( - invocations, - None, - suites, - benchmarks, - configs, - Path(runbms_dir), - log_dir, - ) - return True - - if len(ns) == 0: - fillin(run_N_ns, round(math.log2(N))) else: - run_N_ns(N, ns) + assert N is not None + if len(ns) == 0: + fillin(run_N_ns, round(math.log2(N))) + else: + run_N_ns(N, ns) return True diff --git a/src/running/config/runbms_example.yml b/src/running/config/runbms_example.yml index 7eb9183..9826fe4 100644 --- a/src/running/config/runbms_example.yml +++ b/src/running/config/runbms_example.yml @@ -1,38 +1,17 @@ includes: - "$RUNNING_NG_PACKAGE_DATA/base/runbms.yml" -overrides: - "suites.dacapo2006.timing_iteration": 5 - "suites.dacapobach.timing_iteration": 5 - "suites.dacapo2006.callback": "probe.Dacapo2006Callback" - "suites.dacapobach.callback": "probe.DacapoBachCallback" +benchmarks: + dacapochopin: + - fop modifiers: - probes_cp: - type: JVMClasspath - val: "/home/zixianc/MMTk-Dev/evaluation/probes /home/zixianc/MMTk-Dev/evaluation/probes/probes.jar" - probes_native: + heap4g: type: JVMArg - val: "-Djava.library.path=/home/zixianc/MMTk-Dev/evaluation/probes" - probes_rustmmtk: - type: JVMArg - val: "-Dprobes=RustMMTk" - value_opts_example: - type: EnvVar - var: "FOOBAR{0}" - val: "BUZZ{1}" - -runtimes: - jdk-mmtk: - type: OpenJDK - release: 11 - home: "/home/zixianc/MMTk-Dev/evaluation/build/jdk-mmtk/jdk" - -benchmarks: - dacapo2006: - - eclipse - dacapobach: - - fop + val: -Xms4G -Xmx4G + no_heapsize: + type: NoImplicitHeapsizeModifier configs: - - "jdk-mmtk|ms|s|c2|ss|tph|probes_cp|probes_rustmmtk|probes_native|value_opts_example-42-43" \ No newline at end of file + - "temurin-21|dacapochopin_jdk21" + - "temurin-21|dacapochopin_jdk21|epsilon|no_heapsize|heap4g" \ No newline at end of file diff --git a/src/running/config/runbms_example_probes.yml b/src/running/config/runbms_example_probes.yml new file mode 100644 index 0000000..7eb9183 --- /dev/null +++ b/src/running/config/runbms_example_probes.yml @@ -0,0 +1,38 @@ +includes: + - "$RUNNING_NG_PACKAGE_DATA/base/runbms.yml" + +overrides: + "suites.dacapo2006.timing_iteration": 5 + "suites.dacapobach.timing_iteration": 5 + "suites.dacapo2006.callback": "probe.Dacapo2006Callback" + "suites.dacapobach.callback": "probe.DacapoBachCallback" + +modifiers: + probes_cp: + type: JVMClasspath + val: "/home/zixianc/MMTk-Dev/evaluation/probes /home/zixianc/MMTk-Dev/evaluation/probes/probes.jar" + probes_native: + type: JVMArg + val: "-Djava.library.path=/home/zixianc/MMTk-Dev/evaluation/probes" + probes_rustmmtk: + type: JVMArg + val: "-Dprobes=RustMMTk" + value_opts_example: + type: EnvVar + var: "FOOBAR{0}" + val: "BUZZ{1}" + +runtimes: + jdk-mmtk: + type: OpenJDK + release: 11 + home: "/home/zixianc/MMTk-Dev/evaluation/build/jdk-mmtk/jdk" + +benchmarks: + dacapo2006: + - eclipse + dacapobach: + - fop + +configs: + - "jdk-mmtk|ms|s|c2|ss|tph|probes_cp|probes_rustmmtk|probes_native|value_opts_example-42-43" \ No newline at end of file diff --git a/src/running/modifier.py b/src/running/modifier.py index 594620c..9714072 100644 --- a/src/running/modifier.py +++ b/src/running/modifier.py @@ -180,3 +180,12 @@ def __init__(self, value_opts=None, **kwargs): def __str__(self) -> str: return "{} JuliaArg {}".format(super().__str__(), self.val) + + +@register(Modifier) +class NoImplicitHeapsizeModifier(Modifier): + def __init__(self, value_opts=None, **kwargs): + super().__init__(value_opts, **kwargs) + + def __str__(self) -> str: + return "{} NoImplicitHeapsizeModifier".format(super().__str__()) diff --git a/src/running/util.py b/src/running/util.py index 9486982..4153e47 100644 --- a/src/running/util.py +++ b/src/running/util.py @@ -70,6 +70,16 @@ def parse_config_str( return runtime, mods +def dont_emit_heapsize_modifier(configuration: "Configuration", c: str) -> bool: + mods = parse_modifier_strs(configuration, c.split("|")[1:]) + from running.modifier import NoImplicitHeapsizeModifier + + for mod in mods: + if isinstance(mod, NoImplicitHeapsizeModifier): + return True + return False + + def config_str_encode(c: str) -> str: return ".".join([x.strip() for x in c.split("|")]) diff --git a/tests/test_modifier.py b/tests/test_modifier.py index a43b7a1..744a9a0 100644 --- a/tests/test_modifier.py +++ b/tests/test_modifier.py @@ -2,6 +2,7 @@ from running.modifier import * from running.config import Configuration from running.runtime import OpenJDK +from running.util import dont_emit_heapsize_modifier def test_jvm_arg(): @@ -163,3 +164,23 @@ def test_envvar(): ) assert "$HOME" not in jb.to_string(openjdk) assert "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI" in jb.to_string(openjdk) + + +def test_no_implicit_heapsize_modifier(): + c = Configuration( + { + "modifiers": { + "no_hfac": {"type": "NoImplicitHeapsizeModifier"}, + }, + "runtimes": { + "jdk8": { + "type": "OpenJDK", + "release": 8, + "home": "/usr/lib/jvm/temurin-8-jdk-amd64", + } + }, + } + ) + c.resolve_class() + assert not dont_emit_heapsize_modifier(c, "jdk8|") + assert dont_emit_heapsize_modifier(c, "jdk8|no_hfac")