Skip to content

Commit 73d2fc7

Browse files
committed
[GR-41069] Revert "[GR-28461] Partially Collect Profiles in NI CE"
PullRequest: graal/12679
2 parents 92667d4 + 194172d commit 73d2fc7

File tree

6 files changed

+17
-70
lines changed

6 files changed

+17
-70
lines changed

graal-common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"README": "This file contains definitions that are useful for the hocon and jsonnet CI files of the graal and graal-enterprise repositories.",
33
"ci": {
4-
"overlay": "7fe3eba6396a9b4babac6171e7d2fb95da4dc65c"
4+
"overlay": "b84cafb1bb9555b3b13443815280c85df77cfc75"
55
},
66

77
"mx_version" : "6.9.1"

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ private static void generateFilterRules(Iterator<String> argsIter) throws IOExce
484484
exportedInclusion = ConfigurationFilter.Inclusion.Include;
485485
unexportedInclusion = ConfigurationFilter.Inclusion.Exclude;
486486
}
487-
filter.setHierarchyFilterNode(ModuleFilterTools.generateFromModules(moduleNames, rootInclusion, exportedInclusion, unexportedInclusion, reduce));
487+
rootNode = ModuleFilterTools.generateFromModules(moduleNames, rootInclusion, exportedInclusion, unexportedInclusion, reduce);
488488
} else {
489489
throw new UsageException(current + " is currently not supported in the native-image build of this tool.");
490490
}
@@ -501,20 +501,20 @@ private static void generateFilterRules(Iterator<String> argsIter) throws IOExce
501501

502502
case "--include-classes":
503503
filterModified = true;
504-
addSingleRule(filter.getHierarchyFilterNode(), current, value, ConfigurationFilter.Inclusion.Include);
504+
addSingleRule(rootNode, current, value, ConfigurationFilter.Inclusion.Include);
505505
break;
506506

507507
case "--exclude-classes":
508508
filterModified = true;
509-
addSingleRule(filter.getHierarchyFilterNode(), current, value, ConfigurationFilter.Inclusion.Exclude);
509+
addSingleRule(rootNode, current, value, ConfigurationFilter.Inclusion.Exclude);
510510
break;
511511

512512
default:
513513
throw new UsageException("Unknown argument: " + current);
514514
}
515515
}
516516

