< prev index next >

core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/latency/BiasedLockingRevocationPauseRule.java

Print this page




  54 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
  55 import org.openjdk.jmc.flightrecorder.rules.IRule;
  56 import org.openjdk.jmc.flightrecorder.rules.Result;
  57 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
  58 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
  59 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
  60 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
  61 
  62 public final class BiasedLockingRevocationPauseRule implements IRule {
  63 
  64         public static final TypedPreference<IQuantity> INFO_LIMIT = new TypedPreference<>(
  65                         "vm.biasedrevocationpause.info.limit", //$NON-NLS-1$
  66                         Messages.getString(Messages.BiasedLockingRevocationPauseRule_CONFIG_WARNING_LIMIT),
  67                         Messages.getString(Messages.BiasedLockingRevocationPauseRule_CONFIG_WARNING_LIMIT_LONG),
  68                         UnitLookup.TIMESPAN, UnitLookup.MILLISECOND.quantity(100));
  69 
  70         private static final List<TypedPreference<?>> CONFIG_ATTRIBUTES = Arrays.<TypedPreference<?>> asList(INFO_LIMIT);
  71 
  72         private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
  73                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_OPERATIONS);
  74                 if (eventAvailability == EventAvailability.UNAVAILABLE || eventAvailability == EventAvailability.DISABLED) {
  75                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_OPERATIONS);
  76                 }
  77 
  78                 IItemCollection revocationEvents = items.apply(
  79                                 ItemFilters.and(JdkFilters.VM_OPERATIONS, ItemFilters.matches(JdkAttributes.OPERATION, "RevokeBias"))); //$NON-NLS-1$
  80                 if (!revocationEvents.hasItems()) {
  81                         return new Result(this, 0, Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_OK));
  82                 }
  83                 IQuantity timeSpentRevoking = revocationEvents.hasItems()
  84                                 ? revocationEvents.getAggregate(Aggregators.sum(JfrAttributes.DURATION))
  85                                 : UnitLookup.MILLISECOND.quantity(0);
  86                 double mappedDuration = RulesToolkit.mapExp100Y(timeSpentRevoking.doubleValueIn(UnitLookup.MILLISECOND),
  87                                 valueProvider.getPreferenceValue(INFO_LIMIT).doubleValueIn(UnitLookup.MILLISECOND), 25);
  88                 String shortMessage = MessageFormat.format(
  89                                 Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_MESSAGE),
  90                                 timeSpentRevoking.displayUsing(IDisplayable.AUTO));
  91                 String longMessage = shortMessage;
  92                 if (mappedDuration >= 25) {
  93                         longMessage = longMessage + "<p>" //$NON-NLS-1$
  94                                         + Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_INFO_LONG);




  54 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
  55 import org.openjdk.jmc.flightrecorder.rules.IRule;
  56 import org.openjdk.jmc.flightrecorder.rules.Result;
  57 import org.openjdk.jmc.flightrecorder.rules.jdk.messages.internal.Messages;
  58 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
  59 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
  60 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
  61 
  62 public final class BiasedLockingRevocationPauseRule implements IRule {
  63 
  64         public static final TypedPreference<IQuantity> INFO_LIMIT = new TypedPreference<>(
  65                         "vm.biasedrevocationpause.info.limit", //$NON-NLS-1$
  66                         Messages.getString(Messages.BiasedLockingRevocationPauseRule_CONFIG_WARNING_LIMIT),
  67                         Messages.getString(Messages.BiasedLockingRevocationPauseRule_CONFIG_WARNING_LIMIT_LONG),
  68                         UnitLookup.TIMESPAN, UnitLookup.MILLISECOND.quantity(100));
  69 
  70         private static final List<TypedPreference<?>> CONFIG_ATTRIBUTES = Arrays.<TypedPreference<?>> asList(INFO_LIMIT);
  71 
  72         private Result getResult(IItemCollection items, IPreferenceValueProvider valueProvider) {
  73                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_OPERATIONS);
  74                 if (eventAvailability == EventAvailability.UNKNOWN || eventAvailability == EventAvailability.DISABLED) {
  75                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_OPERATIONS);
  76                 }
  77 
  78                 IItemCollection revocationEvents = items.apply(
  79                                 ItemFilters.and(JdkFilters.VM_OPERATIONS, ItemFilters.matches(JdkAttributes.OPERATION, "RevokeBias"))); //$NON-NLS-1$
  80                 if (!revocationEvents.hasItems()) {
  81                         return new Result(this, 0, Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_OK));
  82                 }
  83                 IQuantity timeSpentRevoking = revocationEvents.hasItems()
  84                                 ? revocationEvents.getAggregate(Aggregators.sum(JfrAttributes.DURATION))
  85                                 : UnitLookup.MILLISECOND.quantity(0);
  86                 double mappedDuration = RulesToolkit.mapExp100Y(timeSpentRevoking.doubleValueIn(UnitLookup.MILLISECOND),
  87                                 valueProvider.getPreferenceValue(INFO_LIMIT).doubleValueIn(UnitLookup.MILLISECOND), 25);
  88                 String shortMessage = MessageFormat.format(
  89                                 Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_MESSAGE),
  90                                 timeSpentRevoking.displayUsing(IDisplayable.AUTO));
  91                 String longMessage = shortMessage;
  92                 if (mappedDuration >= 25) {
  93                         longMessage = longMessage + "<p>" //$NON-NLS-1$
  94                                         + Messages.getString(Messages.BiasedLockingRevocationPauseRule_TEXT_INFO_LONG);


< prev index next >