maksaska commented on code in PR #13413: URL: https://github.com/apache/ignite/pull/13413#discussion_r3957494992
########## modules/ducktests/tests/ignitetest/services/utils/gc_params.py: ########## @@ -0,0 +1,88 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +""" +This module resolves the garbage collector to use from Globals. + +GC selection is mutually-exclusive group replacement: a collector and its tuning flags travel together +(see GC_PROFILES in jvm_utils). It therefore has to be chosen *before* the default option list is +assembled -- patching it afterwards via jvm_opts leaves two selectors in the command line, because +merge_jvm_settings overwrites per option, not per group. + +This is the single resolution point for the 'gc' global. Keep it that way. +""" + +from ignitetest.services.utils.jvm_utils import DEFAULT_GC, GC_PROFILES + +GC_KEY_NAME = "gc" + +SERVER_ROLE = "server" +CLIENT_ROLE = "client" + + +def is_gc_configured(_globals: dict): + """ + :param _globals: Globals parameters + :return: True if the run explicitly selects a garbage collector. + """ + return GC_KEY_NAME in (_globals or {}) + + +def resolve_gc_settings(_globals: dict, role: str): + """ + Gets garbage collector options from Globals. Three shapes are accepted: + + {"gc": "ZGC"} -- both roles + {"gc": {"server": "ZGC"}} -- servers only, clients keep the default + {"gc": {"server": "ZGC", "client": "SERIAL"}} -- per role + {"gc": {"server": ["-XX:+UseZGC", "-XX:SoftMaxHeapSize=2G"]}} -- raw options, escape hatch + + Profile names are case-insensitive. A missing role, or a missing 'gc' key, yields the DEFAULT_GC + profile. A list value is used verbatim and bypasses profile validation -- that is the point of it. + + :param _globals: Globals parameters + :param role: SERVER_ROLE or CLIENT_ROLE + :return: list of JVM options selecting and tuning the collector + """ + configured = (_globals or {}).get(GC_KEY_NAME) + + if configured is None: + return _profile(DEFAULT_GC) + + if isinstance(configured, dict): + configured = configured.get(role) + + if configured is None: + return _profile(DEFAULT_GC) Review Comment: Did you spot anything specific that might be incorrect? It works fine on my end, but please let me know if there's something I missed. -- 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]