517-
filter.getHierarchyFilterNode().removeRedundantNodes();
517+
rootNode.removeRedundantNodes();
518518
if (outputPath != null) {
519519
try (FileOutputStream os = new FileOutputStream(outputPath.toFile())) {
520520
printFilterToStream(filter, os);

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/ComplexFilter.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.util.Map;
3131

3232
public class ComplexFilter implements ConfigurationFilter {
33-
private HierarchyFilterNode hierarchyFilterNode;
33+
private final HierarchyFilterNode hierarchyFilterNode;
3434
private final RegexFilter regexFilter = new RegexFilter();
3535

3636
public ComplexFilter(HierarchyFilterNode hierarchyFilterNode) {
@@ -42,7 +42,6 @@ public void printJson(JsonWriter writer) throws IOException {
4242
writer.append('{');
4343
writer.indent().newline();
4444
hierarchyFilterNode.printJson(writer);
45-
writer.append(",\n").newline();
4645
regexFilter.printJson(writer);
4746
writer.unindent().newline();
4847
writer.append('}').newline();
@@ -62,8 +61,4 @@ public boolean includes(String qualifiedName) {
6261
public HierarchyFilterNode getHierarchyFilterNode() {
6362
return hierarchyFilterNode;
6463
}
65-
66-
public void setHierarchyFilterNode(HierarchyFilterNode hierarchyFilterNode) {
67-
this.hierarchyFilterNode = hierarchyFilterNode;
68-
}
6964
}

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/RegexFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public void printJson(JsonWriter writer) throws IOException {
5858

5959
writer.unindent().newline();
6060
writer.append("]");
61+
writer.unindent().newline();
62+
writer.append("}");
6163
}
6264

6365
@SuppressWarnings({"rawtypes", "unchecked"})

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompileQueue.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ public interface CompileFunction {
227227

228228
private SnippetReflectionProvider snippetReflection;
229229
private final FeatureHandler featureHandler;
230+
protected final OptionValues compileOptions;
230231
protected final GlobalMetrics metricValues = new GlobalMetrics();
231232

232233
private volatile boolean inliningProgress;
@@ -402,6 +403,7 @@ public CompileQueue(DebugContext debug, FeatureHandler featureHandler, HostedUni
402403
this.executor = new CompletionExecutor(universe.getBigBang(), executorService, universe.getBigBang().getHeartbeatCallback());
403404
this.featureHandler = featureHandler;
404405
this.snippetReflection = snippetReflection;
406+
this.compileOptions = getCustomizedOptions(debug);
405407

406408
callForReplacements(debug, runtimeConfig);
407409
}
@@ -465,6 +467,7 @@ public void finish(DebugContext debug) {
465467
if (ImageSingletons.contains(HostedHeapDumpFeature.class)) {
466468
ImageSingletons.lookup(HostedHeapDumpFeature.class).compileQueueAfterCompilation();
467469
}
470+
metricValues.print(compileOptions);
468471
}
469472

470473
private boolean suitesNotCreated() {
@@ -871,7 +874,6 @@ private StructuredGraph transplantGraph(DebugContext debug, HostedMethod hMethod
871874
* The static analysis always needs NodeSourcePosition. But for AOT compilation, we only
872875
* need to preserve them when explicitly enabled, to reduce memory pressure.
873876
*/
874-
OptionValues compileOptions = getCustomizedOptions(hMethod, debug);
875877
boolean trackNodeSourcePosition = GraalOptions.TrackNodeSourcePosition.getValue(compileOptions);
876878
StructuredGraph graph = aGraph.copy(universe.lookup(aGraph.method()), compileOptions, debug, trackNodeSourcePosition);
877879

@@ -1119,7 +1121,7 @@ private void defaultParseFunction(DebugContext debug, HostedMethod method, Compi
11191121
Bytecode code = new ResolvedJavaMethodBytecode(method);
11201122
// DebugContext debug = new DebugContext(options,
11211123
// providers.getSnippetReflection());
1122-
graph = new SubstrateIntrinsicGraphBuilder(getCustomizedOptions(method, debug), debug, providers,
1124+
graph = new SubstrateIntrinsicGraphBuilder(compileOptions, debug, providers,
11231125
code).buildGraph(plugin);
11241126
}
11251127
}
@@ -1129,7 +1131,7 @@ private void defaultParseFunction(DebugContext debug, HostedMethod method, Compi
11291131
}
11301132
if (graph == null) {
11311133
needParsing = true;
1132-
graph = new StructuredGraph.Builder(getCustomizedOptions(method, debug), debug)
1134+
graph = new StructuredGraph.Builder(compileOptions, debug)
11331135
.method(method)
11341136
.recordInlinedMethods(false)
11351137
.build();
@@ -1176,7 +1178,7 @@ private void defaultParseFunction(DebugContext debug, HostedMethod method, Compi
11761178
beforeEncode(method, graph);
11771179
assert GraphOrder.assertSchedulableGraph(graph);
11781180
method.compilationInfo.encodeGraph(graph);
1179-
method.compilationInfo.setCompileOptions(getCustomizedOptions(method, debug));
1181+
method.compilationInfo.setCompileOptions(compileOptions);
11801182
checkTrivial(method, graph);
11811183

11821184
} catch (Throwable ex) {
@@ -1218,7 +1220,7 @@ private void ensureParsed(HostedMethod method, CompileReason reason, CallTargetN
12181220
protected void beforeEncode(HostedMethod method, StructuredGraph graph) {
12191221
}
12201222

1221-
protected OptionValues getCustomizedOptions(@SuppressWarnings("unused") HostedMethod method, DebugContext debug) {
1223+
protected OptionValues getCustomizedOptions(DebugContext debug) {
12221224
return debug.getOptions();
12231225
}
12241226

vm/mx.vm/mx_vm_benchmark.py

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
# ----------------------------------------------------------------------------------------------------
2828
import os
2929
import re
30-
import tempfile
31-
import json
32-
from genericpath import exists
3330
from os.path import basename, dirname, getsize, join
3431
from traceback import print_tb
3532
import inspect
@@ -149,10 +146,6 @@ def __init__(self, vm, bm_suite, args):
149146
'extra-agent-profile-run-arg', 'benchmark-output-dir', 'stages', 'skip-agent-assertions']
150147
self.profile_file_extension = '.iprof'
151148
self.stages = bm_suite.stages(args)
152-
if vm.jdk_profiles_collect: # forbid image build/run in the profile collection execution mode
153-
for stage in ('image', 'run'):
154-
if stage in self.stages:
155-
self.stages.remove(stage)
156149
self.last_stage = self.stages[-1]
157150
self.skip_agent_assertions = bm_suite.skip_agent_assertions(self.benchmark_name, args)
158151
self.root_dir = self.benchmark_output_dir if self.benchmark_output_dir else mx.suite('vm').get_output_root(platformDependent=False, jdkDependent=False)
@@ -218,8 +211,6 @@ def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=
218211
self.config = None
219212
self.stages = None
220213
self.ml = None
221-
self.jdk_profiles_collect = False
222-
self.cached_jdk_pgo = False
223214
self.analysis_context_sensitivity = None
224215
self.no_inlining_before_analysis = False
225216
self._configure_from_name(config_name)
@@ -240,7 +231,7 @@ def _configure_from_name(self, config_name):
240231

241232
# This defines the allowed config names for NativeImageVM. The ones registered will be available via --jvm-config
242233
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-)?(?P<inliner>aot-inline-|iterative-|inline-explored-)?' \
243-
r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<ml>ml-profile-inference-)?(?P<jdk_profiles>jdk-profiles-collect-|cached-jdk-pgo-)?(?P<edition>ce-|ee-)?$'
234+
r'(?P<analysis_context_sensitivity>insens-|allocsens-|1obj-|2obj1h-|3obj2h-|4obj3h-)?(?P<no_inlining_before_analysis>no-inline-)?(?P<ml>ml-profile-inference-)?(?P<edition>ce-|ee-)?$'
244235

245236
mx.logv("== Registering configuration: {}".format(config_name))
246237
match_name = "{}-".format(config_name) # adding trailing dash to simplify the regex
@@ -311,42 +302,6 @@ def _configure_from_name(self, config_name):
311302
if matching.group("ml") is not None:
312303
self.ml = matching.group("ml")[:-1]
313304

314-
if matching.group("jdk_profiles") is not None:
315-
config = matching.group("jdk_profiles")[:-1]
316-
if config == 'jdk-profiles-collect':
317-
self.jdk_profiles_collect = True
318-
self.pgo_instrumented_iterations = 1
319-
320-
def generate_profiling_package_prefixes():
321-
# run the native-image-configure tool to gather the jdk package prefixes
322-
native_image_configure_command = mx.cmd_suffix(join(mx_sdk_vm.graalvm_home(), 'bin', 'native-image-configure'))
323-
if not exists(native_image_configure_command):
324-
mx.abort('Failed to find the native-image-configure command at {}.'.format(native_image_configure_command))
325-
tmp = tempfile.NamedTemporaryFile()
326-
ret = mx.run([native_image_configure_command, 'generate-filters',
327-
'--include-packages-from-modules=java.base',
328-
'--exclude-classes=org.graalvm.**', '--exclude-classes=com.oracle.**', # remove internal packages
329-
'--output-file={}'.format(tmp.name)], nonZeroIsFatal=True)
330-
if ret != 0:
331-
mx.abort('Native image configure command failed.')
332-
333-
# format the profiling package prefixes
334-
with open(tmp.name, 'r') as f:
335-
prefixes = json.loads(f.read())
336-
if 'rules' not in prefixes:
337-
mx.abort('Native image configure command failed. Can not generate rules.')
338-
rules = prefixes['rules']
339-
rules = map(lambda r: r['includeClasses'][:-2], filter(lambda r: 'includeClasses' in r, rules))
340-
return ','.join(rules)
341-
self.generate_profiling_package_prefixes = generate_profiling_package_prefixes
342-
elif config == 'cached-jdk-pgo':
343-
self.cached_jdk_pgo = True
344-
else:
345-
mx.abort('Unknown jdk profiles configuration: {}'.format(config))
346-
# choose appropriate profiles
347-
jdk_profiles = 'JDK{}_PROFILES'.format(str(mx.get_jdk().version).split('.')[0])
348-
self.cached_profiles_base_dir = mx.library(jdk_profiles).get_path(True)
349-
350305
if matching.group("edition") is not None:
351306
edition = matching.group("edition")[:-1]
352307
mx.logv("GraalVM edition is set to: {}".format(edition))
@@ -818,8 +773,6 @@ def run_stage_instrument_image(self, config, stages, out, i, instrumentation_ima
818773
pgo_args += ['-H:' + ('+' if self.pgo_context_sensitive else '-') + 'PGOContextSensitivityEnabled']
819774
pgo_args += ['-H:+AOTInliner'] if self.pgo_aot_inline else ['-H:-AOTInliner']
820775
instrument_args = ['--pgo-instrument'] + ([] if i == 0 else pgo_args)
821-
if self.jdk_profiles_collect:
822-
instrument_args += ['-H:+ProfilingEnabled', '-H:+AOTPriorityInline', '-H:ProfilingPackagePrefixes={}'.format(self.generate_profiling_package_prefixes())]
823776

824777
with stages.set_command(config.base_image_build_args + executable_name_args + instrument_args) as s:
825778
s.execute_command()
@@ -844,12 +797,7 @@ def run_stage_image(self, config, stages):
844797
pgo_args += ['-H:+AOTInliner'] if self.pgo_aot_inline else ['-H:-AOTInliner']
845798
instrumented_iterations = self.pgo_instrumented_iterations if config.pgo_iteration_num is None else int(config.pgo_iteration_num)
846799
ml_args = ['-H:+ProfileInference'] if self.ml == 'ml-profile-inference' else []
847-
if self.cached_jdk_pgo:
848-
cached_profiles = ','.join(list(map(lambda f: os.path.join(self.cached_profiles_base_dir, f), os.listdir(self.cached_profiles_base_dir))))
849-
jdk_profiles_args = ['-H:CachedPGOEnabled={}'.format(cached_profiles)]
850-
else:
851-
jdk_profiles_args = []
852-
final_image_command = config.base_image_build_args + executable_name_args + (pgo_args if instrumented_iterations > 0 else []) + ml_args + jdk_profiles_args
800+
final_image_command = config.base_image_build_args + executable_name_args + (pgo_args if instrumented_iterations > 0 else []) + ml_args
853801
with stages.set_command(final_image_command) as s:
854802
s.execute_command()
855803
if self.use_upx:

0 commit comments

Comments
 (0)