Skip to content
Permalink
Browse files

6657: Add allocation pressure column to Memory and TLAB views

Reviewed-by: hirt
  • Loading branch information
jiekang authored and thegreystone committed Mar 4, 2020
1 parent 49da554 commit 28d203af9f38c3259e6b712b821e01e527be1f09
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
@@ -309,6 +309,8 @@ HeapPage_ROW_MEMORY_USAGE_DESC=\u3053\u306E\u30EC\u30FC\u30F3\u306B\u306F\u3001\
HeapPage_SELECTED_CLASS=1\u30AF\u30E9\u30B9
# {0} is a number
HeapPage_SELECTED_CLASSES={0}\u30AF\u30E9\u30B9
HeapPage_ALLOCATION_TOTAL_PERCENTAGE=\u5272\u5F53\u3066\u5408\u8A08(%)
HeapPage_ALLOCATION_TOTAL_PERCENTAGE_DESC=\u5272\u5F53\u3066\u5408\u8A08\u306E\u898B\u7A4D\u308A\u3002\u3053\u308C\u306F\u6B63\u78BA\u306A\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002(\u30D1\u30FC\u30BB\u30F3\u30C6\u30FC\u30B8)

INFORMATION_COMPONENT_NOT_AVAILABLE=N/A

@@ -484,11 +486,17 @@ ThreadsPage_EDIT_LANES=\u30B9\u30EC\u30C3\u30C9\u30FB\u30EC\u30FC\u30F3\u306E\u7
ThreadsPage_NAME=\u30B9\u30EC\u30C3\u30C9

TlabPage_PAGE_NAME=TLAB\u5272\u5F53\u3066
TlabPage_THREADS_TAB_NAME=\u30B9\u30EC\u30C3\u30C9
TlabPage_METHODS_TAB_NAME=\u30E1\u30BD\u30C3\u30C9
TlabPage_ROW_TLAB_ALLOCATIONS=TLAB\u5272\u5F53\u3066
TlabPage_ROW_TLAB_ALLOCATIONS_DESC=\u5272\u5F53\u3066\u30B5\u30F3\u30D7\u30EB\u304B\u3089\u751F\u6210\u3055\u308C\u305F\u30C7\u30FC\u30BF\u3002\u30B5\u30F3\u30D7\u30EB\u306F\u3001\u65B0\u3057\u3044\u30B9\u30EC\u30C3\u30C9\u30FB\u30ED\u30FC\u30AB\u30EB\u5272\u5F53\u3066\u30D0\u30C3\u30D5\u30A1(TLAB)\u3092\u53D6\u5F97\u3059\u308B\u3068\u304D\u3001\u307E\u305F\u306F\u30B9\u30EC\u30C3\u30C9\u30FB\u30ED\u30FC\u30AB\u30EB\u5272\u5F53\u3066\u30D0\u30C3\u30D5\u30A1\u306E\u5916\u90E8\u3067\u5272\u308A\u5F53\u3066\u308B\u3068\u304D\u306B\u53CE\u96C6\u3055\u308C\u307E\u3059\u3002
TlabPage_SELECTED_THREAD=1\u30B9\u30EC\u30C3\u30C9
TlabPage_SELECTED_THREAD=1
# {0} is a number
TlabPage_SELECTED_THREADS={0}\u30B9\u30EC\u30C3\u30C9
TlabPage_SELECTED_THREADS={0}
TlabPage_INSIDE_TLAB_SUM_PERCENTAGE=TLAB\u5272\u5F53\u3066\u306E\u898B\u7A4D\u308A(%)
TlabPage_INSIDE_TLAB_SUM_PERCENTAGE_DESC=TLAB\u306E\u898B\u7A4D\u308A\u5272\u5F53\u3066\u30B5\u30A4\u30BA(\u30D1\u30FC\u30BB\u30F3\u30C6\u30FC\u30B8)
TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE=TLAB\u5916\u306E\u5408\u8A08\u5272\u5F53\u3066(%)
TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE_DESC=TLAB\u5916\u306E\u5272\u5F53\u3066\u306E\u5408\u8A08\u30B5\u30A4\u30BA(\u30D1\u30FC\u30BB\u30F3\u30C6\u30FC\u30B8)

