Skip to content

Commit

Permalink
7124: Support the new JDK 16 allocation profiling event
Browse files Browse the repository at this point in the history
Reviewed-by: hirt
  • Loading branch information
jpbempel authored and thegreystone committed May 3, 2021
1 parent 917a95c commit 30223c7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -52,6 +52,7 @@

import org.openjdk.jmc.common.IState;
import org.openjdk.jmc.common.IWritableState;
import org.openjdk.jmc.common.item.IAggregator;
import org.openjdk.jmc.common.item.IAttribute;
import org.openjdk.jmc.common.item.IItem;
import org.openjdk.jmc.common.item.IItemCollection;
Expand Down Expand Up @@ -120,7 +121,8 @@ public IDisplayablePage createPage(IPageDefinition dpd, StreamModel items, IPage

}

private static final IItemFilter TABLE_ITEMS = ItemFilters.or(JdkFilters.OBJECT_COUNT, JdkFilters.ALLOC_ALL);
private static final IItemFilter TABLE_ITEMS = ItemFilters.or(JdkFilters.OBJECT_COUNT, JdkFilters.ALLOC_ALL,
JdkFilters.OBJ_ALLOC);
private static final String INSTANCES_COL = "instances"; //$NON-NLS-1$
private static final String SIZE_COL = "size"; //$NON-NLS-1$
private static final String INCREASE_COL = "increase"; //$NON-NLS-1$
Expand All @@ -130,19 +132,6 @@ public IDisplayablePage createPage(IPageDefinition dpd, StreamModel items, IPage
private static final String OUTSIDE_TLAB_COL = "outsideTlabSize"; //$NON-NLS-1$
private static final String GC_PAUSE_ID = "gcPause"; //$NON-NLS-1$

private static final ItemHistogramBuilder HISTOGRAM = new ItemHistogramBuilder();

static {
HISTOGRAM.addColumn(INSTANCES_COL, JdkAggregators.OBJECT_COUNT_MAX_INSTANCES);
HISTOGRAM.addColumn(SIZE_COL, JdkAggregators.OBJECT_COUNT_MAX_SIZE);
HISTOGRAM.addColumn(INCREASE_COL, ObjectStatisticsDataProvider.getIncreaseAggregator());
HISTOGRAM.addColumn(ALLOCATION_COL, JdkAggregators.ALLOCATION_TOTAL);
HISTOGRAM.addPercentageColumn(ALLOCATION_PERCENT_COL, JdkAggregators.ALLOCATION_TOTAL,
Messages.HeapPage_ALLOCATION_TOTAL_PERCENTAGE, Messages.HeapPage_ALLOCATION_TOTAL_PERCENTAGE_DESC);
HISTOGRAM.addColumn(INSIDE_TLAB_COL, JdkAggregators.ALLOC_INSIDE_TLAB_SUM);
HISTOGRAM.addColumn(OUTSIDE_TLAB_COL, JdkAggregators.ALLOC_OUTSIDE_TLAB_SUM);
}

private class ObjectStatisticsUi extends ChartAndTableUI {

private static final String HEAP_FILTER = "heapFilter"; //$NON-NLS-1$
Expand Down Expand Up @@ -176,6 +165,17 @@ private void saveToLocal() {

@Override
protected ItemHistogram buildHistogram(Composite parent, IState state, IAttribute<?> classifier) {
ItemHistogramBuilder HISTOGRAM = new ItemHistogramBuilder();
IAggregator<IQuantity, ?> allocTotalAggregator = hasObjectAllocSampleEvent()
? JdkAggregators.OBJ_ALLOC_TOTAL_SUM : JdkAggregators.ALLOCATION_TOTAL;
HISTOGRAM.addColumn(INSTANCES_COL, JdkAggregators.OBJECT_COUNT_MAX_INSTANCES);
HISTOGRAM.addColumn(SIZE_COL, JdkAggregators.OBJECT_COUNT_MAX_SIZE);
HISTOGRAM.addColumn(INCREASE_COL, ObjectStatisticsDataProvider.getIncreaseAggregator());
HISTOGRAM.addColumn(ALLOCATION_COL, allocTotalAggregator);
HISTOGRAM.addPercentageColumn(ALLOCATION_PERCENT_COL, allocTotalAggregator,
Messages.HeapPage_ALLOCATION_TOTAL_PERCENTAGE, Messages.HeapPage_ALLOCATION_TOTAL_PERCENTAGE_DESC);
HISTOGRAM.addColumn(INSIDE_TLAB_COL, JdkAggregators.ALLOC_INSIDE_TLAB_SUM);
HISTOGRAM.addColumn(OUTSIDE_TLAB_COL, JdkAggregators.ALLOC_OUTSIDE_TLAB_SUM);
return HISTOGRAM.buildWithoutBorder(parent, classifier, getTableSettings(state));
}

Expand All @@ -187,9 +187,13 @@ protected IXDataRenderer getChartRenderer(IItemCollection itemsInTable, Histogra
String classCount = classCount(selection.getRowCount());
IItemCollection selectedItems = selection.getRowCount() == 0 ? itemsInTable : selection.getItems();
if (allocationAction.isChecked()) {
boolean hasObjectAllocSampleEvent = hasObjectAllocSampleEvent();
IAggregator<IQuantity, ?> allocTotalAggregator = hasObjectAllocSampleEvent
? JdkAggregators.OBJ_ALLOC_TOTAL_SUM : JdkAggregators.ALLOCATION_TOTAL;
IItemFilter selectedFilter = hasObjectAllocSampleEvent ? JdkFilters.OBJ_ALLOC : JdkFilters.ALLOC_ALL;
rows.add(DataPageToolkit.buildTimestampHistogram(Messages.HeapPage_ROW_ALLOCATION + classCount,
JdkAggregators.ALLOCATION_TOTAL.getDescription(), selectedItems.apply(JdkFilters.ALLOC_ALL),
JdkAggregators.ALLOCATION_TOTAL, DataPageToolkit.ALLOCATION_COLOR));
allocTotalAggregator.getDescription(), selectedItems.apply(selectedFilter),
allocTotalAggregator, DataPageToolkit.ALLOCATION_COLOR));
}

XYDataRenderer heapRenderer = new XYDataRenderer(UnitLookup.MEMORY.getDefaultUnit().quantity(0),
Expand Down Expand Up @@ -245,8 +249,10 @@ protected List<IAction> initializeChartConfiguration(IState state) {
sizeAction = DataPageToolkit.createCheckAction(Messages.HeapPage_ROW_LIVE_SIZE,
Messages.HeapPage_ROW_LIVE_SIZE_DESC, SIZE_COL,
FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.PAGE_HEAP), b -> buildChart());
allocationAction = DataPageToolkit.createAggregatorCheckAction(JdkAggregators.ALLOCATION_TOTAL,
ALLOCATION_COL, DataPageToolkit.ALLOCATION_COLOR, b -> buildChart());
IAggregator<IQuantity, ?> allocTotalAggregator = hasObjectAllocSampleEvent()
? JdkAggregators.OBJ_ALLOC_TOTAL_SUM : JdkAggregators.ALLOCATION_TOTAL;
allocationAction = DataPageToolkit.createAggregatorCheckAction(allocTotalAggregator, ALLOCATION_COL,
DataPageToolkit.ALLOCATION_COLOR, b -> buildChart());
Stream<IAction> attributeActions = Stream
.concat(HEAP_SUMMARY.getAttributes().stream(), OS_MEMORY_SUMMARY.getAttributes().stream())
.map(a -> DataPageToolkit.createAttributeCheckAction(a, b -> buildChart()));
Expand Down Expand Up @@ -281,6 +287,10 @@ private static String classCount(int count) {
}
}

private boolean hasObjectAllocSampleEvent() {
return getDataSource().getItems().apply(ItemFilters.type(JdkTypeIDs.OBJ_ALLOC_SAMPLE)).hasItems();
}

private IRange<IQuantity> visibleRange;
private IItemFilter tableFilter;
private SelectionState histogramState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -335,6 +335,9 @@ public final class JdkAggregators {
Messages.getString(Messages.AGGR_ALLOC_OUTSIDE_TLAB_SUM),
Messages.getString(Messages.AGGR_ALLOC_OUTSIDE_TLAB_SUM_DESC), JdkTypeIDs.ALLOC_OUTSIDE_TLAB,
JdkAttributes.ALLOCATION_SIZE);
public static final IAggregator<IQuantity, ?> OBJ_ALLOC_TOTAL_SUM = Aggregators.sum(
Messages.getString(Messages.AGGR_OBJ_ALLOC_SUM), Messages.getString(Messages.AGGR_OBJ_ALLOC_SUM_DESC),
JdkTypeIDs.OBJ_ALLOC_SAMPLE, JdkAttributes.SAMPLE_WEIGHT);
public static final IAggregator<IQuantity, ?> SWEEP_METHOD_SUM = Aggregators.sum(
Messages.getString(Messages.AGGR_SWEEP_METHOD_SUM), Messages.getString(Messages.AGGR_SWEEP_METHOD_SUM_DESC),
JdkTypeIDs.SWEEP_CODE_CACHE, JdkAttributes.SWEEP_METHOD_SWEPT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1280,4 +1280,6 @@ public IQuantity getMember(U i) {
public static final IAttribute<String> CONSTANT_VALUE = attr("constant", //$NON-NLS-1$
Messages.getString(Messages.ATTR_CONSTANT_VALUE), PLAIN_TEXT);

public static final IAttribute<IQuantity> SAMPLE_WEIGHT = attr("weight", //$NON-NLS-1$
Messages.getString(Messages.ATTR_SAMPLE_WEIGHT), MEMORY);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public final class JdkFilters {
public static final IItemFilter ALLOC_INSIDE_TLAB = ItemFilters.type(JdkTypeIDs.ALLOC_INSIDE_TLAB);
public static final IItemFilter ALLOC_ALL = ItemFilters.type(JdkTypeIDs.ALLOC_INSIDE_TLAB,
JdkTypeIDs.ALLOC_OUTSIDE_TLAB);
public static final IItemFilter OBJ_ALLOC = ItemFilters.type(JdkTypeIDs.OBJ_ALLOC_SAMPLE);
public static final IItemFilter REFERENCE_STATISTICS = ItemFilters.type(JdkTypeIDs.GC_REFERENCE_STATISTICS);
public static final IItemFilter GARBAGE_COLLECTION = ItemFilters.type(JdkTypeIDs.GARBAGE_COLLECTION);
public static final IItemFilter OLD_GARBAGE_COLLECTION = ItemFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public final class JdkTypeIDs {
public static final String HEAP_SUMMARY = PREFIX + "GCHeapSummary";
public static final String ALLOC_INSIDE_TLAB = PREFIX + "ObjectAllocationInNewTLAB";
public static final String ALLOC_OUTSIDE_TLAB = PREFIX + "ObjectAllocationOutsideTLAB";
public static final String OBJ_ALLOC_SAMPLE = PREFIX + "ObjectAllocationSample";
public static final String VM_INFO = PREFIX + "JVMInformation";
public static final String CLASS_DEFINE = PREFIX + "ClassDefine";
public static final String CLASS_LOAD = PREFIX + "ClassLoad";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -108,6 +108,8 @@ public class Messages {
public static final String AGGR_NUMBER_OF_DISTINCT_HOSTS_DESC = "AGGR_NUMBER_OF_DISTINCT_HOSTS_DESC"; //$NON-NLS-1$
public static final String AGGR_NUMBER_OF_DISTINCT_PORTS = "AGGR_NUMBER_OF_DISTINCT_PORTS"; //$NON-NLS-1$
public static final String AGGR_NUMBER_OF_DISTINCT_PORTS_DESC = "AGGR_NUMBER_OF_DISTINCT_PORTS_DESC"; //$NON-NLS-1$
public static final String AGGR_OBJ_ALLOC_SUM = "AGGR_OBJ_ALLOC_SUM"; //$NON-NLS-1$
public static final String AGGR_OBJ_ALLOC_SUM_DESC = "AGGR_OBJ_ALLOC_SUM_DESC"; //$NON-NLS-1$
public static final String AGGR_OBJECT_COUNT_MAX_INSTANCES = "AGGR_OBJECT_COUNT_MAX_INSTANCES"; //$NON-NLS-1$
public static final String AGGR_OBJECT_COUNT_MAX_INSTANCES_DESC = "AGGR_OBJECT_COUNT_MAX_INSTANCES_DESC"; //$NON-NLS-1$
public static final String AGGR_OBJECT_COUNT_MAX_SIZE = "AGGR_OBJECT_COUNT_MAX_SIZE"; //$NON-NLS-1$
Expand Down Expand Up @@ -421,6 +423,7 @@ public class Messages {
public static final String ATTR_REVOKED_CLASS_DESC = "ATTR_REVOKED_CLASS_DESC"; //$NON-NLS-1$
public static final String ATTR_SAFEPOINT = "ATTR_SAFEPOINT"; //$NON-NLS-1$
public static final String ATTR_SAFEPOINT_DESC = "ATTR_SAFEPOINT_DESC"; //$NON-NLS-1$
public static final String ATTR_SAMPLE_WEIGHT = "ATTR_SAMPLE_WEIGHT"; //$NON-NLS-1$
public static final String ATTR_STACK_TRACE_BOTTOM_FRAME = "ATTR_STACK_TRACE_BOTTOM_FRAME"; //$NON-NLS-1$
public static final String ATTR_STACK_TRACE_BOTTOM_FRAME_DESC = "ATTR_STACK_TRACE_BOTTOM_FRAME_DESC"; //$NON-NLS-1$
public static final String ATTR_STACK_TRACE_BOTTOM_METHOD = "ATTR_STACK_TRACE_BOTTOM_METHOD"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,15 @@ ATTR_SHUTDOWN_REASON_DESC=Reason for JVM Shutdown
ATTR_SHUTDOWN_TIME=Shutdown Time
ATTR_TOP_ADDRESS=Top Address
ATTR_BASE_ADDRESS=Base Address
ATTR_SAMPLE_WEIGHT=Sample Weight
AGGR_MAX_USED_MEMORY=Maximum used memory
AGGR_MIN_TOTAL_MEMORY=Available physical memory
AGGR_ADDRESSES_COUNT=Addresses
AGGR_ADDRESSES_COUNT_DESC=Number of unique addresses
AGGR_AVG_HEAP_USED_AFTER_GC=Average Heap Used After GC
AGGR_AVG_HEAP_USED_BEFORE_GC=Average Heap Used Before GC
AGGR_OBJ_ALLOC_SUM=Alloc Total
AGGR_OBJ_ALLOC_SUM_DESC=The estimated total of allocation size
AGGR_OBJECT_COUNT_MAX_SIZE=Max Live Size
AGGR_OBJECT_COUNT_MAX_SIZE_DESC=An estimate of the maximum size of all instances after garbage collection
AGGR_OBJECT_COUNT_MAX_INSTANCES=Max Live Count
Expand Down

0 comments on commit 30223c7

Please sign in to comment.