Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand environment variables when resolving runtimes and benchmark suites #129

Merged
merged 6 commits into from
Nov 20, 2023
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
24 changes: 22 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -42,3 +42,23 @@ jobs:
- name: Test with mypy
run: |
mypy --check-untyped-defs src/running
black:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools build[virtualenv]
pip install .[zulip,tests]
pip install black
- name: Test with black
run: |
black --check src tests
10 changes: 8 additions & 2 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Changelog
## Unreleased
### Added
#### Benchmark Suites
- `DaCapo`: add 23.11-Chopin release and minheap values.
#### Base Configurations
- DaCapo 23.11-Chopin
- Temurin 21

### Changed
#### Base Configurations
- Environment variables are expanded when resolving paths of runtimes and benchmark suites.

### Deprecated
- Deprecating Python 3.7 support for users. Python 3.7 was last released on June 6, 2023 (3.7.17), which was recent.

### Removed
- Dropping Python 3.6 support for users. Last Python 3.6 release was on Sept. 4, 2021 (3.6.15), which was long ago.
- Dropping Python 3.7 support for developers (NOT users). pytest 7.4+ requires at least Python 3.8 (still supported by Ubuntu 20.04 LTS).

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]
authors = [{name = "Zixian Cai", email = "[email protected]"}]
dependencies = [
"pyyaml~=6.0"
"pyyaml~=6.0.1"
]
dynamic = ["version"]

Expand All @@ -30,12 +30,12 @@ dynamic = ["version"]

[project.optional-dependencies]
zulip = [
"zulip~=0.8.2"
"zulip~=0.9.0"
]
tests = [
"pytest>=7.1.3,<7.5.0",
"types-PyYAML~=6.0.11",
"mypy>=0.971,<2.0"
"pytest~=7.4.3",
"types-PyYAML~=6.0.12",
"mypy~=1.7.0"
]

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion src/running/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
runtime_specific_modifiers_strategy: Optional[
Callable[[Runtime], Sequence[Modifier]]
] = None,
**kwargs
**kwargs,
):
self.name = name
self.suite_name = suite_name
Expand Down
4 changes: 2 additions & 2 deletions src/running/command/log_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def ratio_work_perf_event(event_name: str):