JVMInformationPage_COLUMN_VALUE=\u5024
JVMInformationPage_PAGE_NAME=JVM\u5185\u90E8
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
@@ -309,6 +309,8 @@ HeapPage_ROW_MEMORY_USAGE_DESC=\u6B64\u901A\u9053\u53EF\u4EE5\u663E\u793A\u5806\
HeapPage_SELECTED_CLASS=1 \u4E2A\u7C7B
# {0} is a number
HeapPage_SELECTED_CLASSES={0} \u4E2A\u7C7B
HeapPage_ALLOCATION_TOTAL_PERCENTAGE=\u603B\u5206\u914D\u91CF(%)
HeapPage_ALLOCATION_TOTAL_PERCENTAGE_DESC=\u4F30\u8BA1\u7684\u603B\u5206\u914D\u91CF\u3002\u8FD9\u5E76\u975E\u786E\u5207\u503C\u3002(\u767E\u5206\u6BD4)

INFORMATION_COMPONENT_NOT_AVAILABLE=N/A

@@ -484,11 +486,17 @@ ThreadsPage_EDIT_LANES=\u7F16\u8F91\u7EBF\u7A0B\u901A\u9053
ThreadsPage_NAME=\u7EBF\u7A0B

TlabPage_PAGE_NAME=TLAB \u5206\u914D
TlabPage_THREADS_TAB_NAME=\u7EBF\u7A0B
TlabPage_METHODS_TAB_NAME=\u65B9\u6CD5
TlabPage_ROW_TLAB_ALLOCATIONS=TLAB \u5206\u914D
TlabPage_ROW_TLAB_ALLOCATIONS_DESC=\u4ECE\u5206\u914D\u6837\u672C\u751F\u6210\u7684\u6570\u636E\u3002\u5728\u83B7\u53D6\u65B0\u7684\u7EBF\u7A0B\u672C\u5730\u5206\u914D\u7F13\u51B2\u533A (TLAB) \u6216\u5728\u6B64\u7C7B\u7F13\u51B2\u533A\u4E4B\u5916\u5206\u914D\u65F6\u6536\u96C6\u6837\u672C\u3002
TlabPage_SELECTED_THREAD=1 \u4E2A\u7EBF\u7A0B
TlabPage_SELECTED_ONE=1
# {0} is a number
TlabPage_SELECTED_THREADS={0} \u4E2A\u7EBF\u7A0B
TlabPage_SELECTED_MANY={0}
TlabPage_INSIDE_TLAB_SUM_PERCENTAGE=\u4F30\u8BA1 TLAB \u5206\u914D(%)
TlabPage_INSIDE_TLAB_SUM_PERCENTAGE_DESC=TLAB \u4E2D\u4F30\u8BA1\u7684\u5206\u914D\u5927\u5C0F(\u767E\u5206\u6BD4)
TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE=TLAB \u5916\u90E8\u7684\u603B\u5206\u914D(%)
TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE_DESC=TLAB \u5916\u90E8\u5206\u914D\u7684\u603B\u5927\u5C0F(\u767E\u5206\u6BD4)

