Bug 1001126 - Allow AllTraces CC logging other than at shutdown. (r=mccr8)
authorEric Faust <efaustbmo@gmail.com>
Thu, 24 Apr 2014 14:28:49 -0700
changeset 180081 c219ba15faed02d9c92386de57905d774e85dd14
parent 180080 c9c5d13a9b2b86023748b653418dd3d257aec4cd
child 180082 797c8dfa7c6da5491494df71e15e0c06078ee040
push id26653
push usercbook@mozilla.com
push dateFri, 25 Apr 2014 10:50:28 +0000
treeherdermozilla-central@2b02d933c39a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1001126
milestone31.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 1001126 - Allow AllTraces CC logging other than at shutdown. (r=mccr8)
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -210,42 +210,45 @@ using namespace mozilla;
 // MOZ_CC_LOG_ALL or MOZ_CC_LOG_SHUTDOWN for it to do anything.
 //
 // MOZ_CC_LOG_PROCESS: If set to "main", only automatically log main process
 // CCs. If set to "content", only automatically log tab CCs. If set to
 // "plugins", only automatically log plugin CCs. If set to "all", log
 // everything. The default value is "all". This must be used with either
 // MOZ_CC_LOG_ALL or MOZ_CC_LOG_SHUTDOWN for it to do anything.
 //
-// MOZ_CC_ALL_TRACES_AT_SHUTDOWN: If defined, any cycle collector
-// logging done at shutdown will be WantAllTraces, which disables
+// MOZ_CC_ALL_TRACES: If set to "all", any cycle collector
+// logging done will be WantAllTraces, which disables
 // various cycle collector optimizations to give a fuller picture of
-// the heap.
+// the heap. If set to "shutdown", only shutdown logging will be WantAllTraces.
+// The default is none.
 //
 // MOZ_CC_RUN_DURING_SHUTDOWN: In non-DEBUG or builds, if this is set,
 // run cycle collections at shutdown.
 //
 // MOZ_CC_LOG_DIRECTORY: The directory in which logs are placed (such as
 // logs from MOZ_CC_LOG_ALL and MOZ_CC_LOG_SHUTDOWN, or other uses
 // of nsICycleCollectorListener)
 
 // Various parameters of this collector can be tuned using environment
 // variables.
 
 struct nsCycleCollectorParams
 {
     bool mLogAll;
     bool mLogShutdown;
-    bool mAllTracesAtShutdown;
+    bool mAllTracesAll;
+    bool mAllTracesShutdown;
     bool mLogThisThread;
 
     nsCycleCollectorParams() :
         mLogAll      (PR_GetEnv("MOZ_CC_LOG_ALL") != nullptr),
         mLogShutdown (PR_GetEnv("MOZ_CC_LOG_SHUTDOWN") != nullptr),
-        mAllTracesAtShutdown (PR_GetEnv("MOZ_CC_ALL_TRACES_AT_SHUTDOWN") != nullptr)
+        mAllTracesAll(false),
+        mAllTracesShutdown(false)
     {
         const char* logThreadEnv = PR_GetEnv("MOZ_CC_LOG_THREAD");
         bool threadLogging = true;
         if (logThreadEnv && !!strcmp(logThreadEnv, "all")) {
             if (NS_IsMainThread()) {
                 threadLogging = !strcmp(logThreadEnv, "main");
             } else {
                 threadLogging = !strcmp(logThreadEnv, "worker");
@@ -266,22 +269,36 @@ struct nsCycleCollectorParams
                     processLogging = !strcmp(logProcessEnv, "content");
                     break;
                 default:
                     processLogging = false;
                     break;
             }
         }
         mLogThisThread = threadLogging && processLogging;
+
+        const char* allTracesEnv = PR_GetEnv("MOZ_CC_ALL_TRACES");
+        if (allTracesEnv) {
+            if (!strcmp(allTracesEnv, "all")) {
+                mAllTracesAll = true;
+            } else if (!strcmp(allTracesEnv, "shutdown")) {
+                mAllTracesShutdown = true;
+            }
+        }
     }
 
     bool LogThisCC(bool aIsShutdown)
     {
         return (mLogAll || (aIsShutdown && mLogShutdown)) && mLogThisThread;
     }
+
+    bool AllTracesThisCC(bool aIsShutdown)
+    {
+        return mAllTracesAll || (aIsShutdown && mAllTracesShutdown);
+    }
 };
 
 #ifdef COLLECT_TIME_DEBUG
 class TimeLog
 {
 public:
     TimeLog() : mLastCheckpoint(TimeStamp::Now()) {}
 
@@ -3406,17 +3423,17 @@ nsCycleCollector::BeginCollection(ccType
 
     // Set up the listener for this CC.
     MOZ_ASSERT_IF(isShutdown, !aManualListener);
     MOZ_ASSERT(!mListener, "Forgot to clear a previous listener?");
     mListener = aManualListener;
     aManualListener = nullptr;
     if (!mListener && mParams.LogThisCC(isShutdown)) {
         nsRefPtr<nsCycleCollectorLogger> logger = new nsCycleCollectorLogger();
-        if (isShutdown && mParams.mAllTracesAtShutdown) {
+        if (mParams.AllTracesThisCC(isShutdown)) {
             logger->SetAllTraces();
         }
         mListener = logger.forget();
     }
 
     bool forceGC = isShutdown;
     if (!forceGC && mListener) {
         // On a WantAllTraces CC, force a synchronous global GC to prevent