49 import org.openjdk.jmc.common.util.IPreferenceValueProvider;
50 import org.openjdk.jmc.common.util.TypedPreference;
51 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
52 import org.openjdk.jmc.flightrecorder.jdk.JdkQueries;
53 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
54 import org.openjdk.jmc.flightrecorder.rules.IRule;
55 import org.openjdk.jmc.flightrecorder.rules.Result;
56 import org.openjdk.jmc.flightrecorder.rules.jdk.combine.SpanSquare;
57 import org.openjdk.jmc.flightrecorder.rules.jdk.combine.SpanToolkit;
58 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
59 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
60 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
61 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
62
63 public class HighGcRule implements IRule {
64
65 private static final String RESULT_ID = "HighGc"; //$NON-NLS-1$
66
67 private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
68 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.GC_PAUSE);
69 if (eventAvailability == EventAvailability.UNAVAILABLE || eventAvailability == EventAvailability.DISABLED) {
70 return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.GC_PAUSE);
71 }
72
73 SpanSquare longestGcCluster = calculateLongestGcCluster(items.apply(JdkFilters.GC_PAUSE));
74 if (longestGcCluster != null) {
75 long sumPauseNanos = longestGcCluster.mass;
76 long durationNanos = longestGcCluster.end - longestGcCluster.start;
77 IQuantity pausePercent = UnitLookup.PERCENT_UNITY.quantity(sumPauseNanos / (double) durationNanos);
78 // FIXME: Configuration attribute instead of hard coded 1 second => score 90
79 // FIXME: Also consider duration length when calculating score?
80 double score = RulesToolkit.mapExp100Y(sumPauseNanos, 1e9, 90);
81 // int score = longestGcCluster == null ? 0 : (int) (longestGcCluster.mass / 10000000); // 1 s => 100 p
82 String startTime = KindOfQuantity.format(longestGcCluster.start, EPOCH_NS);
83 String duration = KindOfQuantity.format(durationNanos, UnitLookup.NANOSECOND);
84 String message = MessageFormat.format(Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO), duration,
85 startTime, pausePercent.displayUsing(IDisplayable.AUTO));
86 String longMessage = message + " " + Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO_LONG); //$NON-NLS-1$
87 if (!RulesToolkit.isEventsEnabled(items, JdkTypeIDs.ALLOC_INSIDE_TLAB, JdkTypeIDs.ALLOC_OUTSIDE_TLAB)) {
88 longMessage = longMessage + "<p>" //$NON-NLS-1$
89 + Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO_LONG_ALLOC_DISABLED);
|
49 import org.openjdk.jmc.common.util.IPreferenceValueProvider;
50 import org.openjdk.jmc.common.util.TypedPreference;
51 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
52 import org.openjdk.jmc.flightrecorder.jdk.JdkQueries;
53 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
54 import org.openjdk.jmc.flightrecorder.rules.IRule;
55 import org.openjdk.jmc.flightrecorder.rules.Result;
56 import org.openjdk.jmc.flightrecorder.rules.jdk.combine.SpanSquare;
57 import org.openjdk.jmc.flightrecorder.rules.jdk.combine.SpanToolkit;
58 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
59 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
60 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
61 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
62
63 public class HighGcRule implements IRule {
64
65 private static final String RESULT_ID = "HighGc"; //$NON-NLS-1$
66
67 private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
68 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.GC_PAUSE);
69 if (eventAvailability == EventAvailability.UNKNOWN || eventAvailability == EventAvailability.DISABLED) {
70 return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.GC_PAUSE);
71 }
72
73 SpanSquare longestGcCluster = calculateLongestGcCluster(items.apply(JdkFilters.GC_PAUSE));
74 if (longestGcCluster != null) {
75 long sumPauseNanos = longestGcCluster.mass;
76 long durationNanos = longestGcCluster.end - longestGcCluster.start;
77 IQuantity pausePercent = UnitLookup.PERCENT_UNITY.quantity(sumPauseNanos / (double) durationNanos);
78 // FIXME: Configuration attribute instead of hard coded 1 second => score 90
79 // FIXME: Also consider duration length when calculating score?
80 double score = RulesToolkit.mapExp100Y(sumPauseNanos, 1e9, 90);
81 // int score = longestGcCluster == null ? 0 : (int) (longestGcCluster.mass / 10000000); // 1 s => 100 p
82 String startTime = KindOfQuantity.format(longestGcCluster.start, EPOCH_NS);
83 String duration = KindOfQuantity.format(durationNanos, UnitLookup.NANOSECOND);
84 String message = MessageFormat.format(Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO), duration,
85 startTime, pausePercent.displayUsing(IDisplayable.AUTO));
86 String longMessage = message + " " + Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO_LONG); //$NON-NLS-1$
87 if (!RulesToolkit.isEventsEnabled(items, JdkTypeIDs.ALLOC_INSIDE_TLAB, JdkTypeIDs.ALLOC_OUTSIDE_TLAB)) {
88 longMessage = longMessage + "<p>" //$NON-NLS-1$
89 + Messages.getString(Messages.HighGcRuleFactory_TEXT_INFO_LONG_ALLOC_DISABLED);
|