tmf: Bug 491548: Do not incrementally build full time graph event list
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 12 Apr 2016 21:42:22 +0000 (17:42 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 13 Apr 2016 22:17:17 +0000 (18:17 -0400)
The full event list should be recomputed for the full range at every
iteration of the build thread. If built incrementally it can create too
many events in the full event list.

The build thread should not insert NullTimeEvent in the full event list.

Change-Id: I2523291197b2d93267b2aa799e6126ea74eea0f9
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/70519
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java

index 822685c070d5f6ecd789675c869181a5c6a87fb1..2cde3f81d5ae3d6262d17788ea0a92fc6c3704e9 100644 (file)
@@ -275,9 +275,7 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
             final long resolution = Math.max(1, (end - ssq.getStartTime()) / getDisplayWidth());
             setEndTime(Math.max(getEndTime(), end + 1));
             final List<Integer> threadQuarks = ssq.getQuarks(Attributes.THREADS, "*"); //$NON-NLS-1$
-            final long qStart = start;
-            final long qEnd = end;
-            queryFullStates(ssq, qStart, qEnd, resolution, monitor, new IQueryHandler() {
+            queryFullStates(ssq, start, end, resolution, monitor, new IQueryHandler() {
                 @Override
                 public void handle(List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState) {
                     for (int threadQuark : threadQuarks) {
@@ -364,12 +362,17 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
                         }
                     }
                     updateTree(entryList, parentTrace, ssq);
+                }
+            });
 
+            queryFullStates(ssq, ssq.getStartTime(), end, resolution, monitor, new IQueryHandler() {
+                @Override
+                public void handle(@NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState) {
                     for (final TimeGraphEntry entry : getEntryList(ssq)) {
                         if (monitor.isCanceled()) {
                             return;
                         }
-                        buildStatusEvents(trace, parentTrace, ssq, fullStates, prevFullState, (ControlFlowEntry) entry, monitor, qStart, qEnd);
+                        buildStatusEvents(trace, parentTrace, ssq, fullStates, prevFullState, (ControlFlowEntry) entry, monitor, ssq.getStartTime(), end);
                     }
                 }
             });
@@ -427,8 +430,13 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
             if (eventList == null) {
                 return;
             }
-            for (ITimeEvent event : eventList) {
-                entry.addEvent(event);
+            /* Start a new event list on first iteration, then append to it */
+            if (prevFullState == null) {
+                entry.setEventList(eventList);
+            } else {
+                for (ITimeEvent event : eventList) {
+                    entry.addEvent(event);
+                }
             }
             if (parentTrace.equals(getTrace())) {
                 redraw();
index 933470ae1479bfc67275c551d65e26f84f0ff9b6..fe4edbd3cd33e46492d924e1e71d02d7be92b836 100644 (file)
@@ -198,9 +198,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
             }
             final List<@NonNull TimeGraphEntry> traceEntryChildren = traceEntry.getChildren();
             final long resolution = Math.max(1, (endTime - ssq.getStartTime()) / getDisplayWidth());
-            final long qStart = start;
-            final long qEnd = end;
-            queryFullStates(ssq, qStart, qEnd, resolution, monitor, new IQueryHandler() {
+            queryFullStates(ssq, ssq.getStartTime(), end, resolution, monitor, new IQueryHandler() {
                 @Override
                 public void handle(List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState) {
                     for (TimeGraphEntry child : traceEntryChildren) {
@@ -216,8 +214,13 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
                     }
                     List<ITimeEvent> eventList = getEventList(entry, ssq, fullStates, prevFullState, monitor);
                     if (eventList != null) {
-                        for (ITimeEvent event : eventList) {
-                            entry.addEvent(event);
+                        /* Start a new event list on first iteration, then append to it */
+                        if (prevFullState == null) {
+                            entry.setEventList(eventList);
+                        } else {
+                            for (ITimeEvent event : eventList) {
+                                entry.addEvent(event);
+                            }
                         }
                     }
                     for (TimeGraphEntry child : entry.getChildren()) {
@@ -348,6 +351,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
              */
             return null;
         }
+        boolean isZoomThread = Thread.currentThread() instanceof ZoomThread;
         eventList = new ArrayList<>(fullStates.size());
         ITmfStateInterval lastInterval = prevFullState == null || statusQuark >= prevFullState.size() ? null : prevFullState.get(statusQuark);
         long lastStartTime = lastInterval == null ? -1 : lastInterval.getStartTime();
@@ -372,7 +376,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
                     eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));
                 }
                 eventList.add(new TimeEvent(entry, time, duration, status));
-            } else {
+            } else if (isZoomThread) {
                 eventList.add(new NullTimeEvent(entry, time, duration));
             }
             lastStartTime = time;
@@ -383,6 +387,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
 
     private static List<ITimeEvent> createIrqEventsList(ITimeGraphEntry entry, List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState, IProgressMonitor monitor, int quark) {
         List<ITimeEvent> eventList;
+        boolean isZoomThread = Thread.currentThread() instanceof ZoomThread;
         eventList = new ArrayList<>(fullStates.size());
         ITmfStateInterval lastInterval = prevFullState == null || quark >= prevFullState.size() ? null : prevFullState.get(quark);
         long lastStartTime = lastInterval == null ? -1 : lastInterval.getStartTime();
@@ -415,7 +420,9 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
                      */
                     eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime, -1));
                 }
-                eventList.add(new NullTimeEvent(entry, time, duration));
+                if (isZoomThread) {
+                    eventList.add(new NullTimeEvent(entry, time, duration));
+                }
                 lastIsNull = true;
             }
             lastStartTime = time;
index f63595e784f3e87298a1da76c4fe1613480c6fd5..6acb9937cc0ec0d8ef444198fb13bb834482663e 100644 (file)
@@ -643,7 +643,7 @@ public class CallStackView extends AbstractTimeGraphView {
                     if (monitor.isCanceled()) {
                         return;
                     }
-                    buildStatusEvents(parentTrace, (CallStackEntry) callStackEntry, monitor, start, end);
+                    buildStatusEvents(parentTrace, (CallStackEntry) callStackEntry, monitor, ss.getStartTime(), end);
                 }
             }
             start = end;
@@ -664,9 +664,7 @@ public class CallStackView extends AbstractTimeGraphView {
         long resolution = Math.max(1, (end - ss.getStartTime()) / getDisplayWidth());
         List<ITimeEvent> eventList = getEventList(entry, start, end + 1, resolution, monitor);
         if (eventList != null) {
-            for (ITimeEvent event : eventList) {
-                entry.addEvent(event);
-            }
+            entry.setEventList(eventList);
         }
         if (trace == getTrace()) {
             redraw();
@@ -688,6 +686,7 @@ public class CallStackView extends AbstractTimeGraphView {
         if (end <= start) {
             return null;
         }
+        boolean isZoomThread = Thread.currentThread() instanceof ZoomThread;
         List<ITimeEvent> eventList = null;
         try {
             List<ITmfStateInterval> stackIntervals = StateSystemUtils.queryHistoryRange(ss, entry.getQuark(), start, end - 1, resolution, monitor);
@@ -706,7 +705,7 @@ public class CallStackView extends AbstractTimeGraphView {
                     eventList.add(new CallStackEvent(entry, time, duration, value));
                     lastIsNull = false;
                 } else {
-                    if (lastEndTime == -1) {
+                    if (lastEndTime == -1 && isZoomThread) {
                         // add null event if it intersects the start time
                         eventList.add(new NullTimeEvent(entry, time, duration));
                     } else {
@@ -714,7 +713,7 @@ public class CallStackView extends AbstractTimeGraphView {
                             // add unknown event if between two null states
                             eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));
                         }
-                        if (time + duration >= endTime) {
+                        if (time + duration >= endTime && isZoomThread) {
                             // add null event if it intersects the end time
                             eventList.add(new NullTimeEvent(entry, time, duration));
                         }
This page took 0.032087 seconds and 5 git commands to generate.