Skip to content

Commit 1fa36d5

Browse files
committed
[GR-69781] Give more time and also track memory for micro-native benchmarks.
PullRequest: graalpython/4015
2 parents 0cffc0d + f0cbb5f commit 1fa36d5

File tree

9 files changed

+102
-21
lines changed

9 files changed

+102
-21
lines changed

ci.jsonnet

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,15 @@
391391
for bench in ["warmup"]
392392
} + {
393393
[bench]: bench_task(bench) + platform_spec(no_jobs) + bench_variants({
394-
"vm_name:graalvm_ee_default_interpreter" : {"linux:amd64:jdk-latest" : post_merge + t("01:00:00")},
395-
"vm_name:graalvm_ee_default_interpreter_bc_dsl" : {"linux:amd64:jdk-latest" : post_merge + t("01:00:00")},
396-
"vm_name:graalpython_enterprise_interpreter" : {"linux:amd64:jdk-latest" : daily + t("01:00:00")},
397-
"vm_name:graalpython_enterprise_interpreter_bc_dsl" : {"linux:amd64:jdk-latest" : daily + t("01:00:00")},
398-
"vm_name:cpython" : {"linux:amd64:jdk-latest" : weekly + t("00:30:00")},
394+
"vm_name:graalvm_ee_default_interpreter" : {"linux:amd64:jdk-latest" : post_merge + t("02:00:00")},
395+
"vm_name:graalpython_enterprise_interpreter" : {"linux:amd64:jdk-latest" : weekly + t("02:00:00")},
396+
"vm_name:cpython" : {"linux:amd64:jdk-latest" : weekly + t("01:00:00")},
397+
}),
398+
for bench in ["heap", "micro_small_heap"]
399+
} + {
400+
[bench + "-bytecode-dsl"]: bench_task(bench) + bytecode_dsl_bench + platform_spec(no_jobs) + bench_variants({
401+
"vm_name:graalvm_ee_default_interpreter_bc_dsl" : {"linux:amd64:jdk-latest" : post_merge + t("02:00:00")},
402+
"vm_name:graalpython_enterprise_interpreter_bc_dsl" : {"linux:amd64:jdk-latest" : weekly + t("02:00:00")},
399403
}),
400404
for bench in ["heap", "micro_small_heap"]
401405
} + {
@@ -425,7 +429,7 @@
425429
for bench in ["pyperformance"]
426430
} + {
427431
// Bytecode DSL benchmarks with community benchmark suites for external numbers
428-
[bench + "-bytecode-dsl"]: bench_task(bench, PY_BENCHMARKS) + platform_spec(no_jobs) + raw_results + bench_variants({
432+
[bench + "-bytecode-dsl"]: bench_task(bench, PY_BENCHMARKS) + bytecode_dsl_bench + platform_spec(no_jobs) + raw_results + bench_variants({
429433
"vm_name:graalvm_ee_default_bc_dsl" : {"linux:amd64:jdk-latest" : weekly + t("08:00:00")},
430434
}),
431435
for bench in ["pyperformance"]

ci/python-bench.libsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
jmh: "python-jmh:GRAALPYTHON_BENCH",
3838
heap: "heap-graalpython:*",
3939
micro_small_heap: "micro-small-heap-graalpython:*",
40+
micro_native_heap: "micro-native-heap-graalpython:*",
4041
},
4142

4243
PY_BENCHMARKS:: {

graalpython/com.oracle.graal.python.cext/src/datetime.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7441,12 +7441,12 @@ GraalPyPrivate_InitNativeDateTime()
74417441
PyMemberDef* members_delta = PyDateTime_DeltaType.tp_members;
74427442

74437443
static int64_t datetime_types[] = {
7444-
&PyDateTime_DateType, "datetime.date",
7445-
&PyDateTime_DateTimeType, "datetime.datetime",
7446-
&PyDateTime_TimeType, "datetime.time",
7447-
&PyDateTime_DeltaType, "datetime.timedelta",
7448-
&PyDateTime_TZInfoType, "datetime.timezone",
7449-
NULL, NULL
7444+
(intptr_t)&PyDateTime_DateType, (intptr_t)"datetime.date",
7445+
(intptr_t)&PyDateTime_DateTimeType, (intptr_t)"datetime.datetime",
7446+
(intptr_t)&PyDateTime_TimeType, (intptr_t)"datetime.time",
7447+
(intptr_t)&PyDateTime_DeltaType, (intptr_t)"datetime.timedelta",
7448+
(intptr_t)&PyDateTime_TZInfoType, (intptr_t)"datetime.timezone",
7449+
0, 0
74507450
};
74517451
GraalPyPrivate_InitBuiltinTypesAndStructs(datetime_types);
74527452

graalpython/lib-graalpython/patches/onnxruntime-1.17.1.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,12 @@ index 31f242c..300211b 100644
140140
if args.use_gdk:
141141
cmake_args += [
142142
"-DCMAKE_TOOLCHAIN_FILE=" + os.path.join(source_dir, "cmake", "gdk_toolchain.cmake"),
143+
@@ -2485,7 +2490,7 @@ def main():
144+
args.use_cache = True
145+
146+
if not is_windows():
147+
- if not args.allow_running_as_root:
148+
+ if False and not args.allow_running_as_root:
149+
is_root_user = os.geteuid() == 0
150+
if is_root_user:
151+
raise BuildError(

graalpython/lib-graalpython/patches/onnxruntime-1.22.1.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,12 @@ index 2a06916..c790a21 100644
9393
if args.use_gdk:
9494
cmake_args += [
9595
"-DCMAKE_TOOLCHAIN_FILE=" + os.path.join(source_dir, "cmake", "gdk_toolchain.cmake"),
96+
@@ -2167,7 +2173,7 @@ def main():
97+
os.environ["ANDROID_NDK_HOME"] = args.android_ndk_path
98+
99+
if not is_windows() and not is_macOS():
100+
- if not args.allow_running_as_root:
101+
+ if False and not args.allow_running_as_root:
102+
is_root_user = os.geteuid() == 0
103+
if is_root_user:
104+
raise BuildError(

mx.graalpython/live_heap_tracker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def main():
8080
iterations = int(sys.argv[2])
8181
jmap_binary = sys.argv[3]
8282
benchmark = sys.argv[4:]
83+
# Run the benchmark once to ensure pyc files are generated
84+
subprocess.check_call(benchmark)
8385
with open(output_file, 'w') as f:
86+
t0 = time.time()
8487
for _ in range(iterations):
8588
proc = subprocess.Popen(benchmark)
8689
ppid = proc.pid
@@ -89,6 +92,9 @@ def main():
8992
uss_bytes = uss(ppid)
9093
heap_bytes = jmap(jmap_binary, ppid)
9194
f.write(f"{heap_bytes} {uss_bytes}\n")
95+
# cut short if this is a long benchmark
96+
if time.time() - t0 > 30:
97+
break
9298
if proc.returncode != 0:
9399
sys.exit(proc.returncode)
94100

mx.graalpython/mx_graalpython.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,18 @@ def libpythonvm_build_args():
308308
profile = get_profile(["--branch", b])
309309
except BaseException:
310310
pass
311-
if CI and not os.path.isfile(profile or "") and (
312-
# When running on a release branch or attempting to merge into
313-
# a release branch, make sure we can use a PGO profile
314-
any(b.startswith("release/") for b in [branch, os.environ.get("TO_BRANCH", "")])
315-
# When running in the CI on a bench runner, use a PGO profile
316-
or ",bench," in os.environ.get("LABELS", "")
317-
):
318-
mx.warn("PGO profile must exist for benchmarking and release, creating one now...")
319-
profile = graalpy_native_pgo_build_and_test()
311+
312+
if CI and not os.path.isfile(profile or ""):
313+
mx.log("No profile in CI job")
314+
# When running on a release branch or attempting to merge into
315+
# a release branch, make sure we can use a PGO profile, and
316+
# when running in the CI on a bench runner, ensure a PGO profile
317+
if (
318+
any(b.startswith("release/") for b in [branch, os.environ.get("TO_BRANCH", "")])
319+
or (",bench," in os.environ.get("LABELS", ""))
320+
):
321+
mx.warn("PGO profile must exist for benchmarking and release, creating one now...")
322+
profile = graalpy_native_pgo_build_and_test()
320323

321324
if os.path.isfile(profile or ""):
322325
print(invert(f"Automatically chose PGO profile {profile}. To disable this, set GRAALPY_PGO_PROFILE to an empty string'", blinking=True), file=sys.stderr)

mx.graalpython/mx_graalpython_bench_param.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,5 @@ def _pickling_benchmarks(module='pickle'):
342342
"allocate-objects": [],
343343
}],
344344
"micro-small-heap": [PATH_MICRO, MICRO_BENCHMARKS_SMALL],
345+
"micro-native-heap": [PATH_MICRO, MICRO_NATIVE_BENCHMARKS],
345346
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
if [ -n "$GITHUB_RUN_ID" ]; then
41+
pip install cmake==3.28.4
42+
fi
43+
44+
if [ -n "$1" ]; then
45+
pip wheel "onnxruntime==$1"
46+
else
47+
pip wheel onnxruntime
48+
fi

0 commit comments

Comments
 (0)