Skip to content

Commit 412f431

Browse files
committed
[GR-58521] Use Native Image G1 GC on Linux
PullRequest: graalpython/3845
2 parents 7f9e2c7 + eeb8502 commit 412f431

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
1616
* Add support for sharing Arrow arrays and tables between Java, PyArrow, and Pandas to avoid data copying when embedding those libraries into a Java project.
1717
* Enable FTS3, FTS4, FTS5, RTREE, and math function features in the bundled sqlite3 library.
1818
* Add support patches for Torch 2.7.0, PyGObject 3.52.3, xmlschema 4.0.0, lxml < 5.4.0, SciPy 1.15, jq 1.8.0, NumPy < 2.3, ormsgpack < 1.9.1, pandas 2.2.3, PyArrow 19.0, PyMuPDF 1.25.4.
19+
* The GraalPy Native standalone on Linux now uses the G1 garbage collector which is much faster.
1920

2021
## Version 24.2.0
2122
* Updated developer metadata of Maven artifacts.

graalpython/com.oracle.graal.python.test/src/tests/test_gc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -39,12 +39,14 @@
3939

4040
from _weakref import ref, getweakrefcount
4141
import gc
42+
import sys
4243

4344

4445
def test_gc_collect():
4546
assert isinstance(gc.collect(), (int, type(None)))
4647

4748

48-
def test_gc_count():
49-
c0, c1, c2 = gc.get_count()
50-
assert c0 + c1 + c2 > 0, "we definitely had something collected"
49+
if not (sys.implementation.name == "graalpy" and __graalpython__.is_native): # GR-15504
50+
def test_gc_count():
51+
c0, c1, c2 = gc.get_count()
52+
assert c0 + c1 + c2 > 0, "we definitely had something collected"

mx.graalpython/mx_graalpython.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import mx_native
6161
import mx_unittest
6262
import mx_sdk
63+
import mx_sdk_vm_ng
6364
import mx_subst
6465
import mx_truffle
6566
import mx_graalpython_bisect
@@ -266,6 +267,14 @@ def graalpy_standalone_deps():
266267
return deps
267268

268269

270+
def libpythonvm_build_args():
271+
build_args = []
272+
build_args += bytecode_dsl_build_args()
273+
if mx_sdk_vm_ng.is_nativeimage_ee() and mx.get_os() == 'linux' and 'NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE' not in os.environ:
274+
build_args += ['--gc=G1', '-H:-ProtectionKeys']
275+
return build_args
276+
277+
269278
def full_python(args, env=None):
270279
"""Run python from standalone build (unless kwargs are given). Does not build GraalPython sources automatically."""
271280

@@ -2027,11 +2036,6 @@ def _python_checkpatchfiles():
20272036
def bytecode_dsl_build_args():
20282037
return ['-Dpython.EnableBytecodeDSLInterpreter=true'] if BYTECODE_DSL_INTERPRETER else []
20292038

2030-
mx_subst.results_substitutions.register_no_arg(
2031-
'bytecode_dsl_build_args',
2032-
lambda: f'-Dpython.EnableBytecodeDSLInterpreter={repr(BYTECODE_DSL_INTERPRETER).lower()}'
2033-
)
2034-
20352039
mx_sdk.register_graalvm_component(mx_sdk.GraalVmLanguage(
20362040
suite=SUITE,
20372041
name='GraalVM Python',

mx.graalpython/native-ee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/truffle-enterprise,/vm-enterprise,/substratevm-enterprise
1+
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/truffle-enterprise,/vm-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
22
BUILD_TARGETS=GRAALPY_NATIVE_STANDALONE
3-
COMPONENTS=SubstrateVM Enterprise,Truffle SVM Macro Enterprise
3+
COMPONENTS=SubstrateVM Enterprise,Truffle SVM Macro Enterprise,suite:substratevm-enterprise-gcs
44
NATIVE_IMAGES=lib:pythonvm
55
GRAALVM_SKIP_ARCHIVE=true

mx.graalpython/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@
847847
"-J-Xms14g", # GR-46399: libpythonvm needs more than the default minimum of 8 GB to be built
848848
"-Dpolyglot.python.PosixModuleBackend=native",
849849
"-Dpolyglot.python.Sha3ModuleBackend=native",
850-
"<bytecode_dsl_build_args>",
851850
],
851+
"dynamicBuildArgs": "libpythonvm_build_args",
852852
},
853853
},
854854

0 commit comments

Comments
 (0)