@@ -181,6 +181,7 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
181
181
182
182
# Path to the X.nib bundle file --bundle-apply is specified
183
183
bundle_apply_path = self .get_bundle_path_if_present ()
184
+ self .is_bundle_based = bundle_apply_path is not None
184
185
# Path to the X.output directory if a bundle is created
185
186
# In that case, files generated by Native Image are generated in that folder structure
186
187
bundle_create_path = self .get_bundle_create_path_if_present ()
@@ -197,13 +198,13 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
197
198
198
199
if bundle_create_path :
199
200
self .bundle_output_path = bundle_create_path
200
- elif bundle_apply_path :
201
+ elif self . is_bundle_based :
201
202
bundle_dir = bundle_apply_path .parent
202
203
bundle_name = bundle_apply_path .name
203
204
assert bundle_name .endswith (BUNDLE_EXTENSION ), bundle_name
204
205
self .bundle_output_path = bundle_dir / f"{ bundle_name [:- len (BUNDLE_EXTENSION )]} .output"
205
206
206
- if not bundle_apply_path :
207
+ if not self . is_bundle_based :
207
208
base_image_build_args += self .classpath_arguments
208
209
base_image_build_args += self .modulepath_arguments
209
210
base_image_build_args += self .executable
@@ -258,7 +259,7 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
258
259
# Inform the StagesInfo object about removed stages
259
260
bm_suite .stages_info .setup (removed_stages )
260
261
261
- bundle_args = [f'--bundle-apply={ bundle_apply_path } ' ] if bundle_apply_path else []
262
+ bundle_args = [f'--bundle-apply={ bundle_apply_path } ' ] if self . is_bundle_based else []
262
263
# benchmarks are allowed to use experimental options
263
264
# the bundle might also inject experimental options, but they will be appropriately locked/unlocked.
264
265
self .base_image_build_args = [os .path .join (vm .home (), 'bin' , 'native-image' )] + svm_experimental_options (base_image_build_args ) + bundle_args
@@ -972,7 +973,7 @@ def image_build_general_rules(self, benchmarks):
972
973
973
974
def image_build_analysis_rules (self , benchmarks ):
974
975
return [
975
- AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .is_gate , {
976
+ AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .config . bundle_output_path , self . is_gate , self . config . is_bundle_based , {
976
977
"bench-suite" : self .config .benchmark_suite_name ,
977
978
"benchmark" : benchmarks [0 ],
978
979
"metric.name" : "analysis-stats" ,
@@ -983,7 +984,7 @@ def image_build_analysis_rules(self, benchmarks):
983
984
"metric.iteration" : 0 ,
984
985
"metric.object" : "call-edges" ,
985
986
}, ['total_call_edges' ]),
986
- AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .is_gate , {
987
+ AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .config . bundle_output_path , self . is_gate , self . config . is_bundle_based , {
987
988
"bench-suite" : self .config .benchmark_suite_name ,
988
989
"benchmark" : benchmarks [0 ],
989
990
"metric.name" : "analysis-stats" ,
@@ -994,7 +995,7 @@ def image_build_analysis_rules(self, benchmarks):
994
995
"metric.iteration" : 0 ,
995
996
"metric.object" : "reachable-types" ,
996
997
}, ['total_reachable_types' ]),
997
- AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .is_gate , {
998
+ AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .config . bundle_output_path , self . is_gate , self . config . is_bundle_based , {
998
999
"bench-suite" : self .config .benchmark_suite_name ,
999
1000
"benchmark" : benchmarks [0 ],
1000
1001
"metric.name" : "analysis-stats" ,
@@ -1005,7 +1006,7 @@ def image_build_analysis_rules(self, benchmarks):
1005
1006
"metric.iteration" : 0 ,
1006
1007
"metric.object" : "reachable-methods" ,
1007
1008
}, ['total_reachable_methods' ]),
1008
- AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .is_gate , {
1009
+ AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .config . bundle_output_path , self . is_gate , self . config . is_bundle_based , {
1009
1010
"bench-suite" : self .config .benchmark_suite_name ,
1010
1011
"benchmark" : benchmarks [0 ],
1011
1012
"metric.name" : "analysis-stats" ,
@@ -1016,7 +1017,7 @@ def image_build_analysis_rules(self, benchmarks):
1016
1017
"metric.iteration" : 0 ,
1017
1018
"metric.object" : "reachable-fields" ,
1018
1019
}, ['total_reachable_fields' ]),
1019
- AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .is_gate , {
1020
+ AnalysisReportJsonFileRule (self .config .image_build_reports_directory , self .config . bundle_output_path , self . is_gate , self . config . is_bundle_based , {
1020
1021
"bench-suite" : self .config .benchmark_suite_name ,
1021
1022
"benchmark" : benchmarks [0 ],
1022
1023
"metric.name" : "analysis-stats" ,
@@ -1427,20 +1428,37 @@ class AnalysisReportJsonFileRule(mx_benchmark.JsonStdOutFileRule):
1427
1428
final path of the ``reports`` directory, instead.
1428
1429
"""
1429
1430
1430
- def __init__ (self , report_directory , is_diagnostics_mode , replacement , keys ):
1431
+ def __init__ (self , report_directory , bundle_output_dir , is_diagnostics_mode , is_bundle_based , replacement , keys ):
1431
1432
super ().__init__ (r"^# Printing analysis results stats to: (?P<path>\S+?)$" , "path" , replacement , keys )
1432
1433
self .is_diagnostics_mode = is_diagnostics_mode
1434
+ self .is_bundle_based = is_bundle_based
1433
1435
self .report_directory = report_directory
1436
+ self .bundle_output_dir = bundle_output_dir
1437
+
1438
+ def get_diagnostics_dir_name (self , json_file_path ) -> Path :
1439
+ """Extracts the name of the diagnostics directory, the directory containing the JSON file, from the absolute path of the JSON file."""
1440
+ return Path (json_file_path ).parent .name
1441
+
1442
+ def get_base_search_dir (self , json_file_path ) -> Path :
1443
+ """Returns the absolute path to the directory where we expect to find the JSON file containing analysis results stats.
1444
+
1445
+ DEVELOPER NOTE:
1446
+ Unfortunately, the analysis results JSON file ends up in different locations depending on:
1447
+ - whether the diagnostics mode is enabled (the results end up inside the diagnostics directory)
1448
+ - whether the benchmark is bundle based (the diagnostics directory ends up in the "other" subdirectory of the bundle output directory)
1449
+ """
1450
+ if self .is_diagnostics_mode and self .is_bundle_based :
1451
+ return self .bundle_output_dir / "other" / self .get_diagnostics_dir_name (json_file_path )
1452
+ if self .is_diagnostics_mode :
1453
+ return self .report_directory / self .get_diagnostics_dir_name (json_file_path )
1454
+ return self .report_directory
1434
1455
1435
1456
def getJsonFiles (self , text ):
1436
1457
json_files = super ().getJsonFiles (text )
1437
1458
found_json_files = []
1438
1459
for json_file_path in json_files :
1439
1460
json_file_name = os .path .basename (json_file_path )
1440
- base_search_dir = self .report_directory
1441
- if self .is_diagnostics_mode :
1442
- base_search_dir = os .path .join (base_search_dir , os .path .basename (os .path .dirname (json_file_path )))
1443
- expected_json_file_path = os .path .join (base_search_dir , json_file_name )
1461
+ expected_json_file_path = os .path .join (self .get_base_search_dir (json_file_path ), json_file_name )
1444
1462
if exists (expected_json_file_path ):
1445
1463
found_json_files .append (expected_json_file_path )
1446
1464
else :
0 commit comments