Bug 1371927 - Build KeyedStackCapture only if profiler enabled. r=gfritzsche, a=jcristau
authorIaroslav (yarik) Sheptykin <yarik.sheptykin@googlemail.com>
Sat, 10 Jun 2017 19:59:16 +0200
changeset 413990 4d0e950f01dda9b79531dbf29685ab4bb72da445
parent 413989 25bf27f7c252c3a1d91449f74a0849e0e50d0ab0
child 413991 4c87c5c7c17b17d0babafac5f52a65fff1b78297
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, jcristau
bugs1371927
milestone55.0
Bug 1371927 - Build KeyedStackCapture only if profiler enabled. r=gfritzsche, a=jcristau MozReview-Commit-ID: 9IoVY2K5hXc
toolkit/components/telemetry/HangReports.cpp
toolkit/components/telemetry/KeyedStackCapturer.cpp
toolkit/components/telemetry/KeyedStackCapturer.h
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/moz.build
--- a/toolkit/components/telemetry/HangReports.cpp
+++ b/toolkit/components/telemetry/HangReports.cpp
@@ -6,19 +6,16 @@
 
 #include "HangReports.h"
 
 namespace mozilla {
 namespace Telemetry {
 
 using namespace HangMonitor;
 
-/** The maximum number of stacks that we're keeping for hang reports. */
-const size_t kMaxHangStacksKept = 50;
-
 // This utility function generates a string key that is used to index the annotations
 // in a hash map from |HangReports::AddHang|.
 nsresult
 ComputeAnnotationsKey(const HangAnnotationsPtr& aAnnotations, nsAString& aKeyOut)
 {
   UniquePtr<HangAnnotations::Enumerator> annotationsEnum = aAnnotations->GetEnumerator();
   if (!annotationsEnum) {
     return NS_ERROR_FAILURE;
@@ -31,16 +28,19 @@ ComputeAnnotationsKey(const HangAnnotati
     aKeyOut.Append(key);
     aKeyOut.Append(value);
   }
 
   return NS_OK;
 }
 
 #if defined(MOZ_GECKO_PROFILER)
+/** The maximum number of stacks that we're keeping for hang reports. */
+const size_t kMaxHangStacksKept = 50;
+
 void
 HangReports::AddHang(const Telemetry::ProcessedStack& aStack,
                      uint32_t aDuration,
                      int32_t aSystemUptime,
                      int32_t aFirefoxUptime,
                      HangAnnotationsPtr aAnnotations) {
   // Append the new stack to the stack's circular queue.
   size_t hangIndex = mStacks.AddStack(aStack);
--- a/toolkit/components/telemetry/KeyedStackCapturer.cpp
+++ b/toolkit/components/telemetry/KeyedStackCapturer.cpp
@@ -7,18 +7,16 @@
 #include "KeyedStackCapturer.h"
 #include "nsPrintfCString.h"
 #include "mozilla/StackWalk.h"
 #include "ProcessedStack.h"
 #include "jsapi.h"
 
 namespace {
 
-#if defined(MOZ_GECKO_PROFILER)
-
 /** Defines the size of the keyed stack dictionary. */
 const uint8_t kMaxKeyLength = 50;
 
 /** The maximum number of captured stacks that we're keeping. */
 const size_t kMaxCapturedStacksKept = 50;
 
 /**
  * Checks if a single character of the key string is valid.
@@ -156,12 +154,11 @@ KeyedStackCapturer::ReflectCapturedStack
 
 void
 KeyedStackCapturer::Clear()
 {
   MutexAutoLock captureStackMutex(mStackCapturerMutex);
   mStackInfos.Clear();
   mStacks.Clear();
 }
-#endif
 
 } // namespace Telemetry
 } // namespace mozilla
--- a/toolkit/components/telemetry/KeyedStackCapturer.h
+++ b/toolkit/components/telemetry/KeyedStackCapturer.h
@@ -1,18 +1,16 @@
 /* -*-  Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef KeyedStackCapturer_h__
 #define KeyedStackCapturer_h__
 
-#ifdef MOZ_GECKO_PROFILER
-
 #include "Telemetry.h"
 #include "nsString.h"
 #include "nsClassHashtable.h"
 #include "mozilla/Mutex.h"
 #include "CombinedStacks.h"
 
 struct JSContext;
 
@@ -69,11 +67,9 @@ private:
   FrequencyInfoMapType mStackInfos;
   CombinedStacks mStacks;
   Mutex mStackCapturerMutex;
 };
 
 } // namespace Telemetry
 } // namespace mozilla
 
-#endif // MOZ_GECKO_PROFILER
-
 #endif // KeyedStackCapturer_h__
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -94,20 +94,23 @@
 namespace {
 
 using namespace mozilla;
 using namespace mozilla::HangMonitor;
 using Telemetry::Common::AutoHashtable;
 using mozilla::dom::Promise;
 using mozilla::dom::AutoJSAPI;
 using mozilla::Telemetry::HangReports;
-using mozilla::Telemetry::KeyedStackCapturer;
 using mozilla::Telemetry::CombinedStacks;
 using mozilla::Telemetry::ComputeAnnotationsKey;
 
+#if defined(MOZ_GECKO_PROFILER)
+using mozilla::Telemetry::KeyedStackCapturer;
+#endif
+
 /**
  * IOInterposeObserver recording statistics of main-thread I/O during execution,
  * aimed at consumption by TelemetryImpl
  */
 class TelemetryIOInterposeObserver : public IOInterposeObserver
 {
   /** File-level statistics structure */
   struct FileStats {
--- a/toolkit/components/telemetry/moz.build
+++ b/toolkit/components/telemetry/moz.build
@@ -52,25 +52,30 @@ EXPORTS.mozilla += [
     'ThreadHangStats.h',
 ]
 
 SOURCES += [
     'CombinedStacks.cpp',
     'HangReports.cpp',
     'ipc/TelemetryIPC.cpp',
     'ipc/TelemetryIPCAccumulator.cpp',
-    'KeyedStackCapturer.cpp',
     'Telemetry.cpp',
     'TelemetryCommon.cpp',
     'TelemetryEvent.cpp',
     'TelemetryHistogram.cpp',
     'TelemetryScalar.cpp',
     'WebrtcTelemetry.cpp',
 ]
 
+# KeyedStackCapturer entirely relies on profiler to be enabled.
+if CONFIG['MOZ_GECKO_PROFILER']:
+    SOURCES += [
+      'KeyedStackCapturer.cpp'
+    ]
+
 EXTRA_COMPONENTS += [
     'TelemetryStartup.js',
     'TelemetryStartup.manifest'
 ]
 
 EXTRA_JS_MODULES += [
     'GCTelemetry.jsm',
     'TelemetryArchive.jsm',