Skip to content

Commit 89e7cce

Browse files
committed
[GR-70865] Make separate PGO profile for bytecode DSL
PullRequest: graalpython/4060
2 parents a682556 + b3ba780 commit 89e7cce

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

ci.jsonnet

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,15 @@
7575
local bench_task(bench=null, benchmarks=BENCHMARKS) = super.bench_task(bench=bench, benchmarks=benchmarks),
7676
local bisect_bench_task = self.bisect_bench_task,
7777

78-
local bytecode_dsl_gate(name) = task_spec({
78+
local bytecode_dsl_env = task_spec({
7979
environment +: {
8080
BYTECODE_DSL_INTERPRETER: "true"
8181
},
82+
}),
83+
local bytecode_dsl_gate(name) = bytecode_dsl_env + task_spec({
8284
tags :: name,
8385
}),
84-
local bytecode_dsl_bench = task_spec({
85-
environment +: {
86-
BYTECODE_DSL_INTERPRETER: "true"
87-
},
86+
local bytecode_dsl_bench = bytecode_dsl_env + task_spec({
8887
name_suffix +:: ["bytecode-dsl"],
8988
}),
9089

@@ -212,6 +211,15 @@
212211
],
213212
}),
214213
}),
214+
"python-pgo-profile-bytecode-dsl": gpgate_ee + bytecode_dsl_env + platform_spec(no_jobs) + platform_spec({
215+
"linux:amd64:jdk-latest" : post_merge + t("01:30:00") + task_spec({
216+
run: [["mx", "python-native-pgo"]],
217+
logs+: [
218+
"default-bytecode-dsl.iprof.gz",
219+
"default-bytecode-dsl.lcov",
220+
],
221+
}),
222+
}),
215223
"python-svm-unittest": gpgate + platform_spec(no_jobs) + platform_spec({
216224
"linux:amd64:jdk-latest" : tier2 + require(GPY_NATIVE_STANDALONE),
217225
"linux:aarch64:jdk-latest" : tier3 + require(GPY_NATIVE_STANDALONE),

mx.graalpython/mx_graalpython.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,16 @@ def libpythonvm_build_args():
282282
vc = SUITE.vc
283283
commit = str(vc.tip(SUITE.dir)).strip()
284284
branch = str(vc.active_branch(SUITE.dir, abortOnError=False) or 'master').strip()
285+
dsl_suffix = '' if not BYTECODE_DSL_INTERPRETER else '-bytecode-dsl'
285286

286287
if script := os.environ.get("ARTIFACT_DOWNLOAD_SCRIPT"):
287288
# This is always available in the GraalPy CI
288-
profile = "cached_profile.iprof.gz"
289+
profile = f"cached_profile{dsl_suffix}.iprof.gz"
289290
run(
290291
[
291292
sys.executable,
292293
script,
293-
f"graalpy/{commit}",
294+
f"graalpy/pgo{dsl_suffix}-{commit}",
294295
profile,
295296
],
296297
nonZeroIsFatal=False,
@@ -299,21 +300,23 @@ def libpythonvm_build_args():
299300
# Locally, we try to get a reasonable profile
300301
get_profile = mx.command_function('python-get-latest-profile', fatalIfMissing=False)
301302
if get_profile:
302-
for b in set([branch, "master"]):
303+
for b in [branch, "master"]:
303304
if not profile:
304305
try:
305306
profile = get_profile(["--branch", b])
307+
if profile and dsl_suffix not in profile:
308+
mx.warn("PGO profile seems mismatched, you need newer graal-enterprise")
306309
except BaseException:
307310
pass
308311

309-
if CI and not os.path.isfile(profile or ""):
312+
if CI and (not profile or not os.path.isfile(profile)):
310313
mx.log("No profile in CI job")
311314
# When running on a release branch or attempting to merge into
312315
# a release branch, make sure we can use a PGO profile, and
313316
# when running in the CI on a bench runner, ensure a PGO profile
314317
if (
315318
any(b.startswith("release/") for b in [branch, os.environ.get("TO_BRANCH", "")])
316-
or (",bench," in os.environ.get("LABELS", ""))
319+
or os.environ.get('BUILD_NAME', '').startswith('pybench-')
317320
):
318321
mx.warn("PGO profile must exist for benchmarking and release, creating one now...")
319322
profile = graalpy_native_pgo_build_and_test()
@@ -361,10 +364,13 @@ def graalpy_native_pgo_build_and_test(args=None):
361364
GRAALPY_HOME=instrumented_home,
362365
):
363366
graalpytest(["--python", instrumented_launcher, "test_venv.py"])
364-
mx.command_function('benchmark')(["meso-small:*", "--", "--python-vm", "graalpython", "--python-vm-config", "custom"])
365-
366-
iprof_path = Path(SUITE.dir) / 'default.iprof'
367-
lcov_path = Path(SUITE.dir) / 'default.lcov'
367+
python_vm_config = 'custom'
368+
if BYTECODE_DSL_INTERPRETER:
369+
python_vm_config += '-bc-dsl'
370+
mx.command_function('benchmark')(["meso-small:*", "--", "--python-vm", "graalpython", "--python-vm-config", python_vm_config])
371+
dsl_suffix = '' if not BYTECODE_DSL_INTERPRETER else '-bytecode-dsl'
372+
iprof_path = Path(SUITE.dir) / f'default{dsl_suffix}.iprof'
373+
lcov_path = Path(SUITE.dir) / f'default{dsl_suffix}.lcov'
368374

369375
run([
370376
os.path.join(
@@ -411,17 +417,19 @@ def graalpy_native_pgo_build_and_test(args=None):
411417
mx.log(mx.colorize(f"[PGO] Gzipped profile at: {iprof_gz_path}", color="yellow"))
412418

413419
if script := os.environ.get("ARTIFACT_UPLOADER_SCRIPT"):
420+
commit = str(SUITE.vc.tip(SUITE.dir)).strip()
414421
run(
415422
[
416423
sys.executable,
417424
script,
418425
iprof_gz_path,
419-
str(SUITE.vc.tip(SUITE.dir)).strip(),
426+
f"pgo{dsl_suffix}-{commit}",
420427
"graalpy",
421428
"--lifecycle",
422429
"cache",
423430
"--artifact-repo-key",
424431
os.environ.get("ARTIFACT_REPO_KEY_LOCATION"),
432+
'--skip-existing',
425433
],
426434
)
427435

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def launcher_type(self):
284284
@property
285285
@functools.lru_cache
286286
def interpreter(self):
287-
if self.config_name() == CONFIGURATION_CUSTOM:
287+
if self.config_name().startswith(CONFIGURATION_CUSTOM):
288288
home = mx.get_env("GRAALPY_HOME")
289289
if not home:
290290
mx.abort("The custom benchmark config for graalpy is to run with a custom GRAALPY_HOME locally")
@@ -1081,8 +1081,8 @@ def add_graalpy_vm(name, *extra_polyglot_args):
10811081
python_vm_registry.add_vm(GraalPythonVm(config_name=name, extra_polyglot_args=extra_polyglot_args), suite, 10)
10821082

10831083
# GraalPy VMs:
1084-
add_graalpy_vm(CONFIGURATION_CUSTOM)
10851084
add_graalpy_vm(CONFIGURATION_DEFAULT)
1085+
add_graalpy_vm(CONFIGURATION_CUSTOM)
10861086
add_graalpy_vm(CONFIGURATION_INTERPRETER, '--experimental-options', '--engine.Compilation=false')
10871087
add_graalpy_vm(CONFIGURATION_DEFAULT_MULTI, '--experimental-options', '-multi-context')
10881088
add_graalpy_vm(CONFIGURATION_INTERPRETER_MULTI, '--experimental-options', '-multi-context', '--engine.Compilation=false')

0 commit comments

Comments
 (0)