Skip to content

Commit

Permalink
7201: JdkAttributes.OS_SWITCH_RATE does not work consistently across …
Browse files Browse the repository at this point in the history
…JFRs from different JDK versions.

Reviewed-by: hirt
  • Loading branch information
Suchita Chaturvedi committed May 11, 2021
1 parent d708be3 commit af9df26
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,7 @@ public String getMember(U i) {
public static final IAttribute<IMCThread> MONITOR_PREVIOUS_OWNER = attr("previousOwner", //$NON-NLS-1$
Messages.getString(Messages.ATTR_MONITOR_PREVIOUS_OWNER), THREAD);

public static final IAttribute<IQuantity> OS_SWITCH_RATE = attr("switchRate", //$NON-NLS-1$
Messages.getString(Messages.ATTR_OS_SWITCH_RATE), NUMBER);
public static IAttribute<IQuantity> OS_SWITCH_RATE;
public static final IAttribute<String> REFERENCE_STATISTICS_TYPE = attr("type", //$NON-NLS-1$
Messages.getString(Messages.ATTR_REFERENCE_STATISTICS_TYPE), PLAIN_TEXT);
public static final IAttribute<IQuantity> REFERENCE_STATISTICS_COUNT = attr("count", //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Messages {
public static final String SyntheticAttributeExtension_EXECUTION_SAMPLES_STACKTRACE = "SyntheticAttributeExtension_EXECUTION_SAMPLES_STACKTRACE"; //$NON-NLS-1$
public static final String SyntheticAttributeExtension_EXECUTION_SAMPLES_THREAD = "SyntheticAttributeExtension_EXECUTION_SAMPLES_THREAD"; //$NON-NLS-1$
public static final String SyntheticAttributeExtension_REC_SETTING_EVENT_ID_ATTRIBUTE = "SyntheticAttributeExtension_REC_SETTING_EVENT_ID_ATTRIBUTE"; //$NON-NLS-1$
public static final String SyntheticAttributeExtension_ATTR_OS_SWITCH_RATE = "SyntheticAttributeExtension_ATTR_OS_SWITCH_RATE"; //$NON-NLS-1$

private Messages() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public final class OracleJdkTypeIDsPre11 {
private final static String VM_OPERATIONS = JVM_EVENT_ID_ROOT + "vm/runtime/execute_vm_operation";

private final static String THREAD_STATISTICS = JVM_EVENT_ID_ROOT + "java/statistics/threads";
private final static String CONTEXT_SWITCH_RATE = JVM_EVENT_ID_ROOT + "os/processor/context_switch_rate";
final static String CONTEXT_SWITCH_RATE = JVM_EVENT_ID_ROOT + "os/processor/context_switch_rate";

private final static String COMPILER_CONFIG = JVM_EVENT_ID_ROOT + "vm/compiler/config";
private final static String CODE_CACHE_CONFIG = JVM_EVENT_ID_ROOT + "vm/code_cache/config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class SyntheticAttributeExtension implements IParserExtension {
static final IAttribute<LabeledIdentifier> REC_SETTING_EVENT_ID_ATTRIBUTE = attr("id", //$NON-NLS-1$
Messages.getString(Messages.SyntheticAttributeExtension_REC_SETTING_EVENT_ID_ATTRIBUTE),
UnitLookup.LABELED_IDENTIFIER);
private static final String SWITCH_RATE = "switchRate";

@Override
public IEventSinkFactory getEventSinkFactory(final IEventSinkFactory sf) {
Expand Down Expand Up @@ -187,6 +188,17 @@ public String getValueInterpretation(String eventTypeId, String fieldId) {
|| OracleJdkTypeIDsPre11.JDK9_RECORDING_SETTING.equals(eventTypeId)
|| JdkTypeIDs.RECORDING_SETTING.equals(eventTypeId))) {
return JfrInternalConstants.TYPE_IDENTIFIER_VALUE_INTERPRETATION;
} else if (SWITCH_RATE.equals(fieldId)) {
if (eventTypeId.equalsIgnoreCase("jdk.ThreadContextSwitchRate")) {
JdkAttributes.OS_SWITCH_RATE = attr("switchRate", //$NON-NLS-1$
Messages.getString(Messages.SyntheticAttributeExtension_ATTR_OS_SWITCH_RATE),
UnitLookup.FREQUENCY);

} else if (OracleJdkTypeIDsPre11.CONTEXT_SWITCH_RATE.equals(eventTypeId)) {
JdkAttributes.OS_SWITCH_RATE = attr("switchRate", //$NON-NLS-1$
Messages.getString(Messages.SyntheticAttributeExtension_ATTR_OS_SWITCH_RATE),
UnitLookup.NUMBER);
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ SyntheticAttributeExtension_ALLOC_STATISTICS_THREAD=Thread
SyntheticAttributeExtension_EXECUTION_SAMPLES_STACKTRACE=Stack Trace
SyntheticAttributeExtension_EXECUTION_SAMPLES_THREAD=Sampled Thread
SyntheticAttributeExtension_REC_SETTING_EVENT_ID_ATTRIBUTE=Event Id
SyntheticAttributeExtension_ATTR_OS_SWITCH_RATE=Context Switch Rate

0 comments on commit af9df26

Please sign in to comment.