Skip to content

Commit f1c089f

Browse files
committed
Allow runbms skipping emitting heapsize modifiers for some configs
1 parent 56b3160 commit f1c089f

File tree

8 files changed

+151
-49
lines changed

8 files changed

+151
-49
lines changed

docs/src/changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22
## Unreleased
33
### Added
4+
#### Modifiers
5+
- `NoImplicitHeapsizeModifier`
46

57
### Changed
68

docs/src/references/modifier.md

+11
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,14 @@ If a companion program also exist for the benchmark suite you use, this companio
9696
`val`: a single string with [shell-like syntax](https://docs.python.org/3/library/shlex.html#shlex.split).
9797
Multiple arguments are space separated.
9898
Environment variables will be expanded.
99+
100+
## `NoImplicitHeapsizeModifier` (preview ⚠️)
101+
`runbms` specific.
102+
103+
### Description
104+
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`).
105+
106+
This modifier prevents `runbms` from applying the heap sizes for certain configs, which is useful, for example, for running `NoGC` or `EpsilonGC`.
107+
108+
### Keys
109+
No argument is allowed.

src/running/command/runbms.py

+51-19
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
get_logged_in_users,
2121
config_index_to_chr,
2222
config_str_encode,
23+
dont_emit_heapsize_modifier,
2324
)
2425
import socket
2526
from datetime import datetime
@@ -453,6 +454,42 @@ def run(args):
453454
p.set_runbms_dir(runbms_dir)
454455
p.set_log_dir(log_dir)
455456

457+
configs_no_heapsize = [
458+
c for c in configs if dont_emit_heapsize_modifier(configuration, c)
459+
]
460+
configs_with_heapsize = [
461+
c for c in configs if not dont_emit_heapsize_modifier(configuration, c)
462+
]
463+
464+
# Simple case
465+
if not slice and N is None:
466+
# run all configs without specifying heap size
467+
run_one_hfac(
468+
invocations,
469+
None, # not specifying heap size
470+
suites,
471+
benchmarks,
472+
configs,
473+
Path(runbms_dir),
474+
log_dir,
475+
)
476+
# early return
477+
return True
478+
479+
# In all other cases, we will first run configs that don't want
480+
# implicit
481+
logging.info("Running all configs with NoImplicitHeapSizeModifier set")
482+
run_one_hfac(
483+
invocations,
484+
None, # not specifying heap size
485+
suites,
486+
benchmarks,
487+
configs_no_heapsize,
488+
Path(runbms_dir),
489+
log_dir,
490+
)
491+
492+
# Helper function for running benchmarks using multiple heap factors
456493
def run_hfacs(hfacs):
457494
logging.info(
458495
"hfacs: {}".format(", ".join([hfac_str(hfac) for hfac in hfacs]))
@@ -463,35 +500,30 @@ def run_hfacs(hfacs):
463500
hfac,
464501
suites,
465502
benchmarks,
466-
configs,
503+
configs_with_heapsize,
467504
Path(runbms_dir),
468505
log_dir,
469506
)
470507
print()
471508

509+
# Helper function for using the heap factor spreading algorithm
472510
def run_N_ns(N, ns):
473511
hfacs = get_hfacs(heap_range, spread_factor, N, ns)
474512
run_hfacs(hfacs)
475513

476-
if slice:
514+
if slice: # specified -s, we respect that first
515+
if N is not None:
516+
logging.warning(
517+
"You specified both N={} and -s {}, N is ignored.",
518+
N,
519+
",".join([str(s) for s in slice]),
520+
)
477521
run_hfacs(slice)
478-
return True
479-
480-
if N is None:
481-
run_one_hfac(
482-
invocations,
483-
None,
484-
suites,
485-
benchmarks,
486-
configs,
487-
Path(runbms_dir),
488-
log_dir,
489-
)
490-
return True
491-
492-
if len(ns) == 0:
493-
fillin(run_N_ns, round(math.log2(N)))
494522
else:
495-
run_N_ns(N, ns)
523+
assert N is not None
524+
if len(ns) == 0:
525+
fillin(run_N_ns, round(math.log2(N)))
526+
else:
527+
run_N_ns(N, ns)
496528

497529
return True

src/running/config/runbms_example.yml

+9-30
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
includes:
22
- "$RUNNING_NG_PACKAGE_DATA/base/runbms.yml"
33

4-
overrides:
5-
"suites.dacapo2006.timing_iteration": 5
6-
"suites.dacapobach.timing_iteration": 5
7-
"suites.dacapo2006.callback": "probe.Dacapo2006Callback"
8-
"suites.dacapobach.callback": "probe.DacapoBachCallback"
4+
benchmarks:
5+
dacapochopin:
6+
- fop
97

108
modifiers:
11-
probes_cp:
12-
type: JVMClasspath
13-
val: "/home/zixianc/MMTk-Dev/evaluation/probes /home/zixianc/MMTk-Dev/evaluation/probes/probes.jar"
14-
probes_native:
9+
heap4g:
1510
type: JVMArg
16-
val: "-Djava.library.path=/home/zixianc/MMTk-Dev/evaluation/probes"
17-
probes_rustmmtk:
18-
type: JVMArg
19-
val: "-Dprobes=RustMMTk"
20-
value_opts_example:
21-
type: EnvVar
22-
var: "FOOBAR{0}"
23-
val: "BUZZ{1}"
24-
25-
runtimes:
26-
jdk-mmtk:
27-
type: OpenJDK
28-
release: 11
29-
home: "/home/zixianc/MMTk-Dev/evaluation/build/jdk-mmtk/jdk"
30-
31-
benchmarks:
32-
dacapo2006:
33-
- eclipse
34-
dacapobach:
35-
- fop
11+
val: -Xms4G -Xmx4G
12+
no_heapsize:
13+
type: NoImplicitHeapsizeModifier
3614

3715
configs:
38-
- "jdk-mmtk|ms|s|c2|ss|tph|probes_cp|probes_rustmmtk|probes_native|value_opts_example-42-43"
16+
- "temurin-21|dacapochopin_jdk21"
17+
- "temurin-21|dacapochopin_jdk21|epsilon|no_heapsize|heap4g"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
includes:
2+
- "$RUNNING_NG_PACKAGE_DATA/base/runbms.yml"
3+
4+
overrides:
5+
"suites.dacapo2006.timing_iteration": 5
6+
"suites.dacapobach.timing_iteration": 5
7+
"suites.dacapo2006.callback": "probe.Dacapo2006Callback"
8+
"suites.dacapobach.callback": "probe.DacapoBachCallback"
9+
10+
modifiers:
11+
probes_cp:
12+
type: JVMClasspath
13+
val: "/home/zixianc/MMTk-Dev/evaluation/probes /home/zixianc/MMTk-Dev/evaluation/probes/probes.jar"
14+
probes_native:
15+
type: JVMArg
16+
val: "-Djava.library.path=/home/zixianc/MMTk-Dev/evaluation/probes"
17+
probes_rustmmtk:
18+
type: JVMArg
19+
val: "-Dprobes=RustMMTk"
20+
value_opts_example:
21+
type: EnvVar
22+
var: "FOOBAR{0}"
23+
val: "BUZZ{1}"
24+
25+
runtimes:
26+
jdk-mmtk:
27+
type: OpenJDK
28+
release: 11
29+
home: "/home/zixianc/MMTk-Dev/evaluation/build/jdk-mmtk/jdk"
30+
31+
benchmarks:
32+
dacapo2006:
33+
- eclipse
34+
dacapobach:
35+
- fop
36+
37+
configs:
38+
- "jdk-mmtk|ms|s|c2|ss|tph|probes_cp|probes_rustmmtk|probes_native|value_opts_example-42-43"

src/running/modifier.py

+9
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,12 @@ def __init__(self, value_opts=None, **kwargs):
180180

181181
def __str__(self) -> str:
182182
return "{} JuliaArg {}".format(super().__str__(), self.val)
183+
184+
185+
@register(Modifier)
186+
class NoImplicitHeapsizeModifier(Modifier):
187+
def __init__(self, value_opts=None, **kwargs):
188+
super().__init__(value_opts, **kwargs)
189+
190+
def __str__(self) -> str:
191+
return "{} NoImplicitHeapsizeModifier".format(super().__str__())

src/running/util.py

+10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ def parse_config_str(
7070
return runtime, mods
7171

7272

73+
def dont_emit_heapsize_modifier(configuration: "Configuration", c: str) -> bool:
74+
mods = parse_modifier_strs(configuration, c.split("|")[1:])
75+
from running.modifier import NoImplicitHeapsizeModifier
76+
77+
for mod in mods:
78+
if isinstance(mod, NoImplicitHeapsizeModifier):
79+
return True
80+
return False
81+
82+
7383
def config_str_encode(c: str) -> str:
7484
return ".".join([x.strip() for x in c.split("|")])
7585

tests/test_modifier.py

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from running.modifier import *
33
from running.config import Configuration
44
from running.runtime import OpenJDK
5+
from running.util import dont_emit_heapsize_modifier
56

67

78
def test_jvm_arg():
@@ -163,3 +164,23 @@ def test_envvar():
163164
)
164165
assert "$HOME" not in jb.to_string(openjdk)
165166
assert "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI" in jb.to_string(openjdk)
167+
168+
169+
def test_no_implicit_heapsize_modifier():
170+
c = Configuration(
171+
{
172+
"modifiers": {
173+
"no_hfac": {"type": "NoImplicitHeapsizeModifier"},
174+
},
175+
"runtimes": {
176+
"jdk8": {
177+
"type": "OpenJDK",
178+
"release": 8,
179+
"home": "/usr/lib/jvm/temurin-8-jdk-amd64",
180+
}
181+
},
182+
}
183+
)
184+
c.resolve_class()
185+
assert not dont_emit_heapsize_modifier(c, "jdk8|")
186+
assert dont_emit_heapsize_modifier(c, "jdk8|no_hfac")

0 commit comments

Comments
 (0)