Skip to content

Commit cb467a8

Browse files
committed
[GR-51270] Add the profile-inference-debug-ee jvm config.
PullRequest: graal/16793
2 parents 893b500 + 9aab99a commit cb467a8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

vm/mx.vm/mx_vm_benchmark.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
158158
if vm.jdk_profiles_collect:
159159
# forbid image build/run in the profile collection execution mode
160160
removed_stages.update([Stage.IMAGE, Stage.RUN])
161-
if vm.profile_inference_feature_extraction:
162-
# do not run the image in the profile inference feature extraction mode
161+
if vm.profile_inference_feature_extraction or vm.profile_inference_debug:
162+
# do not run the image in the profile inference feature extraction or debug mode
163163
removed_stages.add(Stage.RUN)
164164
self.skip_agent_assertions = bm_suite.skip_agent_assertions(self.benchmark_name, args)
165165
root_dir = Path(benchmark_output_dir if benchmark_output_dir else mx.suite('vm').get_output_root(platformDependent=False, jdkDependent=False)).absolute()
@@ -171,6 +171,7 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
171171
self.profile_path: Path = self.output_dir / f"{self.executable_name}.iprof"
172172
self.config_dir: Path = self.output_dir / "config"
173173
self.log_dir: Path = self.output_dir
174+
self.ml_log_dump_path: Path = self.output_dir / f"{self.executable_name}.ml.log.csv"
174175
base_image_build_args = ['--no-fallback', '-g']
175176
base_image_build_args += ['-H:+VerifyGraalGraphs', '-H:+VerifyPhases', '--diagnostics-mode'] if vm.is_gate else []
176177
base_image_build_args += ['-H:+ReportExceptionStackTraces']
@@ -530,6 +531,7 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=
530531
self.safepoint_sampler = False
531532
self.profile_inference_feature_extraction = False
532533
self.force_profile_inference = False
534+
self.profile_inference_debug = False
533535
self.analysis_context_sensitivity = None
534536
self.no_inlining_before_analysis = False
535537
self.optimization_level = None
@@ -552,7 +554,7 @@ def _configure_from_name(self, config_name):
552554
# This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config
553555
rule = r'^(?P<native_architecture>native-architecture-)?(?P<string_inlining>string-inlining-)?(?P<gate>gate-)?(?P<upx>upx-)?(?P<quickbuild>quickbuild-)?(?P<gc>g1gc-)?(?P<llvm>llvm-)?(?P<pgo>pgo-|pgo-ctx-insens-|pgo-sampler-)?(?P<inliner>inline-)?' \
554556
r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<jdk_profiles>jdk-profiles-collect-|adopted-jdk-pgo-)?' \
555-
r'(?P<profile_inference>profile-inference-feature-extraction-|profile-inference-pgo-)?(?P<sampler>safepoint-sampler-|async-sampler-)?(?P<optimization_level>O0-|O1-|O2-|O3-|Os-)?(?P<edition>ce-|ee-)?$'
557+
r'(?P<profile_inference>profile-inference-feature-extraction-|profile-inference-pgo-|profile-inference-debug-)?(?P<sampler>safepoint-sampler-|async-sampler-)?(?P<optimization_level>O0-|O1-|O2-|O3-|Os-)?(?P<edition>ce-|ee-)?$'
556558

557559
mx.logv(f"== Registering configuration: {config_name}")
558560
match_name = f"{config_name}-" # adding trailing dash to simplify the regex
@@ -658,6 +660,17 @@ def generate_profiling_package_prefixes():
658660
self.force_profile_inference = True
659661

660662
self.pgo_exclude_conditional = True
663+
elif profile_inference_config == 'profile-inference-debug':
664+
# We need to run instrumentation as the profile-inference-debug config compares inferred profiles to profiles collected via instrumentation.
665+
self.pgo_instrumentation = True
666+
667+
# Due to the collision between flags, we must re-enable the ML inference:
668+
# 1. To run the image build in the debug mode, we must enable PGO to dynamically collect program profiles.
669+
# 2. The PGO flag disables the ML Profile Inference.
670+
# 3. Therefore, here we re-enable the ML Profile Inference from the command line.
671+
self.force_profile_inference = True
672+
673+
self.profile_inference_debug = True
661674
else:
662675
mx.abort('Unknown profile inference configuration: {}.'.format(profile_inference_config))
663676

@@ -1165,9 +1178,13 @@ def run_stage_image(self):
11651178
ml_args = svm_experimental_options(['-H:+MLGraphFeaturesExtraction', '-H:+MLProfileInference'])
11661179
else:
11671180
ml_args = []
1181+
if self.profile_inference_debug:
1182+
ml_debug_args = svm_experimental_options(['-H:LogMLInference={}'.format(self.config.ml_log_dump_path)])
1183+
else:
1184+
ml_debug_args = []
11681185

11691186
collection_args = svm_experimental_options([f"-H:BuildOutputJSONFile={self.config.get_build_output_json_file(Stage.IMAGE)}"])
1170-
final_image_command = self.config.base_image_build_args + executable_name_args + (pgo_args if self.pgo_instrumentation else []) + jdk_profiles_args + ml_args + collection_args
1187+
final_image_command = self.config.base_image_build_args + executable_name_args + (pgo_args if self.pgo_instrumentation else []) + jdk_profiles_args + ml_args + ml_debug_args + collection_args
11711188
with self.get_stage_runner() as s:
11721189
exit_code = s.execute_command(self, final_image_command)
11731190
NativeImageVM.move_bundle_output(self.config, self.config.image_path)

0 commit comments

Comments
 (0)