Skip to content

Commit 3750dd9

Browse files
committed
Automatically try to use PGO profiles when building GraalPy EE standalones
1 parent 8433e04 commit 3750dd9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,21 @@ def libpythonvm_build_args():
274274
build_args += bytecode_dsl_build_args()
275275
if mx_sdk_vm_ng.is_nativeimage_ee() and mx.get_os() == 'linux' and 'NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE' not in os.environ:
276276
build_args += ['--gc=G1', '-H:-ProtectionKeys']
277+
if not os.environ.get("GRAALPY_PGO_PROFILE") and mx.suite('graalpython-enterprise', fatalIfMissing=False):
278+
cmd = mx.command_function('python-get-latest-profile', fatalIfMissing=False)
279+
if cmd:
280+
try:
281+
profile = cmd([])
282+
except BaseException:
283+
pass
284+
else:
285+
mx.log(f"Using PGO profile {profile}")
286+
build_args += [
287+
f"--pgo={profile}",
288+
"-H:+UnlockExperimentalVMOptions",
289+
"-H:+PGOPrintProfileQuality",
290+
"-H:-UnlockExperimentalVMOptions",
291+
]
277292
return build_args
278293

279294

mx.graalpython/native-ee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/truffle-enterprise,/vm-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
1+
DYNAMIC_IMPORTS=/tools,/graalpython-enterprise,/graal-enterprise,/truffle-enterprise,/vm-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
22
BUILD_TARGETS=GRAALPY_NATIVE_STANDALONE
33
COMPONENTS=SubstrateVM Enterprise,Truffle SVM Macro Enterprise,suite:substratevm-enterprise-gcs
44
NATIVE_IMAGES=lib:pythonvm

0 commit comments

Comments
 (0)