@@ -158,8 +158,8 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
158
158
if vm .jdk_profiles_collect :
159
159
# forbid image build/run in the profile collection execution mode
160
160
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
163
163
removed_stages .add (Stage .RUN )
164
164
self .skip_agent_assertions = bm_suite .skip_agent_assertions (self .benchmark_name , args )
165
165
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
171
171
self .profile_path : Path = self .output_dir / f"{ self .executable_name } .iprof"
172
172
self .config_dir : Path = self .output_dir / "config"
173
173
self .log_dir : Path = self .output_dir
174
+ self .ml_log_dump_path : Path = self .output_dir / f"{ self .executable_name } .ml.log.csv"
174
175
base_image_build_args = ['--no-fallback' , '-g' ]
175
176
base_image_build_args += ['-H:+VerifyGraalGraphs' , '-H:+VerifyPhases' , '--diagnostics-mode' ] if vm .is_gate else []
176
177
base_image_build_args += ['-H:+ReportExceptionStackTraces' ]
@@ -530,6 +531,7 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=
530
531
self .safepoint_sampler = False
531
532
self .profile_inference_feature_extraction = False
532
533
self .force_profile_inference = False
534
+ self .profile_inference_debug = False
533
535
self .analysis_context_sensitivity = None
534
536
self .no_inlining_before_analysis = False
535
537
self .optimization_level = None
@@ -552,7 +554,7 @@ def _configure_from_name(self, config_name):
552
554
# This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config
553
555
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-)?' \
554
556
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-)?$'
556
558
557
559
mx .logv (f"== Registering configuration: { config_name } " )
558
560
match_name = f"{ config_name } -" # adding trailing dash to simplify the regex
@@ -658,6 +660,17 @@ def generate_profiling_package_prefixes():
658
660
self .force_profile_inference = True
659
661
660
662
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
661
674
else :
662
675
mx .abort ('Unknown profile inference configuration: {}.' .format (profile_inference_config ))
663
676
@@ -1165,9 +1178,13 @@ def run_stage_image(self):
1165
1178
ml_args = svm_experimental_options (['-H:+MLGraphFeaturesExtraction' , '-H:+MLProfileInference' ])
1166
1179
else :
1167
1180
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 = []
1168
1185
1169
1186
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
1171
1188
with self .get_stage_runner () as s :
1172
1189
exit_code = s .execute_command (self , final_image_command )
1173
1190
NativeImageVM .move_bundle_output (self .config , self .config .image_path )
0 commit comments