JVMInformationPage_COLUMN_VALUE=\u503C
JVMInformationPage_PAGE_NAME=JVM \u5185\u90E8
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -759,16 +759,19 @@
<state>
<sash weights="2,1" />
<table sortColumn="totalOutsideSize">
<column id="itemhistogram.key" width="500" />
<column id="itemhistogram.count" sortAscending="false" width="120" />
<column id="itemhistogram.key" width="350" />
<column id="insideCount" sortAscending="false" width="120"
hidden="true" />
<column id="outsideCount" sortAscending="false" width="120"
hidden="true" />
<column id="averageInsideSize" sortAscending="false" width="120" />
<column id="averageOutsideSize" sortAscending="false" width="120" />
<column id="totalInsideSize" sortAscending="false" width="120" />
<column id="totalOutsideSize" sortAscending="false" width="120" />
<column id="averageInsideSize" sortAscending="false" width="120"
hidden="true" />
<column id="averageOutsideSize" sortAscending="false" width="120"
hidden="true" />
<column id="totalInsideSize" sortAscending="false" width="150" />
<column id="totalInsideSizePercent" sortAscending="false" width="150" />
<column id="totalOutsideSize" sortAscending="false" width="200" />
<column id="totalOutsideSizePercent" sortAscending="false" width="200" />
</table>
<chart>
<checkedAction id="insideSize" />
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -62,11 +62,13 @@
private static class AggregationModel {
final Object[][] cellData;
AggregateRow[] aggregateItems;
IItemCollection modelItems;
int itemsCount;

AggregationModel(int columnCount, int rowCount) {
cellData = new Object[columnCount][];
aggregateItems = new AggregateRow[rowCount];
AggregationModel(int columnCount, int rowCount, IItemCollection modelItems) {
this.cellData = new Object[columnCount][];
this.aggregateItems = new AggregateRow[rowCount];
this.modelItems = modelItems;
}

void addRow(Object key, List<IItem[]> items, int rowIndex) {
@@ -86,9 +88,9 @@ void addRow(Object key, List<IItem[]> items, int rowIndex) {
AggregateRow(AggregationModel model, Object key, List<IItem[]> itemsByType, int rowIndex) {
this.model = model;
this.key = key;
items = buildItemCollection(itemsByType);
count = UnitLookup.NUMBER_UNITY.quantity(itemsByType.stream().mapToInt(ia -> ia.length).sum());
index = rowIndex;
this.items = buildItemCollection(itemsByType);
this.count = UnitLookup.NUMBER_UNITY.quantity(itemsByType.stream().mapToInt(ia -> ia.length).sum());
this.index = rowIndex;
}

@Override
@@ -131,6 +133,34 @@ private Object calculateValue(AggregateRow row) {
}
}

private static class PercentageColumn implements IMemberAccessor<Object, Object> {

private final BiFunction<IItemCollection, IItemCollection, ?> valueFunction;
private final int columnIndex;

PercentageColumn(BiFunction<IItemCollection, IItemCollection, ?> valueFunction, int columnIndex) {
this.valueFunction = valueFunction;
this.columnIndex = columnIndex;
}

@Override
public Object getMember(Object inObject) {
if (inObject instanceof AggregateRow) {
AggregateRow ai = ((AggregateRow) inObject);
if (ai.model.cellData[columnIndex] == null) {
ai.model.cellData[columnIndex] = Arrays.stream(ai.model.aggregateItems).parallel()
.map(this::calculateValue).toArray();
}
return ai.model.cellData[columnIndex][((AggregateRow) inObject).index];
}
return null;
}

private Object calculateValue(AggregateRow row) {
return valueFunction.apply(row.items, row.model.modelItems);
}
}

private int createdColumns;

public static Object getKey(Object row) {
@@ -160,6 +190,12 @@ public static double getCountFraction(Object row) {
return new AggregateColumn(valueFunction, createdColumns++);
}

// All rows built before the column was added will not have the extra column
public IMemberAccessor<?, Object> addPercentageColumn(
BiFunction<IItemCollection, IItemCollection, ?> valueFunction) {
return new PercentageColumn(valueFunction, createdColumns++);
}

private static <T> void addStream(HashMap<T, List<IItem[]>> map, KeyedStream<T, IItem> ks) {
map.computeIfAbsent(ks.getKey(), k -> new ArrayList<>()).add(ks.getStream().toArray(IItem[]::new));
}
@@ -203,9 +239,9 @@ private static IItemCollection buildItemCollection(List<IItem[]> items) {
.build(items.stream().map(ITEMS_BY_TYPE_CONSTRUCTOR).collect(Collectors.toList())::stream);
}

public <T> Object[] buildRows(Stream<IItemIterable> items, IAccessorFactory<T> classifier) {
Map<T, List<IItem[]>> itemsMap = mapItems(items, classifier);
AggregationModel model = new AggregationModel(createdColumns, itemsMap.size());
public <T> Object[] buildRows(IItemCollection items, IAccessorFactory<T> classifier) {
Map<T, List<IItem[]>> itemsMap = mapItems(ItemCollectionToolkit.stream(items), classifier);
AggregationModel model = new AggregationModel(createdColumns, itemsMap.size(), items);
int index = 0;
for (Entry<T, List<IItem[]>> e : itemsMap.entrySet()) {
model.addRow(e.getKey(), e.getValue(), index++);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -50,6 +50,7 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;

@@ -60,7 +61,9 @@
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.item.IMemberAccessor;
import org.openjdk.jmc.common.unit.ContentType;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.LinearKindOfQuantity;
import org.openjdk.jmc.common.unit.UnitLookup;
import org.openjdk.jmc.common.util.CompositeKey;
import org.openjdk.jmc.common.util.TypeHandling;
import org.openjdk.jmc.flightrecorder.ui.ItemCollectionToolkit;
@@ -127,6 +130,27 @@ public void addColumn(String colId, IAggregator<?, ?> a) {
addColumn(colId, ic -> ic.getAggregate(a), a.getName(), a.getDescription(), style);
}

public void addPercentageColumn(String colId, IAggregator<?, ?> a) {
addPercentageColumn(colId, a, a.getName(), a.getDescription());
}

public void addPercentageColumn(String colId, IAggregator<?, ?> a, String name, String description) {
int style = a.getValueType() instanceof LinearKindOfQuantity ? SWT.RIGHT : SWT.NONE;

BiFunction<IItemCollection, IItemCollection, ?> percentageFunction = (rowItems, allItems) -> {
if (a.getValueType() instanceof LinearKindOfQuantity) {
IQuantity rowResult = (IQuantity) rowItems.getAggregate(a);
IQuantity allResult = (IQuantity) allItems.getAggregate(a);
if (rowResult != null && allResult != null) {
return UnitLookup.PERCENT.quantity(rowResult.ratioTo(allResult) * 100);
}
}
return rowItems.getAggregate(a);
};

addPercentageColumn(colId, percentageFunction, name, description, style);
}

public void addColumn(
String colId, Function<IItemCollection, ?> valueFunction, String name, String description) {
addColumn(colId, valueFunction, name, description, SWT.NONE);
@@ -138,6 +162,24 @@ public void addColumn(
.style(style).build());
}

public void addPercentageColumn(
String colId, BiFunction<IItemCollection, IItemCollection, ?> valueFunction, String name,
String description, int style) {
IMemberAccessor<?, Object> column = grid.addPercentageColumn(valueFunction);
BackgroundFractionDrawer percentageValueDrawer = new BackgroundFractionDrawer() {
@Override
public void handleEvent(Event event) {
Object row = event.item.getData();
Object item = column.getMember(row);
if (item instanceof Number) {
draw(((Number) item).doubleValue() / 100, event);
}
}
};
columns.add(new ColumnBuilder(name, colId, column).description(description).style(style)
.columnDrawer(percentageValueDrawer).build());
}

public <T> void addColumn(IAttribute<T> a) {
// FIXME: Refactor/remove this method to avoid it being used instead of passing an IAggregator.
// Accessing the thread-group is quite a special case as it is a property of the key (group by attribute).
@@ -253,7 +295,7 @@ public HistogramSelection getSelection() {
}

public void show(IItemCollection items) {
columnManager.getViewer().setInput(grid.buildRows(ItemCollectionToolkit.stream(items), classifier));
columnManager.getViewer().setInput(grid.buildRows(items, classifier));
}

/*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -212,6 +212,8 @@
public static String HeapPage_ROW_MEMORY_USAGE_DESC;
public static String HeapPage_SELECTED_CLASS;
public static String HeapPage_SELECTED_CLASSES;
public static String HeapPage_ALLOCATION_TOTAL_PERCENTAGE;
public static String HeapPage_ALLOCATION_TOTAL_PERCENTAGE_DESC;
public static String INFORMATION_COMPONENT_NOT_AVAILABLE;
public static String IO_PAGE_DURATIONS_DESCRIPTION;
public static String IO_PAGE_EVENT_LOG_DESCRIPTION;
@@ -511,10 +513,16 @@
public static String ThreadsPage_NAME;
public static String ThreadsPage_RESET_CHART_TO_SELECTION_ACTION;
public static String TlabPage_PAGE_NAME;
public static String TlabPage_THREADS_TAB_NAME;
public static String TlabPage_METHODS_TAB_NAME;
public static String TlabPage_ROW_TLAB_ALLOCATIONS;
public static String TlabPage_ROW_TLAB_ALLOCATIONS_DESC;
public static String TlabPage_SELECTED_THREAD;
public static String TlabPage_SELECTED_THREADS;
public static String TlabPage_SELECTED_ONE;
public static String TlabPage_SELECTED_MANY;
public static String TlabPage_INSIDE_TLAB_SUM_PERCENTAGE;
public static String TlabPage_INSIDE_TLAB_SUM_PERCENTAGE_DESC;
public static String TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE;
public static String TlabPage_OUTSIDE_TLAB_SUM_PERCENTAGE_DESC;
public static String VMOPERATION_PAGE_DURATIONS_DESCRIPTION;
public static String VMOPERATION_PAGE_EVENT_LOG_DESCRIPTION;
public static String VMOPERATION_PAGE_TIMELINE_DESCRIPTION;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -102,15 +102,15 @@

ChartAndTableUI(IItemFilter pageFilter, StreamModel model, Composite parent, FormToolkit toolkit,
IPageContainer pageContainer, IState state, String sectionTitle, IItemFilter tableFilter, Image icon,
FlavorSelectorState flavorSelectorState) {
FlavorSelectorState flavorSelectorState, IAttribute<?> classifier) {
this.pageFilter = pageFilter;
this.model = model;
this.pageContainer = pageContainer;
form = DataPageToolkit.createForm(parent, toolkit, sectionTitle, icon);
sash = new SashForm(form.getBody(), SWT.VERTICAL);
toolkit.adapt(sash);

table = buildHistogram(sash, state.getChild(TABLE));
table = buildHistogram(sash, state.getChild(TABLE), classifier);
MCContextMenuManager mm = MCContextMenuManager.create(table.getManager().getViewer().getControl());
ColumnMenusFactory.addDefaultMenus(table.getManager(), mm);
table.getManager().getViewer().addSelectionChangedListener(e -> buildChart());
@@ -182,6 +182,10 @@ public void saveTo(IWritableState writableState) {
}
}

public Form getComponent() {
return this.form;
}

private void onSetRange(Boolean useRange) {
IRange<IQuantity> range = useRange ? timeRange : pageContainer.getRecordingRange();
chart.setVisibleRange(range.getStart(), range.getEnd());
@@ -218,7 +222,7 @@ protected boolean isAttributeEnabled(IAttribute<IQuantity> attr) {
return action.isPresent() && action.get().isChecked();
}

protected abstract ItemHistogram buildHistogram(Composite parent, IState state);
protected abstract ItemHistogram buildHistogram(Composite parent, IState state, IAttribute<?> classifier);

protected abstract IXDataRenderer getChartRenderer(IItemCollection itemsInTable, HistogramSelection selection);

0 comments on commit 28d203a

Please sign in to comment.
You can’t perform that action at this time.