Bug 1447973 - Convert DOMEvent markers to use tracing markers r?mstange draft
authorNazım Can Altınova <canaltinova@gmail.com>
Mon, 21 May 2018 23:54:44 +0200
changeset 797931 410dab9b8cd59dc17c8f002a0c919566b2d45ee5
parent 797912 51f2535c797495f1f4e864072c2449b7c28669de
push id110623
push userbmo:canaltinova@gmail.com
push dateMon, 21 May 2018 23:54:19 +0000
reviewersmstange
bugs1447973
milestone62.0a1
Bug 1447973 - Convert DOMEvent markers to use tracing markers r?mstange Changed DOMEventMarkerPayload to use tracing markers to be able to see unfinished DOMEvents in the profiler. DOMEventMarkerPayload was containing both start and end timestamps and we were adding it once DOMEvent finishes. Now, we are adding two tracing markers. Once the event starts and once the event ends. That makes the start of the event visible on the profiler. MozReview-Commit-ID: Gak6dGsgMDt
dom/events/EventListenerManager.cpp
tools/profiler/core/ProfilerMarkerPayload.cpp
tools/profiler/core/platform.cpp
tools/profiler/public/ProfilerMarkerPayload.h
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -1269,27 +1269,34 @@ EventListenerManager::HandleEventInterna
               // Add a profiler label and a profiler marker for the actual
               // dispatch of the event.
               // This is a very hot code path, so we need to make sure not to
               // do this extra work when we're not profiling.
               nsAutoString typeStr;
               (*aDOMEvent)->GetType(typeStr);
               AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
                 "EventListenerManager::HandleEventInternal", EVENTS, typeStr);
-              TimeStamp startTime = TimeStamp::Now();
 
-              rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
-
-              TimeStamp endTime = TimeStamp::Now();
               uint16_t phase = (*aDOMEvent)->EventPhase();
               profiler_add_marker(
                 "DOMEvent",
                 MakeUnique<DOMEventMarkerPayload>(typeStr, phase,
                                                   aEvent->mTimeStamp,
-                                                  startTime, endTime));
+                                                  "DOMEvent",
+                                                  TRACING_INTERVAL_START));
+
+              rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
+
+              phase = (*aDOMEvent)->EventPhase();
+              profiler_add_marker(
+                "DOMEvent",
+                MakeUnique<DOMEventMarkerPayload>(typeStr, phase,
+                                                  aEvent->mTimeStamp,
+                                                  "DOMEvent",
+                                                  TRACING_INTERVAL_END));
             } else
 #endif
             {
               rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
             }
 
             if (NS_FAILED(rv)) {
               aEvent->mFlags.mExceptionWasRaised = true;
--- a/tools/profiler/core/ProfilerMarkerPayload.cpp
+++ b/tools/profiler/core/ProfilerMarkerPayload.cpp
@@ -96,17 +96,18 @@ UserTimingMarkerPayload::StreamPayload(S
   }
 }
 
 void
 DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                      const TimeStamp& aProcessStartTime,
                                      UniqueStacks& aUniqueStacks)
 {
-  StreamCommonProps("DOMEvent", aWriter, aProcessStartTime, aUniqueStacks);
+  TracingMarkerPayload::StreamPayload(aWriter, aProcessStartTime, aUniqueStacks);
+
   WriteTime(aWriter, aProcessStartTime, mTimeStamp, "timeStamp");
   aWriter.StringProperty("eventType", NS_ConvertUTF16toUTF8(mEventType).get());
   aWriter.IntProperty("phase", mPhase);
 }
 
 void
 LayerTranslationMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                              const TimeStamp& aProcessStartTime,
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1559,17 +1559,17 @@ StreamTaskTracer(PSLockRef aLock, Splice
 }
 
 static void
 StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter,
                          bool aIsShuttingDown)
 {
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
-  aWriter.IntProperty("version", 9);
+  aWriter.IntProperty("version", 10);
 
 #if defined(MOZ_SOURCE_URL)
   aWriter.StringProperty("sourceURL", "@MOZ_SOURCE_URL@");
 #endif
 
   // The "startTime" field holds the number of milliseconds since midnight
   // January 1, 1970 GMT. This grotty code computes (Now - (Now -
   // ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
--- a/tools/profiler/public/ProfilerMarkerPayload.h
+++ b/tools/profiler/public/ProfilerMarkerPayload.h
@@ -116,24 +116,23 @@ public:
 
   DECL_STREAM_PAYLOAD
 
 private:
   const char* mSource;
   mozilla::UniqueFreePtr<char> mFilename;
 };
 
-class DOMEventMarkerPayload : public ProfilerMarkerPayload
+class DOMEventMarkerPayload : public TracingMarkerPayload
 {
 public:
   DOMEventMarkerPayload(const nsAString& aEventType, uint16_t aPhase,
                         const mozilla::TimeStamp& aTimeStamp,
-                        const mozilla::TimeStamp& aStartTime,
-                        const mozilla::TimeStamp& aEndTime)
-    : ProfilerMarkerPayload(aStartTime, aEndTime)
+                        const char* aCategory, TracingKind aKind)
+    : TracingMarkerPayload(aCategory, aKind)
     , mTimeStamp(aTimeStamp)
     , mEventType(aEventType)
     , mPhase(aPhase)
   {}
 
   DECL_STREAM_PAYLOAD
 
 private: