Skip to content
Draft
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 @@ -14,13 +14,11 @@
import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.tracecompass.analysis.profiling.core.callgraph.AggregatedCallSite;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider2;
import org.eclipse.tracecompass.analysis.profiling.core.base.ICallStackSymbol;
import org.eclipse.tracecompass.analysis.profiling.core.base.IDataPalette;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeProvider;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.AggregatedCallSite;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider2;
import org.eclipse.tracecompass.analysis.profiling.core.tree.WeightedTree;
import org.eclipse.tracecompass.analysis.profiling.core.base.ICallStackElement;
import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.diff.DifferentialWeightedTree;
import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.diff.DifferentialWeightedTreeProvider;
import org.eclipse.tracecompass.incubator.analysis.core.weighted.tree.diff.DifferentialWeightedTreeSet;
Expand All @@ -33,35 +31,32 @@
*/
public class DifferentialCallGraphProvider extends DifferentialWeightedTreeProvider<ICallStackSymbol> {

private final ICallGraphProvider2 fOriginalTree;

/**
* Constructor
*
* @param instrumentedCallStackAnalysis
* @param instrumentedCallStackAnalyses
* the original tree
* @param trees
* the other trees to compare to
*/
public DifferentialCallGraphProvider(IWeightedTreeProvider<ICallStackSymbol, ICallStackElement, AggregatedCallSite> instrumentedCallStackAnalysis,
public DifferentialCallGraphProvider(Collection<ICallGraphProvider2> instrumentedCallStackAnalyses,
Collection<DifferentialWeightedTree<ICallStackSymbol>> trees) {
this(instrumentedCallStackAnalysis, DifferentialWeightedTreeSet.<ICallStackSymbol> create(trees));
this(instrumentedCallStackAnalyses, DifferentialWeightedTreeSet.<ICallStackSymbol> create(trees));
}

/**
* Constructor
*
* @param originalTree
* @param instrumentedCallStackAnalyses
* The original tree provider, used to get information for texts
* and metrics.
* @param treeSet
* The differential tree set
*/
public DifferentialCallGraphProvider(
IWeightedTreeProvider<ICallStackSymbol, ICallStackElement, ? extends WeightedTree<ICallStackSymbol>> originalTree,
Collection<ICallGraphProvider2> instrumentedCallStackAnalyses,
DifferentialWeightedTreeSet<ICallStackSymbol> treeSet) {
super((IWeightedTreeProvider<ICallStackSymbol, ICallStackElement, WeightedTree<ICallStackSymbol>>) originalTree, treeSet);
fOriginalTree = (ICallGraphProvider2) originalTree;
super(instrumentedCallStackAnalyses, treeSet);
}

@Override
Expand All @@ -75,7 +70,12 @@ public String toDisplayString(DifferentialWeightedTree<ICallStackSymbol> tree) {
WeightedTree<ICallStackSymbol> originalTree = tree.getOriginalTree();
String label = ""; //$NON-NLS-1$
if (originalTree instanceof AggregatedCallSite) {
label = fOriginalTree.toDisplayString((AggregatedCallSite) originalTree);
for (ICallGraphProvider2 provider : fOriginalTrees) {
label = provider.toDisplayString((AggregatedCallSite) originalTree);
if (!label.startsWith("0x")) { //$NON-NLS-1$
break;
}
}
} else {
label = String.valueOf(originalTree.getObject().resolve(new ArrayList<>()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider2;
import org.eclipse.tracecompass.analysis.profiling.core.instrumented.InstrumentedCallStackAnalysis;
import org.eclipse.tracecompass.analysis.profiling.core.tree.ITree;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeProvider;
import org.eclipse.tracecompass.analysis.profiling.core.tree.WeightedTree;
import org.eclipse.tracecompass.analysis.profiling.core.tree.WeightedTreeSet;
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
Expand All @@ -54,8 +53,6 @@
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;

import com.google.common.collect.Iterables;

/**
* Builds a differential call graph using the differentialWeightedTreeSet from
* two sets of call graphs.
Expand Down Expand Up @@ -92,6 +89,7 @@ public DifferentialSeqCallGraphAnalysis() {
// TODO: Make a way to register tracetype->callstack IDs.
fCallStackAnalysisMap.put("org.eclipse.tracecompass.incubator.traceevent.core.trace", "org.eclipse.tracecompass.incubator.traceevent.analysis.callstack"); //$NON-NLS-1$ //$NON-NLS-2$
fCallStackAnalysisMap.put("org.eclipse.linuxtools.lttng2.ust.tracetype", "org.eclipse.tracecompass.lttng2.ust.core.analysis.callstack"); //$NON-NLS-1$ //$NON-NLS-2$
fCallStackAnalysisMap.put("org.eclipse.tracecompass.incubator.uftrace.trace", "org.eclipse.tracecompass.incubator.uftrace.analysis.callstack"); //$NON-NLS-1$ //$NON-NLS-2$
}

/**
Expand All @@ -103,25 +101,51 @@ public DifferentialSeqCallGraphAnalysis() {
*/
public DifferentialCallGraphProvider refreshDiffCG(@Nullable IProgressMonitor monitor) {
try (ScopeLog sl = new ScopeLog(LOGGER, Level.CONFIG, "DifferentialSequenceCGA::refresh()")) { //$NON-NLS-1$

Collection<WeightedTree<ICallStackSymbol>> originalTree = new ArrayList<>();
Collection<WeightedTree<ICallStackSymbol>> diffTree = new ArrayList<>();
WeightedTreeSet<ICallStackSymbol, Object> callGraphA = mergeCallGraph(fStartA, fEndA, getTraceListA());
List<String> tla = getTraceListA();
WeightedTreeSet<ICallStackSymbol, Object> callGraphA = mergeCallGraph(fStartA, fEndA, tla);

Collection<@NonNull ?> processes = callGraphA.getTreesForNamed(MERGE);
for (Object process : processes) {
originalTree.add((AggregatedCalledFunction) process);
String label = ""; //$NON-NLS-1$
for(String trace : tla) {
ICallGraphProvider2 reg = fTraceCallGraphRegistry.get(trace);
if (reg != null) {
label = reg.toDisplayString((AggregatedCallSite) process);
if (!label.startsWith("0x")) { //$NON-NLS-1$
break;
}
}
}
AggregatedCalledFunction p = new ResolvedFunction(label, (AggregatedCalledFunction)process);
originalTree.add(p);
}

WeightedTreeSet<ICallStackSymbol, Object> callGraphB = mergeCallGraph(fStartB, fEndB, getTraceListB());
List<String> tlb = getTraceListB();
WeightedTreeSet<ICallStackSymbol, Object> callGraphB = mergeCallGraph(fStartB, fEndB, tlb);
processes = callGraphB.getTreesForNamed(MERGE);
for (Object process : processes) {
diffTree.add((AggregatedCalledFunction) process);
String label = ""; //$NON-NLS-1$
for(String trace : tlb) {
ICallGraphProvider2 reg = fTraceCallGraphRegistry.get(trace);
if (reg != null) {
label = reg.toDisplayString((AggregatedCallSite) process);
if (!label.startsWith("0x")) { //$NON-NLS-1$
break;
}
}
}
AggregatedCalledFunction p = new ResolvedFunction(label, (AggregatedCalledFunction)process);
diffTree.add(p);
}

Collection<DifferentialWeightedTree<ICallStackSymbol>> trees;
trees = WeightedTreeUtils.diffTrees(originalTree, diffTree, fStatistic);

IWeightedTreeProvider<ICallStackSymbol, ICallStackElement, AggregatedCallSite> instrumentedCallStackAnalysis = Iterables.get(fTraceCallGraphRegistry.values(), 0);
fDifferentialCallGraphProvider = new DifferentialCallGraphProvider(instrumentedCallStackAnalysis, trees);
Collection<ICallGraphProvider2> instrumentedCallStackAnalyses = fTraceCallGraphRegistry.values();
fDifferentialCallGraphProvider = new DifferentialCallGraphProvider(instrumentedCallStackAnalyses, trees);
return fDifferentialCallGraphProvider;
}
}
Expand Down Expand Up @@ -220,7 +244,6 @@ private static List<CallGraph> addToCallGraph(ITmfTimestamp start, ITmfTimestamp
}
}
}

refreshDiffCG(monitor);
return fDifferentialCallGraphProvider;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.incubator.internal.executioncomparison.core;

import java.util.Collection;
import java.util.Objects;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.profiling.core.base.ICallStackSymbol;
import org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph2.AggregatedCalledFunction;
import org.eclipse.tracecompass.tmf.core.symbols.ISymbolProvider;

/**
* A pre-resolved function. Basically has an overridden equals on the name
*/
@SuppressWarnings("restriction")
public final class ResolvedFunction extends AggregatedCalledFunction {
private static class CSS implements ICallStackSymbol {
private String fLabel;

public CSS(String label) {
fLabel = label;
}

@Override
public String resolve(Collection<ISymbolProvider> providers) {
return fLabel;
}

@Override
public int hashCode() {
return Objects.hash(fLabel);
}

@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CSS other = (CSS) obj;
return Objects.equals(fLabel, other.fLabel);
}

}

private final String fLabel;

ResolvedFunction(String label, AggregatedCalledFunction toCopy) {
super(toCopy);
fLabel = label;
}

@Override
public ICallStackSymbol getObject() {
return new CSS(fLabel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.profiling.core.base.IDataPalette;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.AggregatedCallSite;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider2;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeProvider;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeSet;
import org.eclipse.tracecompass.analysis.profiling.core.tree.WeightedTree;
import org.eclipse.tracecompass.incubator.internal.analysis.core.weighted.tree.DifferentialPalette;

/**
Expand Down Expand Up @@ -76,34 +77,39 @@ public class DifferentialWeightedTreeProvider<@NonNull N> implements IWeightedTr

private final IWeightedTreeSet<N, Object, DifferentialWeightedTree<N>> fTreeSet;

private final IWeightedTreeProvider<N, ?, WeightedTree<N>> fOriginalTree;
private final List<MetricType> fAdditionalMetrics = new ArrayList<>(WEIGHT_TYPES);
private @Nullable IDataPalette fPalette = null;

protected final Collection<ICallGraphProvider2> fOriginalTrees;

/**
* Constructor
*
* @param originalTree
* The original tree provider, used to get information for texts and metrics.
* @param trees
* @param instrumentedCallStackAnalyses
* The original tree provider, used to get information for texts
* and metrics.
* @param treeSet
* The differential tree
*/
public DifferentialWeightedTreeProvider(IWeightedTreeProvider<N, ?, WeightedTree<N>> originalTree, Collection<DifferentialWeightedTree<N>> trees) {
public DifferentialWeightedTreeProvider(Collection<ICallGraphProvider2> originalTree, Collection<DifferentialWeightedTree<N>> trees) {
this(originalTree, DifferentialWeightedTreeSet.create(trees));
}

/**
* Constructor
*
* @param originalTree
* The original tree provider, used to get information for texts and metrics.
* The original tree provider, used to get information for texts
* and metrics.
* @param treeSet
* The differential tree set
*/
public DifferentialWeightedTreeProvider(IWeightedTreeProvider<N, ?, WeightedTree<N>> originalTree, DifferentialWeightedTreeSet<N> treeSet) {
fOriginalTree = originalTree;
public DifferentialWeightedTreeProvider(Collection<ICallGraphProvider2> originalTrees, DifferentialWeightedTreeSet<N> treeSet) {
fOriginalTrees = originalTrees;
fTreeSet = treeSet;
fAdditionalMetrics.addAll(fOriginalTree.getAdditionalMetrics());
for (ICallGraphProvider2 tree : fOriginalTrees) {
fAdditionalMetrics.addAll(tree.getAdditionalMetrics());
}
}

/**
Expand Down Expand Up @@ -138,12 +144,22 @@ public String getTitle() {

@Override
public @NonNull MetricType getWeightType() {
return fOriginalTree.getWeightType();
for(ICallGraphProvider2 tree : fOriginalTrees) {
return tree.getWeightType();
}
throw new IllegalStateException();
}

@Override
public String toDisplayString(DifferentialWeightedTree<N> tree) {
return fOriginalTree.toDisplayString(tree.getOriginalTree());
String returnValue = "";
for (ICallGraphProvider2 provider: fOriginalTrees) {
returnValue = provider.toDisplayString((AggregatedCallSite) tree.getOriginalTree());
if (!returnValue.startsWith("0x")) {
break;
}
}
return returnValue;
}

@Override
Expand All @@ -156,7 +172,10 @@ public Object getAdditionalMetric(DifferentialWeightedTree<N> object, int metric
if (metricIndex == 0) {
return object.getDifference();
}
return fOriginalTree.getAdditionalMetric(object.getOriginalTree(), metricIndex - 1);
for (ICallGraphProvider2 tree : fOriginalTrees) {
return tree.getAdditionalMetric((AggregatedCallSite) object.getOriginalTree(), metricIndex - 1);
}
throw new IllegalStateException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider2;
import org.eclipse.tracecompass.analysis.profiling.core.tree.ITree;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeProvider;
import org.eclipse.tracecompass.analysis.profiling.core.tree.IWeightedTreeSet;
Expand Down Expand Up @@ -172,7 +173,7 @@ private static <T> long[] calculateWeights(WeightedTree<@NonNull T> base, @Nulla
* set, or <code>null</code> if the 2 treesets have no elements in
* common
*/
public static <@NonNull N> @Nullable DifferentialWeightedTreeProvider<N> diffTreeSets(IWeightedTreeProvider<N, ?, WeightedTree<N>> provider,
public static <@NonNull N> @Nullable DifferentialWeightedTreeProvider<N> diffTreeSets(Collection<ICallGraphProvider2> provider,
IWeightedTreeSet<N, @NonNull ?, WeightedTree<N>> first,
IWeightedTreeSet<N, @NonNull ?, WeightedTree<N>> second) {
Collection<Pair<@NonNull ?, @NonNull ?>> pairedElements = pairElementsFromTrees(first, second);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
EPL-2.0 *************************************************************************** -->
<pattern version="1" id="system.gc.duration">
<head>
<traceType id="org.eclipse.tracecompass.jifa.gclog" />
<label value="GC Segments" />
</head>
<patternHandler>

<action id="segment_create">
<segment>
<segType>
Expand Down
Loading