Skip to content

Commit af19563

Browse files
arfiobhufmann
authored andcommitted
profiling: cache symbol key interval
To resolve symbols, the method retrieveSymbolKeyAt will query a symbol key attribute for every interval in a query2d. This create a significant overhead that can easily be avoided if we cache this interval. For all current use cases, the symbol key interval is unique for each trace. Signed-off-by: Arnaud Fiorini <[email protected]>
1 parent a7673d5 commit af19563

File tree

1 file changed

+6
-0
lines changed
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented

1 file changed

+6
-0
lines changed

analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/InstrumentedCallStackElement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class InstrumentedCallStackElement extends CallStackElement {
5353
private final int fQuark;
5454
private final IHostIdResolver fHostResolver;
5555
private final @Nullable IThreadIdResolver fThreadIdResolver;
56+
private @Nullable ITmfStateInterval fSymbolKeyInterval = null;
5657
private final Map<Integer, ICallStackElement> fNextElements = new HashMap<>();
5758

5859
private @Nullable CallStack fCallstack = null;
@@ -178,13 +179,18 @@ private static Collection<ICallStackElement> getNextElements(InstrumentedGroupDe
178179
public int retrieveSymbolKeyAt(long startTime) {
179180
int processId = CallStackElement.DEFAULT_SYMBOL_KEY;
180181
if (fQuark != ITmfStateSystem.ROOT_ATTRIBUTE) {
182+
ITmfStateInterval symbolKeyInterval = fSymbolKeyInterval;
183+
if (symbolKeyInterval != null && symbolKeyInterval.intersects(startTime)) {
184+
return symbolKeyInterval.getValueInt();
185+
}
181186
try {
182187
// Query a time that is within the bounds of the state system
183188
long start = Math.max(fStateSystem.getStartTime(), startTime);
184189
start = Math.max(start, fStateSystem.getCurrentEndTime());
185190

186191
// Query the value of the quark at the requested time
187192
ITmfStateInterval interval = fStateSystem.querySingleState(start, fQuark);
193+
fSymbolKeyInterval = interval;
188194
ITmfStateValue processStateValue = interval.getStateValue();
189195
// If the state value is an integer, assume it is the symbol we
190196
// are looking for

0 commit comments

Comments
 (0)