|
28 | 28 | import jdk.graal.compiler.options.Option;
|
29 | 29 | import jdk.graal.compiler.options.OptionKey;
|
30 | 30 |
|
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 { |
32 | 41 |
|
33 | 42 | public static class Options {
|
34 | 43 | @Option(help = "Minimal self time for a compilation unit to be considered hot globally.")//
|
35 | 44 | public static final OptionKey<Double> HotCodeMinSelfTime = new OptionKey<>(0.001);
|
36 | 45 |
|
37 | 46 | }
|
38 | 47 |
|
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()); |
41 | 58 | }
|
42 | 59 |
|
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; |
45 | 62 | }
|
46 | 63 |
|
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; |
49 | 66 | }
|
50 | 67 |
|
51 | 68 | /**
|
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. |
55 | 74 | */
|
56 |
| - public static boolean hotGlobalSelfTime(StructuredGraph graph) { |
| 75 | + public static boolean shouldPrioritizeForOptimization(StructuredGraph graph) { |
57 | 76 | final double globalSelfTimePercent = graph.globalProfileProvider().getGlobalSelfTimePercent();
|
58 | 77 | if (globalSelfTimePercent == StructuredGraph.GlobalProfileProvider.GLOBAL_PROFILE_PROVIDER_DISABLED) {
|
59 | 78 | // We are in a mode where there is no self time data available. In JIT all compilation
|
|
0 commit comments