Skip to content

5705: Explain metaspace in rule results #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.openjdk.jmc.common.item.IItemIterable;
import org.openjdk.jmc.common.item.IMemberAccessor;
import org.openjdk.jmc.common.item.ItemFilters;
import org.openjdk.jmc.common.unit.BinaryPrefix;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.UnitLookup;
import org.openjdk.jmc.common.util.IPreferenceValueProvider;
Expand Down Expand Up @@ -74,29 +75,36 @@ public class IncreasingMetaspaceLiveSetRule implements IRule {
private static final Map<String, EventAvailability> REQUIRED_EVENTS = RequiredEventsBuilder.create()
.addEventType(JdkTypeIDs.METASPACE_SUMMARY, EventAvailability.ENABLED).build();

public static final TypedResult<IQuantity> METASPACE_LIVESET_INCREASE = new TypedResult<>(
"metaspaceLivesetIncrease", //$NON-NLS-1$
"Metaspace Liveset Increase", "The speed of the metaspace liveset increase per second.", UnitLookup.MEMORY,
IQuantity.class);

private static final Collection<TypedResult<?>> RESULT_ATTRIBUTES = Arrays
.<TypedResult<?>> asList(TypedResult.SCORE);
.<TypedResult<?>> asList(TypedResult.SCORE, METASPACE_LIVESET_INCREASE);

private IResult getResult(
IItemCollection items, IPreferenceValueProvider valueProvider, IResultValueProvider resultProvider) {
IItemFilter afterFilter = ItemFilters.and(JdkFilters.METASPACE_SUMMARY_AFTER_GC, JdkFilters.AFTER_GC);
Iterator<? extends IItemIterable> allAfterItems = items.apply(afterFilter).iterator();
IQuantity metaspaceLiveSetIncreasePerSecond = UnitLookup.MEMORY.getUnit(BinaryPrefix.MEBI).quantity(0);
if (allAfterItems.hasNext()) {
IItemIterable afterItems = allAfterItems.next();
// FIXME: Handle multiple IItemIterable
IMemberAccessor<IQuantity, IItem> timeAccessor = JfrAttributes.END_TIME.getAccessor(afterItems.getType());
IMemberAccessor<IQuantity, IItem> memAccessor = JdkAttributes.GC_METASPACE_USED
.getAccessor(afterItems.getType());
double leastSquare = RulesToolkit.leastSquareMemory(afterItems.iterator(), timeAccessor, memAccessor);
metaspaceLiveSetIncreasePerSecond = UnitLookup.MEMORY.getUnit(BinaryPrefix.MEBI).quantity(leastSquare);
// FIXME: Configuration attribute
double score = RulesToolkit.mapExp100(leastSquare, 0.75);
// FIXME: Should construct a message using leastSquare, not use a hard limit
if (score >= 25) {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.IncreasingMetaspaceLiveSetRuleFactory_TEXT_INFO))
.setExplanation(
Messages.getString(Messages.IncreasingMetaspaceLiveSetRuleFactory_TEXT_INFO_LONG))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score)).build();
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(METASPACE_LIVESET_INCREASE, metaspaceLiveSetIncreasePerSecond).build();
}
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.IncreasingMetaspaceLiveSetRuleFactory_TEXT_OK))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,42 @@ public class MetaspaceOomRule implements IRule {
public static final TypedResult<IQuantity> OOM_EVENTS = new TypedResult<>("oomCount", //$NON-NLS-1$
JdkAggregators.METASPACE_OOM_COUNT, UnitLookup.NUMBER, IQuantity.class);

public static final TypedResult<IQuantity> MAX_METASPACE_SIZE = new TypedResult<>("maxMetaspaceSize", //$NON-NLS-1$
"Maximum Metaspace Size", "The maximum size of the metaspace.", UnitLookup.NUMBER, IQuantity.class);

private static final Collection<TypedResult<?>> RESULT_ATTRIBUTES = Arrays
.<TypedResult<?>> asList(TypedResult.SCORE, OOM_EVENTS);

private IResult getResult(
IItemCollection items, IPreferenceValueProvider valueProvider, IResultValueProvider resultProvider) {
IQuantity oomCount = items.getAggregate(JdkAggregators.METASPACE_OOM_COUNT);
IQuantity maxMetaspaceSize = items.getAggregate(JdkAggregators.LARGEST_MAX_METASPACE_SIZE_FROM_FLAG);
if (oomCount != null && oomCount.doubleValue() > 0) {
// FIXME: Configuration attribute instead of hard coded 1 as warning limit
double score = RulesToolkit.mapExp100(oomCount.clampedLongValueIn(UnitLookup.NUMBER_UNITY), 1);
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_WARN))
.setExplanation(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_WARN_LONG))

ResultBuilder builder = ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_CAUSE)
.concat(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_WARN)))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(OOM_EVENTS, oomCount).build();
.addResult(OOM_EVENTS, oomCount);

