LTTng: Bug 433214: Populate the UST memory view during analysis
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Fri, 6 Jun 2014 18:04:17 +0000 (14:04 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 13 Jun 2014 12:07:34 +0000 (08:07 -0400)
The UST memory view is populated as data is available, while the analysis is
being executed.

Change-Id: I75cd4cb2c57f2f29b394bff5adb81c08537c0440
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/28150
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.lttng2.ust.ui/src/org/eclipse/linuxtools/internal/lttng2/ust/ui/views/memusage/MemoryUsageViewer.java

index 732b884c79df163646a8dfefebc78365f9872d34..fcb2c06ed0fde3aaa34169dfd324e14f1fe3a3c4 100644 (file)
@@ -47,6 +47,9 @@ public class MemoryUsageViewer extends TmfCommonXLineChartViewer {
 
     private static final int BYTES_TO_KB = 1024;
 
+    // Timeout between updates in the updateData thread
+    private static final long BUILD_UPDATE_TIMEOUT = 500;
+
     /**
      * Constructor
      *
@@ -74,66 +77,79 @@ public class MemoryUsageViewer extends TmfCommonXLineChartViewer {
             if (getTrace() == null || fModule == null) {
                 return;
             }
+            fModule.waitForInitialization();
             ITmfStateSystem ss = fModule.getStateSystem();
             /* Don't wait for the module completion, when it's ready, we'll know */
             if (ss == null) {
                 return;
             }
+
             double[] xvalues = getXAxis(start, end, nb);
             setXAxis(xvalues);
-            List<Integer> tidQuarks = ss.getSubAttributes(-1, false);
-            long traceStart = getStartTime();
-            long traceEnd = getEndTime();
-            long offset = this.getTimeOffset();
-
-            /* Initialize quarks and series names */
-            for (int quark : tidQuarks) {
-                fYValues.put(quark, new double[xvalues.length]);
-                fMemoryQuarks.put(quark, ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE));
-                int procNameQuark = ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
-                try {
-                    ITmfStateValue procnameValue = ss.querySingleState(start, procNameQuark).getStateValue();
-                    String procname = new String();
-                    if (!procnameValue.isNull()) {
-                        procname = procnameValue.unboxStr();
-                    }
-                    fSeriesName.put(quark, new String(procname + ' ' + '(' + ss.getAttributeName(quark) + ')').trim());
-                } catch (TimeRangeException e) {
-                    fSeriesName.put(quark, '(' + ss.getAttributeName(quark) + ')');
-                }
-            }
 
-            /*
-             * TODO: It should only show active threads in the time range. If a
-             * tid does not have any memory value (only 1 interval in the time
-             * range with value null or 0), then its series should not be
-             * displayed.
-             */
-            double yvalue = 0.0;
-            for (int i = 0; i < xvalues.length; i++) {
+            boolean complete = false;
+            long currentEnd = start;
+
+            while (!complete && currentEnd < end) {
                 if (monitor.isCanceled()) {
                     return;
                 }
-                double x = xvalues[i];
-                long time = (long) x + offset;
-                // make sure that time is in the trace range after double to
-                // long conversion
-                time = time < traceStart ? traceStart : time;
-                time = time > traceEnd ? traceEnd : time;
+                complete = ss.waitUntilBuilt(BUILD_UPDATE_TIMEOUT);
+                currentEnd = ss.getCurrentEndTime();
+                List<Integer> tidQuarks = ss.getSubAttributes(-1, false);
+                long traceStart = getStartTime();
+                long traceEnd = getEndTime();
+                long offset = this.getTimeOffset();
 
+                /* Initialize quarks and series names */
                 for (int quark : tidQuarks) {
+                    fYValues.put(quark, new double[xvalues.length]);
+                    fMemoryQuarks.put(quark, ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE));
+                    int procNameQuark = ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
                     try {
-                        yvalue = ss.querySingleState(time, fMemoryQuarks.get(quark)).getStateValue().unboxLong() / BYTES_TO_KB;
-                        fYValues.get(quark)[i] = yvalue;
+                        ITmfStateValue procnameValue = ss.querySingleState(start, procNameQuark).getStateValue();
+                        String procname = new String();
+                        if (!procnameValue.isNull()) {
+                            procname = procnameValue.unboxStr();
+                        }
+                        fSeriesName.put(quark, new String(procname + ' ' + '(' + ss.getAttributeName(quark) + ')').trim());
                     } catch (TimeRangeException e) {
-                        fYValues.get(quark)[i] = 0;
+                        fSeriesName.put(quark, '(' + ss.getAttributeName(quark) + ')');
                     }
                 }
+
+                /*
+                 * TODO: It should only show active threads in the time range. If a
+                 * tid does not have any memory value (only 1 interval in the time
+                 * range with value null or 0), then its series should not be
+                 * displayed.
+                 */
+                double yvalue = 0.0;
+                for (int i = 0; i < xvalues.length; i++) {
+                    if (monitor.isCanceled()) {
+                        return;
+                    }
+                    double x = xvalues[i];
+                    long time = (long) x + offset;
+                    // make sure that time is in the trace range after double to
+                    // long conversion
+                    time = time < traceStart ? traceStart : time;
+                    time = time > traceEnd ? traceEnd : time;
+
+                    for (int quark : tidQuarks) {
+                        try {
+                            yvalue = ss.querySingleState(time, fMemoryQuarks.get(quark)).getStateValue().unboxLong() / BYTES_TO_KB;
+                            fYValues.get(quark)[i] = yvalue;
+                        } catch (TimeRangeException e) {
+                            fYValues.get(quark)[i] = 0;
+                        }
+                    }
+                }
+                for (int quark : tidQuarks) {
+                    setSeries(fSeriesName.get(quark), fYValues.get(quark));
+                }
+                updateDisplay();
             }
-            for (int quark : tidQuarks) {
-                setSeries(fSeriesName.get(quark), fYValues.get(quark));
-            }
-            updateDisplay();
         } catch (AttributeNotFoundException | StateValueTypeException | StateSystemDisposedException e) {
             Activator.logError("Error updating the data of the Memory usage view", e); //$NON-NLS-1$
         }
This page took 0.029731 seconds and 5 git commands to generate.