bug 1530011: When calculating event durations, if we reach the end of the event list then use the last event as the end event for any events that remain on the stack r=sfink
authorDenis Palmeiro <dpalmeiro@mozilla.com>
Wed, 08 May 2019 20:49:19 +0000
changeset 531966 244b0ee2c89066b418c7088acf880f5f4eb6fa3d
parent 531965 5b5baa11e448f70893bc096aa518b4f58d07cc2f
child 531967 2e3522f77b0f686663145bdce20ffceef3909896
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1530011
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1530011: When calculating event durations, if we reach the end of the event list then use the last event as the end event for any events that remain on the stack r=sfink An assert occurs while calculating durations whenever we reach the end of the event list and we didn't encounter the TraceLogger_Stop events for events that were still active when the profiler stopped. The fix is to use the last event as the end event for any remaining events on the stack. Differential Revision: https://phabricator.services.mozilla.com/D29926
js/src/vm/TraceLogging.cpp
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -898,16 +898,34 @@ size_t JS::TraceLoggerDurationImpl::Next
             return 0;
           }
 
         } else if (TLTextIdIsTreeEvent(id)) {
           if (!eventStack.append(j)) {
             return 0;
           }
         }
+
+        // If we reach the end of the list, use the last event as the end
+        // event for all events remaining on the stack.
+        if (j == events.size() - 1) {
+          while (!eventStack.empty()) {
+            uint32_t prev = eventStack.popCopy();
+            double delta =
+                (events[j].time - events[prev].time).ToMicroseconds();
+            if (prev == *dataIndex) {
+              MOZ_ASSERT(eventStack.empty());
+              duration = delta;
+            } else {
+              if (!eventMap.putNew(prev, delta)) {
+                return 0;
+              }
+            }
+          }
+        }
       }
     }
 
     buffer[bufferIndex++] = duration;
     if (bufferIndex == bufferSize) {
       break;
     }
   }