def inner(stats: Dict[str, float]):
new_stats = deepcopy(stats)
for (k, v) in stats.items():
for k, v in stats.items():
if compiled.match(k):
new_column = k.replace(".total", ".ratio")
new_stats[new_column] = v / stats[aggregated_column]
Expand Down Expand Up @@ -107,7 +107,7 @@ def calc_work_ipc(stats: Dict[str, float]):
pattern = "work\\.\\w+\\.PERF_COUNT_HW_INSTRUCTIONS\\.total"
compiled = re.compile(pattern)
new_stats = deepcopy(stats)
for (k, v) in stats.items():
for k, v in stats.items():
if compiled.match(k):
cycles = k.replace("PERF_COUNT_HW_INSTRUCTIONS", "PERF_COUNT_HW_CPU_CYCLES")
ipc = k.replace(
Expand Down
4 changes: 4 additions & 0 deletions src/running/config/base/temurin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ runtimes:
type: OpenJDK
release: 17
home: /usr/lib/jvm/temurin-17-jdk-amd64
temurin-21:
type: OpenJDK
release: 21
home: /usr/lib/jvm/temurin-21-jdk-amd64
9 changes: 5 additions & 4 deletions src/running/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import logging
from running.util import register
import os.path


class Runtime(object):
Expand Down Expand Up @@ -90,7 +91,7 @@ def __init__(self, **kwargs):
except ValueError:
raise TypeError("The release of an OpenJDK has to be int-like")
self.home: Path
self.home = Path(kwargs["home"])
self.home = Path(os.path.expandvars(kwargs["home"]))
if not self.home.exists():
logging.warning("OpenJDK home {} doesn't exist".format(self.home))
self.executable = self.home / "bin" / "java"
Expand All @@ -110,7 +111,7 @@ class JikesRVM(JVM):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.home: Path
self.home = Path(kwargs["home"])
self.home = Path(os.path.expandvars(kwargs["home"]))
if not self.home.exists():
logging.warning("JikesRVM home {} doesn't exist".format(self.home))
self.executable = self.home / "rvm"
Expand All @@ -129,7 +130,7 @@ class JavaScriptRuntime(Runtime):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.executable: Path
self.executable = Path(kwargs["executable"])
self.executable = Path(os.path.expandvars(kwargs["executable"]))
if not self.executable.exists():
logging.warning(
"JavaScriptRuntime executable {} doesn't exist".format(self.executable)
Expand Down Expand Up @@ -204,7 +205,7 @@ class Julia(Runtime):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.executable: Path
self.executable = Path(kwargs["executable"])
self.executable = Path(os.path.expandvars(kwargs["executable"]))
if not self.executable.exists():
logging.warning("Julia executable {} doesn't exist".format(self.executable))
self.executable = self.executable.absolute()
Expand Down
11 changes: 6 additions & 5 deletions src/running/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from running.modifier import JVMArg, Modifier
import logging
from running.util import register, split_quoted
import os.path

__DRY_RUN = False
__DEFAULT_MINHEAP = 4096
Expand Down Expand Up @@ -112,7 +113,7 @@ def __init__(self, **kwargs):
if self.release not in ["2006", "9.12", "evaluation"]:
raise ValueError("DaCapo release {} not recongized".format(self.release))
self.path: Path
self.path = Path(kwargs["path"])
self.path = Path(os.path.expandvars(kwargs["path"]))
if not self.path.exists():
logging.warning("DaCapo jar {} not found".format(self.path))
self.minheap: Optional[str]
Expand Down Expand Up @@ -306,7 +307,7 @@ def __init__(self, **kwargs):
"SPECjbb2015 release {} not recongized".format(self.release)
)
self.path: Path
self.path = Path(kwargs["path"]).resolve()
self.path = Path(os.path.expandvars(kwargs["path"])).resolve()
self.propsfile = (self.path / ".." / "config" / "specjbb2015.props").resolve()
if not self.path.exists():
logging.info("SPECjbb2015 jar {} not found".format(self.path))
Expand Down Expand Up @@ -349,7 +350,7 @@ class Octane(BenchmarkSuite):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.path: Path
self.path = Path(kwargs["path"]).resolve()
self.path = Path(os.path.expandvars(kwargs["path"])).resolve()
if not self.path.exists():
logging.info("Octane folder {} not found".format(self.path))
self.wrapper: Path
Expand Down Expand Up @@ -431,7 +432,7 @@ def __init__(self, **kwargs):
if self.release not in ["1.03_05"]:
raise ValueError("SPECjvm98 release {} not recongized".format(self.release))
self.path: Path
self.path = Path(kwargs["path"]).resolve()
self.path = Path(os.path.expandvars(kwargs["path"])).resolve()

if not self.path.exists():
logging.info("SPECjvm98 {} not found".format(self.path))
Expand Down Expand Up @@ -481,7 +482,7 @@ class JuliaGCBenchmarks(BenchmarkSuite):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.path: Path
self.path = Path(kwargs["path"])
self.path = Path(os.path.expandvars(kwargs["path"]))
if not self.path.exists():
logging.warning("JuliaGCBenchmarks does not exist at {}".format(self.path))
self.minheap: Optional[str]
Expand Down
29 changes: 29 additions & 0 deletions tests/test_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from running.config import Configuration


def test_openjdk_path_ennvvar():
c = Configuration(
{
"runtimes": {
"temurin-21_bogus": {
"type": "OpenJDK",
"release": 21,
# some bogus environment variable that will not be expanded
"home": "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI/temurin-21-jdk-amd64",
},
"temurin-21": {
"type": "OpenJDK",
"release": 21,
"home": "$HOME/temurin-21-jdk-amd64",
},
}
}
)

c.resolve_class()
temurin_21_bogus = c.get("runtimes")["temurin-21_bogus"]
temurin_21 = c.get("runtimes")["temurin-21_bogus"]
assert "$HOME" not in str(temurin_21.home)
assert "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI" in str(
temurin_21_bogus.home
)
30 changes: 30 additions & 0 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,33 @@ def test_dacapo_openjdk_9_workaround():
print(fop_jdk11.to_string(jdk11))
assert "add-exports" not in fop_jdk8.to_string(jdk8)
assert "add-exports" in fop_jdk11.to_string(jdk11)


def test_dacapo_path_ennvvar():
c = Configuration(
{
"suites": {
"dacapo2006_bogus": {
"type": "DaCapo",
"release": "2006",
# some bogus environment variable that will not be expanded
"path": "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI/dacapo-2006-10-MR2.jar",
"timing_iteration": 3,
},
"dacapo2006": {
"type": "DaCapo",
"release": "2006",
"path": "$HOME/dacapo-2006-10-MR2.jar",
"timing_iteration": 3,
},
}
}
)

c.resolve_class()
dacapo2006 = c.get("suites")["dacapo2006"]
dacapo2006_bogus = c.get("suites")["dacapo2006_bogus"]
assert "$HOME" not in str(dacapo2006.path)
assert "$DAHKDLHDIWHEIUWHEIWEHIJHDJKAGDKJADGUQDGIQUWDGI" in str(
dacapo2006_bogus.path
)
Loading