maksaska commented on code in PR #13413:
URL: https://github.com/apache/ignite/pull/13413#discussion_r3970542632
##########
modules/ducktests/tests/ignitetest/services/utils/jvm_utils.py:
##########
@@ -17,25 +17,85 @@
This module contains JVM utilities.
"""
+import re
+
from ignitetest.services.utils.decorators import memoize
DEFAULT_HEAP = "768M"
-JVM_PARAMS_GC_G1 = "-XX:+UseG1GC -XX:MaxGCPauseMillis=100 " \
- "-XX:ConcGCThreads=$(((`nproc`/3)>1?(`nproc`/3):1)) " \
- "-XX:ParallelGCThreads=$(((`nproc`*3/4)>1?(`nproc`*3/4):1))
"
+GC_G1 = "G1"
+GC_PARALLEL = "PARALLEL"
+GC_SERIAL = "SERIAL"
+GC_Z = "ZGC"
+GC_SHENANDOAH = "SHENANDOAH"
+
+DEFAULT_GC = GC_G1
+
+# NOTE: these strings are interpolated into a shell command that is evaluated
on the remote
+# node (see IgniteSpec._jvm_opts and IgniteNodeSpec.command), which is what
makes the `nproc`
+# substitutions work. Consequently NO option here may contain spaces or quotes.
+_NPROC_THIRD = "$(((`nproc`/3)>1?(`nproc`/3):1))"
+_NPROC_THREE_QUARTERS = "$(((`nproc`*3/4)>1?(`nproc`*3/4):1))"
+
+# Garbage collector profiles. A profile is a mutually exclusive group: it both
selects the collector
+# and carries the tuning flags that are meaningful for it. Never mix flags
across profiles.
+GC_PROFILES = {
+ GC_G1: [
+ "-XX:+UseG1GC",
+ "-XX:MaxGCPauseMillis=100",
+ f"-XX:ConcGCThreads={_NPROC_THIRD}",
+ f"-XX:ParallelGCThreads={_NPROC_THREE_QUARTERS}",
+ "-XX:+UseStringDeduplication", # G1-only until JDK 18, hence part of
the profile
+ ],
+ GC_PARALLEL: [
+ "-XX:+UseParallelGC",
+ f"-XX:ParallelGCThreads={_NPROC_THREE_QUARTERS}",
+ # deliberately NO MaxGCPauseMillis: it flips ParallelGC into adaptive
pause-goal sizing
+ ],
+ GC_SERIAL: [
+ "-XX:+UseSerialGC",
+ ],
+ GC_Z: [
+ "-XX:+UseZGC", # product feature since JDK 15, no unlock flag needed
+ f"-XX:ConcGCThreads={_NPROC_THIRD}",
+ f"-XX:ParallelGCThreads={_NPROC_THREE_QUARTERS}",
+ ],
+ GC_SHENANDOAH: [
+ "-XX:+UseShenandoahGC", # product feature since JDK 15; OpenJDK only,
not Oracle JDK
+ f"-XX:ConcGCThreads={_NPROC_THIRD}",
+ f"-XX:ParallelGCThreads={_NPROC_THREE_QUARTERS}",
+ ],
+}
JVM_PARAMS_GENERIC = "-server -XX:+DisableExplicitGC -XX:+AlwaysPreTouch " \
"-XX:+ParallelRefProcEnabled -XX:+DoEscapeAnalysis " \
- "-XX:+OptimizeStringConcat -XX:+UseStringDeduplication"
+ "-XX:+OptimizeStringConcat"
+
+# Matches a collector selector like -XX:+UseZGC. Deliberately narrow: it must
not match
+# -XX:+DisableExplicitGC or -XX:+UseStringDeduplication.
+_GC_SELECTOR_PATTERN = re.compile(r"^-XX:([+-])(Use\w+GC)$")
+
+
+class MultipleGcSelectedError(Exception):
+ """
+ Raised when JVM options end up selecting more than one garbage collector.
+ """
-def create_jvm_settings(heap_size=DEFAULT_HEAP, gc_settings=JVM_PARAMS_GC_G1,
generic_params=JVM_PARAMS_GENERIC,
+def create_jvm_settings(heap_size=DEFAULT_HEAP, gc_settings=None,
generic_params=JVM_PARAMS_GENERIC,
gc_dump_path=None, oom_path=None, vm_error_path=None):
"""
Provides settings string for JVM process.
- param opts: JVM options to merge. Adds new or rewrites default values. Can
be list or string.
+ :param heap_size: value for both -Xmx and -Xms.
+ :param gc_settings: garbage collector options, see GC_PROFILES. Can be
list or string.
+ Defaults to the DEFAULT_GC profile.
+ :param generic_params: collector-independent options. Can be list or
string.
"""
+ gc_settings = GC_PROFILES[DEFAULT_GC] if gc_settings is None else
gc_settings
+
+ if isinstance(gc_settings, str):
Review Comment:
Fixed. resolve_gc_settings always returns a list, so it can't break in-tree,
but accepting non-str silently is worse than failing - a dict would join to its
keys. Added one _as_opts_list() helper that asserts str/list (like _to_map did)
and reused it in all three places, generic_params included.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]