if (maxMetaspaceSize != null) {
builder.setExplanation(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_INCREASE_ACTION)
.concat(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_WARN_LONG)))
.addResult(MAX_METASPACE_SIZE, maxMetaspaceSize);
} else {
builder.setExplanation(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_SET_ACTION)
.concat(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_WARN_LONG)));
}

return builder.build();

}
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_OK)).build();
.setSummary(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_CAUSE)
.concat(Messages.getString(Messages.MetaspaceOomRuleFactory_TEXT_OK)))
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ public class Messages {
public static final String ManyRunningProcessesRule_TEXT_RECOMMENDATION = "ManyRunningProcessesRule_TEXT_RECOMMENDATION"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_RULE_NAME = "MetaspaceOomRuleFactory_RULE_NAME"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_OK = "MetaspaceOomRuleFactory_TEXT_OK"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_CAUSE = "MetaspaceOomRuleFactory_TEXT_CAUSE"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_SET_ACTION = "MetaspaceOomRuleFactory_TEXT_SET_ACTION"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_INCREASE_ACTION = "MetaspaceOomRuleFactory_TEXT_INCREASE_ACTION"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_WARN = "MetaspaceOomRuleFactory_TEXT_WARN"; //$NON-NLS-1$
public static final String MetaspaceOomRuleFactory_TEXT_WARN_LONG = "MetaspaceOomRuleFactory_TEXT_WARN_LONG"; //$NON-NLS-1$
public static final String MethodProfilingDataProvider_AGGR_AGGR_TOP_FRAME_QUOTA = "MethodProfilingDataProvider_AGGR_AGGR_TOP_FRAME_QUOTA"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,10 @@ IncreasingLiveSetRuleFactory_RULE_NAME=Heap Live Set Trend
IncreasingLiveSetRuleFactory_TEXT_INFO=The live set on the heap seems to increase with a speed of about {livesetIncrease} per second during the recording.
IncreasingLiveSetRuleFactory_TEXT_INFO_LONG=This may be due to a memory leak in the application or it may be an artifact of a short recording if the JVM has recently been started. The recording began {timeAfterJvmStart} after the JVM was started. More information can be gathered by using the 'Old Object Sample' event, if available.
IncreasingMetaspaceLiveSetRuleFactory_RULE_NAME=Metaspace Live Set Trend
IncreasingMetaspaceLiveSetRuleFactory_TEXT_INFO=The class data seems to increase constantly in the metaspace during the recording.
# {metaspaceLivesetIncrease} is a number denoted in Mebibytes per second
IncreasingMetaspaceLiveSetRuleFactory_TEXT_INFO=Metaspace is the area of memory allocated for the JVM to store class metadata. The class metadata seems to increase constantly in the metaspace during the recording. The live set on the metaspace seems to increase with a speed of about {metaspaceLivesetIncrease} per second during the recording.
IncreasingMetaspaceLiveSetRuleFactory_TEXT_INFO_LONG=This behavior may indicate a memory leak in the metaspace, this could be due to the application not unloading classes as needed.
IncreasingMetaspaceLiveSetRuleFactory_TEXT_OK=The class data does not seem to increase during the recording.
IncreasingMetaspaceLiveSetRuleFactory_TEXT_OK=Metaspace is the area of memory allocated for the JVM to store class metadata. The class metadata does not seem to increase during the recording.
JavaBlocking_RULE_NAME=Java Blocking
JavaBlockingRule_AGGR_BALANCE_BY_INSTANCE=By Instance
JavaBlockingRule_AGGR_BALANCE_BY_THREAD=By Thread
Expand Down Expand Up @@ -519,10 +520,13 @@ ManyRunningProcessesRule_TEXT_RECOMMENDATION=If this is a server environment, it
ManyRunningProcessesRule_INFO_LIMIT=Competing processes limit
ManyRunningProcessesRule_INFO_LIMIT_LONG=The number of simultaneous processes needed to trigger an info notice
MetaspaceOomRuleFactory_RULE_NAME=Metaspace Out of Memory
MetaspaceOomRuleFactory_TEXT_CAUSE=Java class metadata is allocated in native memory (metaspace). When the amount of native memory needed for a class metadata exceeds MaxMetaspaceSize, a java.lang.OutOfMemoryError exception with a detail Metaspace is thrown. The amount of metaspace that can be used for class metadata is limited by the parameter MaxMetaspaceSize, which is specified on the command line.
MetaspaceOomRuleFactory_TEXT_SET_ACTION=MaxMetaspaceSize has not been set on the command-line, setting its value may help resolve the issue. Metaspace is allocated from the same address spaces as the Java heap. Reducing the size of the Java heap will make more space available for MetaSpace.
MetaspaceOomRuleFactory_TEXT_INCREASE_ACTION=MaxMetaspaceSize has been set to {maxMetaspaceSize} on the command-line, increase its value to resolve the issue. Metaspace is allocated from the same address spaces as the Java heap. Reducing the size of the Java heap will make more space available for MetaSpace.
MetaspaceOomRuleFactory_TEXT_OK=The metaspace was not exhausted during this recording.
# {oomCount} is a number
MetaspaceOomRuleFactory_TEXT_WARN={oomCount} ''Out of Metaspace Memory'' events are present in this recording.
MetaspaceOomRuleFactory_TEXT_WARN_LONG=Increase or remove the '-XX:MaxMetaSpaceSize' flag or investigate why classes are not unloaded properly.
MetaspaceOomRuleFactory_TEXT_WARN_LONG=Increase or remove the '-XX:MaxMetaspaceSize' flag or investigate why classes are not unloaded properly.
MethodProfilingDataProvider_AGGR_AGGR_TOP_FRAME_QUOTA=Top Frame Quota
MethodProfilingDataProvider_AGGR_AGGR_TOP_FRAME_QUOTA_DESC=The quota between the top frame and the total samples count
MethodProfilingDataProvider_AGGR_MAX_ENDTIME=Max End Time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public final class JdkAggregators {
public static final IAggregator<IQuantity, ?> LARGEST_MAX_HEAP_SIZE_FROM_FLAG = filter(
Messages.getString(Messages.AGGR_LARGEST_MAX_HEAP_SIZE_FROM_FLAG), null, max(ULONG_FLAG, FLAG_VALUE_NUMBER),
ItemFilters.equals(FLAG_NAME, "MaxHeapSize")); //$NON-NLS-1$
public static final IAggregator<IQuantity, ?> LARGEST_MAX_METASPACE_SIZE_FROM_FLAG = filter(
Messages.getString(Messages.AGGR_LARGEST_MAX_METASPACE_SIZE_FROM_FLAG), null,
max(ULONG_FLAG, FLAG_VALUE_NUMBER), ItemFilters.equals(FLAG_NAME, "MaxMetaspaceSize")); //$NON-NLS-1$
public static final IAggregator<IQuantity, ?> OUTSIDE_TLAB_COUNT = Aggregators.count(
Messages.getString(Messages.AGGR_OUTSIDE_TLAB_COUNT),
Messages.getString(Messages.AGGR_OUTSIDE_TLAB_COUNT_DESC), ALLOC_OUTSIDE_TLAB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class Messages {
public static final String AGGR_JFR_DATA_LOST_COUNT = "AGGR_JFR_DATA_LOST_COUNT"; //$NON-NLS-1$
public static final String AGGR_JFR_DATA_LOST_COUNT_DESC = "AGGR_JFR_DATA_LOST_COUNT_DESC"; //$NON-NLS-1$
public static final String AGGR_LARGEST_MAX_HEAP_SIZE_FROM_FLAG = "AGGR_LARGEST_MAX_HEAP_SIZE_FROM_FLAG"; //$NON-NLS-1$
public static final String AGGR_LARGEST_MAX_METASPACE_SIZE_FROM_FLAG = "AGGR_LARGEST_MAX_METASPACE_SIZE_FROM_FLAG"; //$NON-NLS-1$
public static final String AGGR_LAST_ATTRIBUTE = "AGGR_LAST_ATTRIBUTE"; //$NON-NLS-1$
public static final String AGGR_LAST_ATTRIBUTE_DESC = "AGGR_LAST_ATTRIBUTE_DESC"; //$NON-NLS-1$
public static final String AGGR_LONGEST_GC_PAUSE = "AGGR_LONGEST_GC_PAUSE"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ AGGR_IGNORE_UNRECOGNIZED_VM_OPTIONS=Ignore Unrecognized VM Options
AGGR_ITEM_COUNT=Event Count
AGGR_ITEM_COUNT_DESC=Total number of events
AGGR_LARGEST_MAX_HEAP_SIZE_FROM_FLAG=Max Heap Size
AGGR_LARGEST_MAX_METASPACE_SIZE_FROM_FLAG=Max Metaspace Size
AGGR_LAST_ATTRIBUTE=Last {0}
AGGR_LAST_ATTRIBUTE_DESC=The last value of {0} encountered
AGGR_USING_COMPRESSED_OOPS=Using Compressed Oops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ This recording is only 9.903 s long, consider creating a recording longer than
<rule>
<id>IncreasingMetaSpaceLiveSet</id>
<severity>OK</severity>
<summary>The class data does not seem to increase during the recording.</summary>
<summary>Metaspace is the area of memory allocated for the JVM to store class metadata. The class metadata does not seem to increase during the recording.</summary>
</rule>
<rule>
<id>JavaBlocking</id>
Expand Down Expand Up @@ -240,7 +240,7 @@ This recording is only 9.903 s long, consider creating a recording longer than
<rule>
<id>MetaspaceOom</id>
<severity>OK</severity>
<summary>The metaspace was not exhausted during this recording.</summary>
<summary>Java class metadata is allocated in native memory (metaspace). When the amount of native memory needed for a class metadata exceeds MaxMetaSpaceSize, a java.lang.OutOfMemoryError exception with a detail MetaSpace is thrown. The amount of metaspace that can be used for class metadata is limited by the parameter MaxMetaSpaceSize, which is specified on the command line.The metaspace was not exhausted during this recording.</summary>
</rule>
<rule>
<id>MethodProfiling</id>
Expand Down
Loading