From 84d171411e2b915f26d15743c87234d774fc13c1 Mon Sep 17 00:00:00 2001 From: Francois Farquet Date: Thu, 19 Sep 2024 16:24:37 +0200 Subject: [PATCH 1/4] Support dynamically generated vm configs --- vm/mx.vm/mx_vm_benchmark.py | 96 ++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 12 deletions(-) diff --git a/vm/mx.vm/mx_vm_benchmark.py b/vm/mx.vm/mx_vm_benchmark.py index d436b429fbab..95a71b6cb26b 100644 --- a/vm/mx.vm/mx_vm_benchmark.py +++ b/vm/mx.vm/mx_vm_benchmark.py @@ -544,26 +544,98 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args= self.analysis_context_sensitivity = None self.no_inlining_before_analysis = False self.optimization_level = None - self._configure_from_name(config_name) + self._configure_comma_separated_configs(config_name) + if ',' not in config_name: + # we validate that programmatic configuration of the VM matches reliably re-generates the original config name + # since this feature is relied upon for syntactic sugar for vm configs + assert config_name == self.config_name(), f"Config name mismatch: '{config_name}' is generated as '{self.config_name()}' !" + + @staticmethod + def canonical_config_name(config_name): + # NativeImageVM allows syntactic sugar for its VM configs such that 'otw-ee,pgo,g1gc' is mapped to 'otw-g1gc-pgo-ee' + # this canonicalization will take the former and return the latter + return NativeImageVM('native-image', config_name).config_name() + + def config_name(self): + # Generates the unique vm config name based on how the VM is actually configured. + # It concatenates the config options in the correct order to match the expected format. + config = [] + if self.native_architecture is True: + config += ["native-architecture"] + if self.use_string_inlining is True: + config += ["string-inlining"] + if self.use_open_type_world is True: + config += ["otw"] + if self.is_gate is True: + config += ["gate"] + if self.use_upx is True: + config += ["upx"] + if self.is_quickbuild is True: + config += ["quickbuild"] + if self.gc == "G1": + config += ["g1gc"] + if self.is_llvm is True: + config += ["llvm"] + is_pgo_set = False + if self.pgo_context_sensitive is False: + config += ["pgo-ctx-insens"] + is_pgo_set = True + if self.pgo_sampler_only is True: + config += ["pgo-sampler"] + is_pgo_set = True + if not is_pgo_set and self.pgo_instrumentation is True \ + and self.jdk_profiles_collect is False \ + and self.adopted_jdk_pgo is False \ + and self.safepoint_sampler is False \ + and self.async_sampler is False \ + and self.force_profile_inference is False \ + and self.profile_inference_feature_extraction is False: + config += ["pgo"] + if self.analysis_context_sensitivity is not None: + sensitivity = self.analysis_context_sensitivity + if sensitivity.startswith("_"): + sensitivity = sensitivity[1:] + config += [sensitivity] + if self.no_inlining_before_analysis is True: + config += ["no-inline"] + if self.jdk_profiles_collect is True: + config += ["jdk-profiles-collect"] + if self.adopted_jdk_pgo is True: + config += ["adopted-jdk-pgo"] + if self.profile_inference_feature_extraction is True: + config += ["profile-inference-feature-extraction"] + if self.pgo_instrumentation is True and self.force_profile_inference is True: + if self.pgo_exclude_conditional is True: + config += ["profile-inference-pgo"] + if self.profile_inference_debug is True: + config += ["profile-inference-debug"] + if self.safepoint_sampler is True: + config += ["safepoint-sampler"] + if self.async_sampler is True: + config += ["async-sampler"] + if self.optimization_level is not None: + config += [self.optimization_level] + if not config: + config += ["default"] + if self.graalvm_edition is not None: + config += [self.graalvm_edition] + return "-".join(config) + + def _configure_comma_separated_configs(self, config_string): + # Due to the complexity of the VM config and how hard it is to get the ordering right, it has been relaxed + # to allow comma-separated configs. So 'pgo,g1gc-ee,native-architecture' is syntactic sugar for 'native-architecture-g1gc-pgo-ee' + for config_part in config_string.split(','): + if config_part: + self._configure_from_name(config_part) def _configure_from_name(self, config_name): if not config_name: mx.abort(f"config_name must be set. Use 'default' for the default {self.__class__.__name__} configuration.") - # special case for the 'default' configuration, other configurations are handled by the regex to ensure consistent ordering - if config_name == "default": - return - if config_name == "default-ce": - self.graalvm_edition = "ce" - return - if config_name == "default-ee": - self.graalvm_edition = "ee" - return - # This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config rule = r'^(?Pnative-architecture-)?(?Pstring-inlining-)?(?Potw-)?(?Pgate-)?(?Pupx-)?(?Pquickbuild-)?(?Pg1gc-)?(?Pllvm-)?(?Ppgo-|pgo-ctx-insens-|pgo-sampler-)?(?Pinline-)?' \ r'(?Pinsens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?Pno-inline-)?(?Pjdk-profiles-collect-|adopted-jdk-pgo-)?' \ - r'(?Pprofile-inference-feature-extraction-|profile-inference-pgo-|profile-inference-debug-)?(?Psafepoint-sampler-|async-sampler-)?(?PO0-|O1-|O2-|O3-|Os-)?(?Pce-|ee-)?$' + r'(?Pprofile-inference-feature-extraction-|profile-inference-pgo-|profile-inference-debug-)?(?Psafepoint-sampler-|async-sampler-)?(?PO0-|O1-|O2-|O3-|Os-)?(default-)?(?Pce-|ee-)?$' mx.logv(f"== Registering configuration: {config_name}") match_name = f"{config_name}-" # adding trailing dash to simplify the regex From 9a2ad5a619911baa44556a0312070cbe67299150 Mon Sep 17 00:00:00 2001 From: Francois Farquet Date: Mon, 4 Nov 2024 11:45:39 +0100 Subject: [PATCH 2/4] Prevent non-canonical configuration of VMs --- vm/mx.vm/mx_vm_benchmark.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vm/mx.vm/mx_vm_benchmark.py b/vm/mx.vm/mx_vm_benchmark.py index 95a71b6cb26b..4657249ad513 100644 --- a/vm/mx.vm/mx_vm_benchmark.py +++ b/vm/mx.vm/mx_vm_benchmark.py @@ -545,7 +545,9 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args= self.no_inlining_before_analysis = False self.optimization_level = None self._configure_comma_separated_configs(config_name) - if ',' not in config_name: + if ',' in config_name: + self._canonical_configuration = False + else: # we validate that programmatic configuration of the VM matches reliably re-generates the original config name # since this feature is relied upon for syntactic sugar for vm configs assert config_name == self.config_name(), f"Config name mismatch: '{config_name}' is generated as '{self.config_name()}' !" From 20e6e653287df6fdbf89113f49905045dc1bc2f6 Mon Sep 17 00:00:00 2001 From: Francois Farquet Date: Mon, 4 Nov 2024 12:12:56 +0100 Subject: [PATCH 3/4] pylint --- vm/mx.vm/mx_vm_benchmark.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vm/mx.vm/mx_vm_benchmark.py b/vm/mx.vm/mx_vm_benchmark.py index 4657249ad513..d2a96e509837 100644 --- a/vm/mx.vm/mx_vm_benchmark.py +++ b/vm/mx.vm/mx_vm_benchmark.py @@ -585,6 +585,7 @@ def config_name(self): if self.pgo_sampler_only is True: config += ["pgo-sampler"] is_pgo_set = True + # pylint: disable=too-many-boolean-expressions if not is_pgo_set and self.pgo_instrumentation is True \ and self.jdk_profiles_collect is False \ and self.adopted_jdk_pgo is False \ From b6e410e9657e3ac8a5d372ca20e621d130b408fb Mon Sep 17 00:00:00 2001 From: Francois Farquet Date: Thu, 19 Sep 2024 16:28:21 +0200 Subject: [PATCH 4/4] Bump mx version --- common.json | 2 +- vm/mx.vm/suite.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.json b/common.json index 25be40131e1c..61aa7088f7e8 100644 --- a/common.json +++ b/common.json @@ -4,7 +4,7 @@ "Jsonnet files should not include this file directly but use ci/common.jsonnet instead." ], - "mx_version": "7.33.1", + "mx_version": "7.34.1", "COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet", "jdks": { diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index 9952f3102f3a..0d43ff10132f 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -1,7 +1,7 @@ suite = { "name": "vm", "version" : "24.2.0", - "mxversion": "7.33.0", + "mxversion": "7.34.1", "release" : False, "groupId" : "org.graalvm",