Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profiling.ui: make reseting symbols asynchronous #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -741,28 +749,38 @@ private void updateConfigureSymbolsAction() {
}

private void resetSymbols() {
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries != null) {
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
ITimeGraphDataProvider<? extends TimeGraphEntryModel> 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$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, this part should be refactored into a separate function as we have 7 indentation levels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reseting -> Resetting

List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries != null) {
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = traceEntry.getProvider();
if (provider instanceof CallStackDataProvider) {
((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor());
}

// reset full and zoomed events here
Iterable<TimeGraphEntry> 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<TimeGraphEntry> 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
Expand Down
Loading