45 import org.openjdk.jmc.common.unit.UnitLookup;
46 import org.openjdk.jmc.common.util.IPreferenceValueProvider;
47 import org.openjdk.jmc.common.util.TypedPreference;
48 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
49 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
50 import org.openjdk.jmc.flightrecorder.rules.IRule;
51 import org.openjdk.jmc.flightrecorder.rules.Result;
52 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
53 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
54 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
55 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
56
57 public class TlabAllocationRatioRule implements IRule {
58
59 private static final String RESULT_ID = "TlabAllocationRatio"; //$NON-NLS-1$
60
61 private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
62
63 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.ALLOC_INSIDE_TLAB,
64 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
65 if (eventAvailability == EventAvailability.DISABLED || eventAvailability == EventAvailability.UNAVAILABLE) {
66 return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.ALLOC_INSIDE_TLAB,
67 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
68 }
69
70 IQuantity insideSum = items.getAggregate(JdkAggregators.ALLOC_INSIDE_TLAB_SUM);
71 IQuantity outsideSum = items.getAggregate(JdkAggregators.ALLOC_OUTSIDE_TLAB_SUM);
72
73 if (outsideSum == null) {
74 return new Result(this, 0, Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_OK_NO_OUTSIDE));
75 } else if (insideSum == null) {
76 String shortMessage = Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_INFO_ONLY_OUTSIDE);
77 String longMessage = Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_INFO_ONLY_OUTSIDE_LONG)
78 + "<p>" //$NON-NLS-1$
79 + Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_RECOMMEND_LESS_ALLOCATION);
80 return new Result(this, 100, shortMessage, longMessage);
81 }
82
83 IQuantity totalSum = insideSum.add(outsideSum);
84
85 double rawRatio = outsideSum.ratioTo(totalSum);
|
45 import org.openjdk.jmc.common.unit.UnitLookup;
46 import org.openjdk.jmc.common.util.IPreferenceValueProvider;
47 import org.openjdk.jmc.common.util.TypedPreference;
48 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
49 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
50 import org.openjdk.jmc.flightrecorder.rules.IRule;
51 import org.openjdk.jmc.flightrecorder.rules.Result;
52 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
53 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
54 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
55 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
56
57 public class TlabAllocationRatioRule implements IRule {
58
59 private static final String RESULT_ID = "TlabAllocationRatio"; //$NON-NLS-1$
60
61 private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
62
63 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.ALLOC_INSIDE_TLAB,
64 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
65 if (eventAvailability == EventAvailability.DISABLED || eventAvailability == EventAvailability.UNKNOWN) {
66 return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.ALLOC_INSIDE_TLAB,
67 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
68 }
69
70 IQuantity insideSum = items.getAggregate(JdkAggregators.ALLOC_INSIDE_TLAB_SUM);
71 IQuantity outsideSum = items.getAggregate(JdkAggregators.ALLOC_OUTSIDE_TLAB_SUM);
72
73 if (outsideSum == null) {
74 return new Result(this, 0, Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_OK_NO_OUTSIDE));
75 } else if (insideSum == null) {
76 String shortMessage = Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_INFO_ONLY_OUTSIDE);
77 String longMessage = Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_INFO_ONLY_OUTSIDE_LONG)
78 + "<p>" //$NON-NLS-1$
79 + Messages.getString(Messages.TlabAllocationRatioRuleFactory_TEXT_RECOMMEND_LESS_ALLOCATION);
80 return new Result(this, 100, shortMessage, longMessage);
81 }
82
83 IQuantity totalSum = insideSum.add(outsideSum);
84
85 double rawRatio = outsideSum.ratioTo(totalSum);
|