< prev index next >

core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/memory/AllocationByClassRule.java

Print this page




  57 import org.openjdk.jmc.flightrecorder.rules.jdk.dataproviders.StacktraceDataProvider;
  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 import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator;
  63 import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator.FrameCategorization;
  64 import org.openjdk.jmc.flightrecorder.stacktrace.StacktraceModel;
  65 import org.openjdk.jmc.flightrecorder.stacktrace.StacktraceModel.Fork;
  66 import org.owasp.encoder.Encode;
  67 
  68 public class AllocationByClassRule implements IRule {
  69         private static final String CLASS_RESULT_ID = "Allocations.class"; //$NON-NLS-1$
  70 
  71         private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
  72                 EventAvailability eventAvailabilityInside = RulesToolkit.getEventAvailability(items,
  73                                 JdkTypeIDs.ALLOC_INSIDE_TLAB);
  74                 EventAvailability eventAvailabilityOutside = RulesToolkit.getEventAvailability(items,
  75                                 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
  76                 if (!RulesToolkit.isEventsEnabled(eventAvailabilityInside, eventAvailabilityOutside)) {
  77                         return RulesToolkit.getNotApplicableResult(this,
  78                                         MessageFormat.format(Messages.getString(Messages.General_RULE_REQUIRES_ALL_EVENT_TYPES_ENABLED),
  79                                                         JdkTypeIDs.ALLOC_INSIDE_TLAB + "," + JdkTypeIDs.ALLOC_OUTSIDE_TLAB));
  80                 }
  81                 if (!(eventAvailabilityInside == EventAvailability.AVAILABLE
  82                                 || eventAvailabilityOutside == EventAvailability.AVAILABLE)) {
  83                         return RulesToolkit.getNotApplicableResult(this,
  84                                         MessageFormat.format(Messages.getString(Messages.General_RULE_REQUIRES_EVENTS_FROM_ONE_OF_MANY),
  85                                                         JdkTypeIDs.ALLOC_INSIDE_TLAB + ", " + JdkTypeIDs.ALLOC_OUTSIDE_TLAB));
  86                 }
  87 
  88                 List<IntEntry<IMCType>> entries = RulesToolkit.calculateGroupingScore(items.apply(JdkFilters.ALLOC_ALL),
  89                                 JdkAttributes.ALLOCATION_CLASS);
  90 
  91                 double balance = RulesToolkit.calculateBalanceScore(entries);
  92                 IntEntry<IMCType> mostSignificant = entries.get(entries.size() - 1);
  93                 // FIXME: Configuration attribute instead of hard coded 1000 tlabs => relevance 50
  94                 double relevance = RulesToolkit.mapExp100Y(mostSignificant.getValue(), 1000, 50);
  95                 double score = balance * relevance * 0.74; // ceiling at 74;
  96 
  97                 IItemFilter significantFilter = ItemFilters.and(JdkFilters.ALLOC_ALL,
  98                                 ItemFilters.equals(JdkAttributes.ALLOCATION_CLASS, mostSignificant.getKey()));
  99                 StacktraceModel stacktraceModel = new StacktraceModel(false,




  57 import org.openjdk.jmc.flightrecorder.rules.jdk.dataproviders.StacktraceDataProvider;
  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 import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator;
  63 import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator.FrameCategorization;
  64 import org.openjdk.jmc.flightrecorder.stacktrace.StacktraceModel;
  65 import org.openjdk.jmc.flightrecorder.stacktrace.StacktraceModel.Fork;
  66 import org.owasp.encoder.Encode;
  67 
  68 public class AllocationByClassRule implements IRule {
  69         private static final String CLASS_RESULT_ID = "Allocations.class"; //$NON-NLS-1$
  70 
  71         private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
  72                 EventAvailability eventAvailabilityInside = RulesToolkit.getEventAvailability(items,
  73                                 JdkTypeIDs.ALLOC_INSIDE_TLAB);
  74                 EventAvailability eventAvailabilityOutside = RulesToolkit.getEventAvailability(items,
  75                                 JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
  76                 if (!RulesToolkit.isEventsEnabled(eventAvailabilityInside, eventAvailabilityOutside)) {
  77                         return RulesToolkit.getEventAvailabilityResult(this, items,
  78                                         RulesToolkit.getLeastAvailable(eventAvailabilityInside, eventAvailabilityOutside),
  79                                         JdkTypeIDs.ALLOC_INSIDE_TLAB, JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
  80                 }
  81                 if (!(eventAvailabilityInside == EventAvailability.AVAILABLE
  82                                 || eventAvailabilityOutside == EventAvailability.AVAILABLE)) {
  83                         return RulesToolkit.getNotApplicableResult(this,
  84                                         MessageFormat.format(Messages.getString(Messages.General_RULE_REQUIRES_EVENTS_FROM_ONE_OF_MANY),
  85                                                         JdkTypeIDs.ALLOC_INSIDE_TLAB + ", " + JdkTypeIDs.ALLOC_OUTSIDE_TLAB));
  86                 }
  87 
  88                 List<IntEntry<IMCType>> entries = RulesToolkit.calculateGroupingScore(items.apply(JdkFilters.ALLOC_ALL),
  89                                 JdkAttributes.ALLOCATION_CLASS);
  90 
  91                 double balance = RulesToolkit.calculateBalanceScore(entries);
  92                 IntEntry<IMCType> mostSignificant = entries.get(entries.size() - 1);
  93                 // FIXME: Configuration attribute instead of hard coded 1000 tlabs => relevance 50
  94                 double relevance = RulesToolkit.mapExp100Y(mostSignificant.getValue(), 1000, 50);
  95                 double score = balance * relevance * 0.74; // ceiling at 74;
  96 
  97                 IItemFilter significantFilter = ItemFilters.and(JdkFilters.ALLOC_ALL,
  98                                 ItemFilters.equals(JdkAttributes.ALLOCATION_CLASS, mostSignificant.getKey()));
  99                 StacktraceModel stacktraceModel = new StacktraceModel(false,


< prev index next >