Skip to content

Commit e715aac

Browse files
committed
improve docs and naming around global profiles hotness
1 parent f92a8f6 commit e715aac

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/util/OptimizationUtility.java renamed to compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/util/GlobalProfilesOptimizationUtility.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,51 @@
2828
import jdk.graal.compiler.options.Option;
2929
import jdk.graal.compiler.options.OptionKey;
3030

31-
public class OptimizationUtility {
31+
/**
32+
* Utility class for managing and applying additional optimizer benefits to "super hot" code
33+
* regions.
34+
*
35+
* This class provides methods to identify, evaluate, and process compilation units that demonstrate
36+
* exceptional runtime significance based on global profiling data. Its functions enable the
37+
* optimizer to selectively apply advanced strategies and enhancements to code regions determined to
38+
* be of highest execution criticality, maximizing performance gains where they matter most.
39+
*/
40+
public class GlobalProfilesOptimizationUtility {
3241

3342
public static class Options {
3443
@Option(help = "Minimal self time for a compilation unit to be considered hot globally.")//
3544
public static final OptionKey<Double> HotCodeMinSelfTime = new OptionKey<>(0.001);
3645

3746
}
3847

39-
public static <X> X chooseAdaptiveBudgetFactor(StructuredGraph graph, OptionKey<X> coldOption, OptionKey<X> hotOption) {
40-
return hotGlobalSelfTime(graph) ? hotOption.getValue(graph.getOptions()) : coldOption.getValue(graph.getOptions());
48+
/**
49+
* Selects and returns the appropriate option value for the specified compilation unit based on
50+
* its optimization significance. If the provided {@link StructuredGraph} is determined to merit
51+
* prioritization for optimization - such as exhibiting high runtime significance or profiling
52+
* "hotness" - the {@code hotOption} value is returned. Otherwise, the {@code coldOption} value
53+
* is chosen. This selection allows the optimizer to allocate additional resources beyond
54+
* regular hotness to a compilation unit.
55+
*/
56+
public static <X> X selectOptionBySignificance(StructuredGraph graph, OptionKey<X> coldOption, OptionKey<X> hotOption) {
57+
return shouldPrioritizeForOptimization(graph) ? hotOption.getValue(graph.getOptions()) : coldOption.getValue(graph.getOptions());
4158
}
4259

43-
public static <X> X chooseAdaptiveBudgetFactor(StructuredGraph graph, X coldValue, OptionKey<X> hotOption) {
44-
return hotGlobalSelfTime(graph) ? hotOption.getValue(graph.getOptions()) : coldValue;
60+
public static <X> X selectOptionBySignificance(StructuredGraph graph, X coldValue, OptionKey<X> hotOption) {
61+
return shouldPrioritizeForOptimization(graph) ? hotOption.getValue(graph.getOptions()) : coldValue;
4562
}
4663

47-
public static <X> X chooseAdaptiveBudgetFactor(StructuredGraph graph, X coldValue, X hotValue) {
48-
return hotGlobalSelfTime(graph) ? hotValue : coldValue;
64+
public static <X> X selectOptionBySignificance(StructuredGraph graph, X coldValue, X hotValue) {
65+
return shouldPrioritizeForOptimization(graph) ? hotValue : coldValue;
4966
}
5067

5168
/**
52-
* Determine if the given graph should be considered "hot" for optimization purposes. We define
53-
* "hot" by inspecting its self time with respect to overall execution time. This is a purely
54-
* heuristical value.
69+
* Determines if the specified graph merits prioritization for optimization. This method
70+
* evaluates the compilation unit's significance-based on heuristics such as self time relative
71+
* to overall execution - to decide whether it should receive additional optimizer benefits.
72+
* This assessment is heuristic and intended to guide the allocation of extra optimization
73+
* resources.
5574
*/
56-
public static boolean hotGlobalSelfTime(StructuredGraph graph) {
75+
public static boolean shouldPrioritizeForOptimization(StructuredGraph graph) {
5776
final double globalSelfTimePercent = graph.globalProfileProvider().getGlobalSelfTimePercent();
5877
if (globalSelfTimePercent == StructuredGraph.GlobalProfileProvider.GLOBAL_PROFILE_PROVIDER_DISABLED) {
5978
// We are in a mode where there is no self time data available. In JIT all compilation

0 commit comments

Comments
 (0)