Bug 1371927: Build KeyedStackCapture only if profiler enabled. r?gfritzsche
MozReview-Commit-ID: 9IoVY2K5hXc
--- 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',