Bug 722124 - Profiler cleanup. r=ehsan
authorBenoit Girard <b56girard@gmail.com>
Sun, 29 Jan 2012 01:56:41 -0500
changeset 86077 9a02a8985f9dad5b5f0d3ca2ba851b50bda06149
parent 86076 f60a70c9120f96788cd41d2c8e8b4ec080da81ea
child 86078 880df44948d80c9aa536aee1d1a1151e84e9ae3b
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs722124
milestone13.0a1
Bug 722124 - Profiler cleanup. r=ehsan
tools/profiler/Makefile.in
tools/profiler/TableTicker.cpp
tools/profiler/nsIProfiler.idl
tools/profiler/platform-linux.cc
tools/profiler/platform-win32.cc
tools/profiler/platform.h
tools/profiler/public/nsIProfiler.idl
tools/profiler/sampler.h
tools/profiler/shared-libraries-linux.cc
tools/profiler/shared-libraries-macos.cc
tools/profiler/shared-libraries-win32.cc
tools/profiler/shared-libraries.h
tools/profiler/sps/TableTicker.cpp
tools/profiler/sps/platform-linux.cc
tools/profiler/sps/platform-win32.cc
tools/profiler/sps/platform.h
tools/profiler/sps/shared-libraries-linux.cc
tools/profiler/sps/shared-libraries-macos.cc
tools/profiler/sps/shared-libraries-win32.cc
tools/profiler/sps/shared-libraries.h
tools/profiler/sps/sps_sampler.h
tools/profiler/sps/thread_helper.h
tools/profiler/sps/v8-support.h
tools/profiler/sps_sampler.h
tools/profiler/thread_helper.h
tools/profiler/v8-support.h
--- a/tools/profiler/Makefile.in
+++ b/tools/profiler/Makefile.in
@@ -35,21 +35,17 @@
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 DEPTH       = ../..
 topsrcdir	  = @top_srcdir@
 srcdir      = @srcdir@
-VPATH       = \
-  $(srcdir) \
-  $(srcdir)/sps \
-  $(srcdir)/public \
-  $(NULL)
+VPATH       = $(srcdir)
 
 include $(DEPTH)/config/autoconf.mk
 
 EXPORTS = \
   sampler.h \
   sps_sampler.h \
   thread_helper.h \
   $(NULL)
@@ -109,12 +105,10 @@ DEFINES += -DMOZ_ENABLE_PROFILER_SPS
 
 CPPSRCS += \
   shared-libraries-win32.cc \
   platform-win32.cc \
   TableTicker.cpp \
   $(NULL)
 endif
 
-
-
 include $(topsrcdir)/config/rules.mk
 
rename from tools/profiler/sps/TableTicker.cpp
rename to tools/profiler/TableTicker.cpp
--- a/tools/profiler/sps/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -62,38 +62,38 @@
 #ifdef USE_NS_STACKWALK
  #include "nsStackWalk.h"
 #endif
 
 using std::string;
 using namespace mozilla;
 
 #ifdef XP_WIN
-#include <windows.h>
-#define getpid GetCurrentProcessId
+ #include <windows.h>
+ #define getpid GetCurrentProcessId
 #else
-#include <unistd.h>
+ #include <unistd.h>
 #endif
 
 #ifndef MAXPATHLEN
-#ifdef PATH_MAX
-#define MAXPATHLEN PATH_MAX
-#elif defined(MAX_PATH)
-#define MAXPATHLEN MAX_PATH
-#elif defined(_MAX_PATH)
-#define MAXPATHLEN _MAX_PATH
-#elif defined(CCHMAXPATH)
-#define MAXPATHLEN CCHMAXPATH
-#else
-#define MAXPATHLEN 1024
-#endif
+ #ifdef PATH_MAX
+  #define MAXPATHLEN PATH_MAX
+ #elif defined(MAX_PATH)
+  #define MAXPATHLEN MAX_PATH
+ #elif defined(_MAX_PATH)
+  #define MAXPATHLEN _MAX_PATH
+ #elif defined(CCHMAXPATH)
+  #define MAXPATHLEN CCHMAXPATH
+ #else
+  #define MAXPATHLEN 1024
+ #endif
 #endif
 
 #if _MSC_VER
-#define snprintf _snprintf
+ #define snprintf _snprintf
 #endif
 
 
 mozilla::tls::key pkey_stack;
 mozilla::tls::key pkey_ticker;
 // We need to track whether we've been initialized otherwise
 // we end up using pkey_stack without initializing it.
 // Because pkey_stack is totally opaque to us we can't reuse
