From b72451f986368f56328bd131b7b0e26897184407 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 30 Apr 2024 23:45:03 -0400 Subject: [PATCH] profiling.ui: make reseting symbols asynchronous Remove a slower bit of code from the UI thread. Change-Id: I7278b1466989f2ece24bb844621979641ef647c7 Signed-off-by: Matthew Khouzam --- .../ui/views/flamechart/FlameChartView.java | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/analysis/profiling/ui/views/flamechart/FlameChartView.java b/analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/analysis/profiling/ui/views/flamechart/FlameChartView.java index 57b59b6115..4bf26f6f08 100644 --- a/analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/analysis/profiling/ui/views/flamechart/FlameChartView.java +++ b/analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/analysis/profiling/ui/views/flamechart/FlameChartView.java @@ -28,9 +28,14 @@ import java.util.Map; import java.util.Objects; import java.util.function.Function; +import java.util.logging.Level; +import java.util.logging.Logger; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.action.Action; @@ -44,6 +49,8 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog; +import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder; import org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.provider.CallStackDataProvider; import org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.provider.CallStackEntryModel; import org.eclipse.tracecompass.internal.analysis.profiling.ui.Activator; @@ -105,6 +112,7 @@ public class FlameChartView extends BaseDataProviderTimeGraphView { /** View ID. */ public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.callstack"; //$NON-NLS-1$ + private static final Logger LOGGER = Logger.getLogger(FlameChartView.class.getName()); private static final String[] COLUMN_NAMES = new String[] { Messages.CallStackView_FunctionColumn, @@ -741,28 +749,38 @@ private void updateConfigureSymbolsAction() { } private void resetSymbols() { - List traceEntries = getEntryList(getTrace()); - if (traceEntries != null) { - for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) { - ITimeGraphDataProvider provider = traceEntry.getProvider(); - if (provider instanceof CallStackDataProvider) { - ((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor()); + try (FlowScopeLog fsl = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Reseting Symbols").setCategory("Flame Chart").build();) { //$NON-NLS-1$ //$NON-NLS-2$ + new Job("Reseting Symbols") { //$NON-NLS-1$ + @Override + protected IStatus run(@Nullable IProgressMonitor monitor) { + try (FlowScopeLog fsl2 = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Reseting Symbols - inner").setParentScope(fsl).build()) { //$NON-NLS-1$ + List traceEntries = getEntryList(getTrace()); + if (traceEntries != null) { + for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) { + ITimeGraphDataProvider provider = traceEntry.getProvider(); + if (provider instanceof CallStackDataProvider) { + ((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor()); + } + + // reset full and zoomed events here + Iterable flatten = Utils.flatten(traceEntry); + flatten.forEach(e -> e.setSampling(null)); + + // recompute full events + long start = traceEntry.getStartTime(); + long end = traceEntry.getEndTime(); + final long resolution = Long.max(1, (end - start) / getDisplayWidth()); + zoomEntries(flatten, start, end, resolution, new NullProgressMonitor()); + } + // zoomed events will be retriggered by refreshing + refresh(); + } + synchingToTime(getTimeGraphViewer().getSelectionBegin()); + return Status.OK_STATUS; + } } - - // reset full and zoomed events here - Iterable flatten = Utils.flatten(traceEntry); - flatten.forEach(e -> e.setSampling(null)); - - // recompute full events - long start = traceEntry.getStartTime(); - long end = traceEntry.getEndTime(); - final long resolution = Long.max(1, (end - start) / getDisplayWidth()); - zoomEntries(flatten, start, end, resolution, new NullProgressMonitor()); - } - // zoomed events will be retriggered by refreshing - refresh(); + }.schedule(); } - synchingToTime(getTimeGraphViewer().getSelectionBegin()); } @TmfSignalHandler @Override