Bug 1465954 - Set IDLE and OTHER categories on stack frames in the Java thread. r=m_kato
authorMarkus Stange <mstange@themasta.com>
Thu, 31 May 2018 16:20:51 -0400
changeset 482428 d67618d9ba00e9384114989daddbbdc86daf1ad7
parent 482427 5d45c705980a056136fc9c0c85334fcbe95a3da6
child 482464 690cb3015db6645b335ac4835a50073cb6a3e23c
child 482466 47f25d0b1e1d7986a90aace67c5d90f42959e63f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1465954
milestone63.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 1465954 - Set IDLE and OTHER categories on stack frames in the Java thread. r=m_kato MozReview-Commit-ID: EFEOLUO5VyA
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1795,25 +1795,40 @@ CollectJavaThreadProfileData()
   while (true) {
     double sampleTime = java::GeckoJavaSampler::GetSampleTime(0, sampleId);
     if (sampleTime == 0.0) {
       break;
     }
 
     buffer->AddThreadIdEntry(0);
     buffer->AddEntry(ProfileBufferEntry::Time(sampleTime));
+    bool parentFrameWasIdleFrame = false;
     int frameId = 0;
     while (true) {
       jni::String::LocalRef frameName =
         java::GeckoJavaSampler::GetFrameName(0, sampleId, frameId++);
       if (!frameName) {
         break;
       }
-      buffer->CollectCodeLocation("", frameName->ToCString().get(), -1,
-                                  Nothing());
+      nsCString frameNameString = frameName->ToCString();
+
+      // Compute a category for the frame:
+      //  - IDLE for the wait function android.os.MessageQueue.nativePollOnce()
+      //  - OTHER for any function that's directly called by that wait function
+      //  - no category on everything else
+      Maybe<js::ProfilingStackFrame::Category> category;
+      if (frameNameString.EqualsLiteral("android.os.MessageQueue.nativePollOnce()")) {
+        category = Some(js::ProfilingStackFrame::Category::IDLE);
+        parentFrameWasIdleFrame = true;
+      } else if (parentFrameWasIdleFrame) {
+        category = Some(js::ProfilingStackFrame::Category::OTHER);
+        parentFrameWasIdleFrame = false;
+      }
+
+      buffer->CollectCodeLocation("", frameNameString.get(), -1, category);
     }
     sampleId++;
   }
   return buffer;
 }
 #endif
 
 static void