Skip to content

Commit 408d286

Browse files
profiling.ui: make reseting symbols asynchronous
Remove a slower bit of code from the UI thread. Change-Id: I7278b1466989f2ece24bb844621979641ef647c7 Signed-off-by: Matthew Khouzam <[email protected]> Signed-off-by: Arnaud Fiorini <[email protected]>
1 parent f03ccc7 commit 408d286

File tree

2 files changed

+51
-6
lines changed
  • analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass

2 files changed

+51
-6
lines changed

analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/analysis/profiling/ui/views/flamechart/FlameChartView.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@
2828
import java.util.Map;
2929
import java.util.Objects;
3030
import java.util.function.Function;
31+
import java.util.logging.Level;
32+
import java.util.logging.Logger;
3133

3234
import org.eclipse.core.runtime.IProgressMonitor;
35+
import org.eclipse.core.runtime.IStatus;
3336
import org.eclipse.core.runtime.NullProgressMonitor;
37+
import org.eclipse.core.runtime.Status;
38+
import org.eclipse.core.runtime.jobs.Job;
3439
import org.eclipse.jdt.annotation.NonNull;
3540
import org.eclipse.jdt.annotation.Nullable;
3641
import org.eclipse.jface.action.Action;
@@ -84,6 +89,8 @@
8489
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
8590
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
8691
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
92+
import org.eclipse.tracecompass.traceeventlogger.LogUtils.FlowScopeLog;
93+
import org.eclipse.tracecompass.traceeventlogger.LogUtils.FlowScopeLogBuilder;
8794
import org.eclipse.ui.IEditorPart;
8895
import org.eclipse.ui.IWorkbenchActionConstants;
8996

@@ -105,6 +112,7 @@ public class FlameChartView extends BaseDataProviderTimeGraphView {
105112

106113
/** View ID. */
107114
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.callstack"; //$NON-NLS-1$
115+
private static final Logger LOGGER = Logger.getLogger(FlameChartView.class.getName());
108116

109117
private static final String[] COLUMN_NAMES = new String[] {
110118
Messages.CallStackView_FunctionColumn,
@@ -740,13 +748,13 @@ private void updateConfigureSymbolsAction() {
740748
getConfigureSymbolsAction().setEnabled(providerPages.length > 0);
741749
}
742750

743-
private void resetSymbols() {
751+
private IStatus resetSymbolsSync() {
744752
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
745753
if (traceEntries != null) {
746754
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
747755
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = traceEntry.getProvider();
748-
if (provider instanceof CallStackDataProvider) {
749-
((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor());
756+
if (provider instanceof CallStackDataProvider callstackProvider) {
757+
callstackProvider.resetFunctionNames(new NullProgressMonitor());
750758
}
751759

752760
// reset full and zoomed events here
@@ -763,7 +771,22 @@ private void resetSymbols() {
763771
refresh();
764772
}
765773
synchingToTime(getTimeGraphViewer().getSelectionBegin());
774+
return Status.OK_STATUS;
766775
}
776+
777+
private void resetSymbols() {
778+
try (FlowScopeLog flowParent = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Resetting Symbols - Job launch").setCategory("Flame Chart").build();) { //$NON-NLS-1$ //$NON-NLS-2$
779+
new Job("Resetting Symbols") { //$NON-NLS-1$
780+
@Override
781+
protected IStatus run(@Nullable IProgressMonitor monitor) {
782+
try (FlowScopeLog log = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Resetting Symbols").setParentScope(flowParent).build()) { //$NON-NLS-1$
783+
return resetSymbolsSync();
784+
}
785+
}
786+
}.schedule();
787+
}
788+
}
789+
767790
@TmfSignalHandler
768791
@Override
769792
public void traceClosed(@Nullable TmfTraceClosedSignal signal) {

analysis/org.eclipse.tracecompass.analysis.profiling.ui/src/org/eclipse/tracecompass/internal/analysis/profiling/ui/FlameChartView.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
import java.util.HashMap;
1919
import java.util.List;
2020
import java.util.Map;
21+
import java.util.logging.Level;
22+
import java.util.logging.Logger;
2123

2224
import org.eclipse.core.runtime.IProgressMonitor;
25+
import org.eclipse.core.runtime.IStatus;
2326
import org.eclipse.core.runtime.NullProgressMonitor;
27+
import org.eclipse.core.runtime.Status;
28+
import org.eclipse.core.runtime.jobs.Job;
2429
import org.eclipse.jdt.annotation.NonNull;
2530
import org.eclipse.jdt.annotation.Nullable;
2631
import org.eclipse.jface.action.Action;
@@ -78,6 +83,8 @@
7883
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
7984
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
8085
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
86+
import org.eclipse.tracecompass.traceeventlogger.LogUtils.FlowScopeLog;
87+
import org.eclipse.tracecompass.traceeventlogger.LogUtils.FlowScopeLogBuilder;
8188
import org.eclipse.ui.IEditorPart;
8289
import org.eclipse.ui.IWorkbenchActionConstants;
8390

@@ -100,6 +107,7 @@ public class FlameChartView extends BaseDataProviderTimeGraphView {
100107

101108
/** View ID. */
102109
public static final String ID = "org.eclipse.tracecompass.analysis.profiling.ui.flamechart"; //$NON-NLS-1$
110+
private static final Logger LOGGER = Logger.getLogger(FlameChartView.class.getName());
103111

104112
private static final String[] COLUMN_NAMES = new String[] {
105113
Messages.CallStackView_FunctionColumn,
@@ -667,13 +675,13 @@ private void updateConfigureSymbolsAction() {
667675
getConfigureSymbolsAction().setEnabled(providerPages.length > 0);
668676
}
669677

670-
private void resetSymbols() {
678+
private IStatus resetSymbolsSync() {
671679
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
672680
if (traceEntries != null) {
673681
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
674682
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = traceEntry.getProvider();
675-
if (provider instanceof FlameChartDataProvider) {
676-
((FlameChartDataProvider) provider).resetFunctionNames(new NullProgressMonitor());
683+
if (provider instanceof FlameChartDataProvider callstackProvider) {
684+
callstackProvider.resetFunctionNames(new NullProgressMonitor());
677685
}
678686

679687
// reset full and zoomed events here
@@ -690,6 +698,20 @@ private void resetSymbols() {
690698
refresh();
691699
}
692700
synchingToTime(getTimeGraphViewer().getSelectionBegin());
701+
return Status.OK_STATUS;
702+
}
703+
704+
private void resetSymbols() {
705+
try (FlowScopeLog flowParent = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Resetting Symbols - Job launch").setCategory("Flame Chart").build();) { //$NON-NLS-1$ //$NON-NLS-2$
706+
new Job("Resetting Symbols") { //$NON-NLS-1$
707+
@Override
708+
protected IStatus run(@Nullable IProgressMonitor monitor) {
709+
try (FlowScopeLog log = new FlowScopeLogBuilder(LOGGER, Level.FINE, "Resetting Symbols").setParentScope(flowParent).build()) { //$NON-NLS-1$
710+
return resetSymbolsSync();
711+
}
712+
}
713+
}.schedule();
714+
}
693715
}
694716

695717
@TmfSignalHandler

0 commit comments

Comments
 (0)