@@ -316,19 +316,19 @@ class TableTicker: public Sampler {
   TableTicker(int aInterval, int aEntrySize, Stack *aStack,
               const char** aFeatures, uint32_t aFeatureCount)
     : Sampler(aInterval, true)
     , mProfile(aEntrySize)
     , mStack(aStack)
     , mSaveRequested(false)
   {
     mUseStackWalk = hasFeature(aFeatures, aFeatureCount, "stackwalk");
-    mProfile.addTag(ProfileEntry('m', "Start"));
     //XXX: It's probably worth splitting the jank profiler out from the regular profiler at some point
     mJankOnly = hasFeature(aFeatures, aFeatureCount, "jank");
+    mProfile.addTag(ProfileEntry('m', "Start"));
   }
 
   ~TableTicker() { if (IsActive()) Stop(); }
 
   virtual void SampleStack(TickSample* sample) {}
 
   // Called within a signal. This function must be reentrant
   virtual void Tick(TickSample* sample);
@@ -684,16 +684,17 @@ char* mozilla_sampler_get_profile()
 }
 
 const char** mozilla_sampler_get_features()
 {
   static const char* features[] = {
 #if defined(MOZ_PROFILING) && (defined(USE_BACKTRACE) || defined(USE_NS_STACKWALK))
     "stackwalk",
 #endif
+    "jank",
     NULL
   };
 
   return features;
 }
 
 // Values are only honored on the first start
 void mozilla_sampler_start(int aProfileEntries, int aInterval,
@@ -740,20 +741,16 @@ unsigned int sResponsivenessLoc = 0;
 void mozilla_sampler_responsiveness(TimeStamp aTime)
 {
   if (!sLastTracerEvent.IsNull()) {
     if (sResponsivenessLoc == 100) {
       for(size_t i = 0; i < 100-1; i++) {
         sResponsivenessTimes[i] = sResponsivenessTimes[i+1];
       }
       sResponsivenessLoc--;
-      //for(size_t i = 0; i < 100; i++) {
-      //  sResponsivenessTimes[i] = 0;
-      //}
-      //sResponsivenessLoc = 0;
     }
     TimeDuration delta = aTime - sLastTracerEvent;
     sResponsivenessTimes[sResponsivenessLoc++] = delta.ToMilliseconds();
   }
   sCurrentEventGeneration++;
 
   sLastTracerEvent = aTime;
 }
rename from tools/profiler/public/nsIProfiler.idl
rename to tools/profiler/nsIProfiler.idl
rename from tools/profiler/sps/platform-linux.cc
rename to tools/profiler/platform-linux.cc
rename from tools/profiler/sps/platform-win32.cc
rename to tools/profiler/platform-win32.cc
rename from tools/profiler/sps/platform.h
rename to tools/profiler/platform.h
--- a/tools/profiler/sampler.h
+++ b/tools/profiler/sampler.h
@@ -61,20 +61,25 @@
  * tags   -> tag tags
  * tag    -> CHAR - STRING
  *
  * Tags:
  * 's' - Sample tag followed by the first stack frame followed by 0 or more 'c' tags.
  * 'c' - Continue Sample tag gives remaining tag element. If a 'c' tag is seen without
  *         a preceding 's' tag it should be ignored. This is to support the behavior
  *         of circular buffers.
+ *         If the 'stackwalk' feature is enabled this tag will have the format
+ *         'l-<library name>@<hex address>' and will expect an external tool to translate
+ *         the tag into something readable through a symbolication processing step.
  * 'm' - Timeline marker. Zero or more may appear before a 's' tag.
  * 'l' - Information about the program counter library and address. Post processing
  *         can include function and source line. If built with leaf data enabled
  *         this tag will describe the last 'c' tag.
+ * 'r' - Responsiveness tag following an 's' tag. Gives an indication on how well the
+ *          application is responding to the event loop. Lower is better.
  *
  * NOTE: File format is planned to be extended to include a dictionary to reduce size.
  */
 
 #ifndef SAMPLER_H
 #define SAMPLER_H
 
 // Redefine the macros for platforms where SPS is supported.
rename from tools/profiler/sps/shared-libraries-linux.cc
rename to tools/profiler/shared-libraries-linux.cc
rename from tools/profiler/sps/shared-libraries-macos.cc
rename to tools/profiler/shared-libraries-macos.cc
rename from tools/profiler/sps/shared-libraries-win32.cc
rename to tools/profiler/shared-libraries-win32.cc
rename from tools/profiler/sps/shared-libraries.h
rename to tools/profiler/shared-libraries.h
rename from tools/profiler/sps/sps_sampler.h
rename to tools/profiler/sps_sampler.h
rename from tools/profiler/sps/thread_helper.h
rename to tools/profiler/thread_helper.h
rename from tools/profiler/sps/v8-support.h
rename to tools/profiler/v8-support.h