Bug 1452580 - remove RELEASE_OR_BETA defines for PerformanceCounter usage - r?baku,farre,erahm draft
authorTarek Ziadé <tarek@mozilla.com>
Tue, 24 Apr 2018 22:03:06 +0200
changeset 787461 0f70c8086b249f405e7526328c4ebe5b85cc6fbf
parent 787142 26e53729a10976f52e75efa44e17b5e054969fec
push id107736
push usertziade@mozilla.com
push dateTue, 24 Apr 2018 21:10:36 +0000
reviewersbaku, farre, erahm
bugs1452580
milestone61.0a1
Bug 1452580 - remove RELEASE_OR_BETA defines for PerformanceCounter usage - r?baku,farre,erahm PerformanceCounters are currently disabled in two ways: - a preference that's off by default "dom.performance.enable_scheduler_timing" - calls made only for nightly using #ifndef RELEASE_OR_BETA In order to simplify the code, let's remove the #ifndef and rely only on the pref. That will also allows us to use the feature in every version going forward. The performance will not be impacted since the current code is already using the (cached) pref value to determine if the counters are used. MozReview-Commit-ID: 47t2M1O13aH
dom/base/ChromeUtils.cpp
dom/base/ChromeUtils.h
dom/base/DocGroup.cpp
dom/base/DocGroup.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/tests/browser/browser.ini
dom/workers/WorkerDebugger.cpp
dom/workers/WorkerDebugger.h
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/WorkerThread.cpp
dom/workers/WorkerThread.h
xpcom/tests/gtest/moz.build
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
--- a/dom/base/ChromeUtils.cpp
+++ b/dom/base/ChromeUtils.cpp
@@ -7,19 +7,17 @@
 #include "ChromeUtils.h"
 
 #include "jsfriendapi.h"
 #include "WrapperFactory.h"
 
 #include "mozilla/Base64.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
-#ifndef RELEASE_OR_BETA
 #include "mozilla/PerformanceUtils.h"
-#endif
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/IdleDeadline.h"
 #include "mozilla/dom/UnionTypes.h"
 #include "mozilla/dom/WindowBinding.h" // For IdleRequestCallback/Options
 #include "nsThreadUtils.h"
 #include "mozJSComponentLoader.h"
 #include "GeckoProfiler.h"
@@ -652,17 +650,16 @@ ChromeUtils::ClearRecentJSDevError(Globa
 {
   auto runtime = CycleCollectedJSRuntime::Get();
   MOZ_ASSERT(runtime);
 
   runtime->ClearRecentDevError();
 }
 #endif // NIGHTLY_BUILD
 
-#ifndef RELEASE_OR_BETA
 /* static */ void
 ChromeUtils::RequestPerformanceMetrics(GlobalObject&)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   // calling all content processes via IPDL (async)
   nsTArray<ContentParent*> children;
   ContentParent::GetAll(children);
@@ -677,17 +674,16 @@ ChromeUtils::RequestPerformanceMetrics(G
   SystemGroup::Dispatch(TaskCategory::Performance,
     NS_NewRunnableFunction(
       "RequestPerformanceMetrics",
       [info]() { mozilla::Unused << NS_WARN_IF(NS_FAILED(NotifyPerformanceInfo(info))); }
     )
   );
 
 }
-#endif
 
 constexpr auto kSkipSelfHosted = JS::SavedFrameSelfHosted::Exclude;
 
 /* static */ void
 ChromeUtils::GetCallerLocation(const GlobalObject& aGlobal, nsIPrincipal* aPrincipal,
                                JS::MutableHandle<JSObject*> aRetval)
 {
   JSContext* cx = aGlobal.Context();
--- a/dom/base/ChromeUtils.h
+++ b/dom/base/ChromeUtils.h
@@ -150,19 +150,17 @@ public:
                            ErrorResult& aRv);
 
   static void GetRecentJSDevError(GlobalObject& aGlobal,
                                   JS::MutableHandleValue aRetval,
                                   ErrorResult& aRv);
 
   static void ClearRecentJSDevError(GlobalObject& aGlobal);
 
-#ifndef RELEASE_OR_BETA
   static void RequestPerformanceMetrics(GlobalObject& aGlobal);
-#endif
 
   static void Import(const GlobalObject& aGlobal,
                      const nsAString& aResourceURI,
                      const Optional<JS::Handle<JSObject*>>& aTargetObj,
                      JS::MutableHandle<JSObject*> aRetval,
                      ErrorResult& aRv);
 
   static void DefineModuleGetter(const GlobalObject& global,
--- a/dom/base/DocGroup.cpp
+++ b/dom/base/DocGroup.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/dom/DocGroup.h"
+#include "mozilla/dom/DOMPrefs.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/TabGroup.h"
 #include "mozilla/Telemetry.h"
 #include "nsIDocShell.h"
 #include "nsDOMMutationObserver.h"
 #if defined(XP_WIN)
 #include <processthreadsapi.h>  // for GetCurrentProcessId()
 #else
@@ -46,37 +47,37 @@ DocGroup::RemoveDocument(nsIDocument* aD
   MOZ_ASSERT(mDocuments.Contains(aDocument));
   mDocuments.RemoveElement(aDocument);
 }
 
 DocGroup::DocGroup(TabGroup* aTabGroup, const nsACString& aKey)
   : mKey(aKey), mTabGroup(aTabGroup)
 {
   // This method does not add itself to mTabGroup->mDocGroups as the caller does it for us.
-#ifndef RELEASE_OR_BETA
-  mPerformanceCounter = new mozilla::PerformanceCounter(aKey);
-#endif
+  if (mozilla::dom::DOMPrefs::SchedulerLoggingEnabled()) {
+    mPerformanceCounter = new mozilla::PerformanceCounter(aKey);
+  }
 }
 
 DocGroup::~DocGroup()
 {
   MOZ_ASSERT(mDocuments.IsEmpty());
   if (!NS_IsMainThread()) {
     nsIEventTarget* target = EventTargetFor(TaskCategory::Other);
     NS_ProxyRelease("DocGroup::mReactionsStack", target, mReactionsStack.forget());
   }
 
   mTabGroup->mDocGroups.RemoveEntry(mKey);
 }
 
-#ifndef RELEASE_OR_BETA
 PerformanceInfo
 DocGroup::ReportPerformanceInfo()
 {
   AssertIsOnMainThread();
+  MOZ_ASSERT(mPerformanceCounter);
 #if defined(XP_WIN)
   uint32_t pid = GetCurrentProcessId();
 #else
   uint32_t pid = getpid();
 #endif
   uint64_t wid = 0;
   uint64_t pwid = 0;
   uint16_t count = 0;
@@ -122,25 +123,24 @@ DocGroup::ReportPerformanceInfo()
       return PerformanceInfo(host, pid, wid, pwid, duration, false, items);
     }
   }
 
   // setting back all counters to zero
   mPerformanceCounter->ResetPerformanceCounters();
   return PerformanceInfo(host, pid, wid, pwid, duration, false, items);
 }
-#endif
 
 nsresult
 DocGroup::Dispatch(TaskCategory aCategory,
                    already_AddRefed<nsIRunnable>&& aRunnable)
 {
-#ifndef RELEASE_OR_BETA
-  mPerformanceCounter->IncrementDispatchCounter(DispatchCategory(aCategory));
-#endif
+  if (mPerformanceCounter) {
+    mPerformanceCounter->IncrementDispatchCounter(DispatchCategory(aCategory));
+  }
   return mTabGroup->DispatchWithDocGroup(aCategory, Move(aRunnable), this);
 }
 
 nsISerialEventTarget*
 DocGroup::EventTargetFor(TaskCategory aCategory) const
 {
   return mTabGroup->EventTargetFor(aCategory);
 }
--- a/dom/base/DocGroup.h
+++ b/dom/base/DocGroup.h
@@ -53,25 +53,25 @@ public:
   // |aString| may still be set to an empty string.
   static MOZ_MUST_USE nsresult
   GetKey(nsIPrincipal* aPrincipal, nsACString& aString);
 
   bool MatchesKey(const nsACString& aKey)
   {
     return aKey == mKey;
   }
-#ifndef RELEASE_OR_BETA
+
   PerformanceCounter* GetPerformanceCounter()
   {
     return mPerformanceCounter;
   }
 
   PerformanceInfo
   ReportPerformanceInfo();
-#endif
+
   TabGroup* GetTabGroup()
   {
     return mTabGroup;
   }
   mozilla::dom::CustomElementReactionsStack* CustomElementReactionsStack()
   {
     MOZ_ASSERT(NS_IsMainThread());
     if (!mReactionsStack) {
@@ -134,17 +134,17 @@ private:
   DocGroup(TabGroup* aTabGroup, const nsACString& aKey);
   ~DocGroup();
 
   nsCString mKey;
   RefPtr<TabGroup> mTabGroup;
   nsTArray<nsIDocument*> mDocuments;
   RefPtr<mozilla::dom::CustomElementReactionsStack> mReactionsStack;
   nsTArray<RefPtr<HTMLSlotElement>> mSignalSlotList;
-#ifndef RELEASE_OR_BETA
+  // This pointer will be null if dom.performance.enable_scheduler_timing is
+  // false (default value)
   RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
-#endif
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // defined(DocGroup_h)
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -64,19 +64,17 @@
 #include "mozilla/layers/CompositorManagerChild.h"
 #include "mozilla/layers/ContentProcessController.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layout/RenderFrameChild.h"
 #include "mozilla/loader/ScriptCacheActors.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/net/CookieServiceChild.h"
 #include "mozilla/net/CaptivePortalService.h"
-#ifndef RELEASE_OR_BETA
 #include "mozilla/PerformanceUtils.h"
-#endif
 #include "mozilla/plugins/PluginInstanceParent.h"
 #include "mozilla/plugins/PluginModuleParent.h"
 #include "mozilla/widget/ScreenManager.h"
 #include "mozilla/widget/WidgetMessageUtils.h"
 #include "nsBaseDragService.h"
 #include "mozilla/media/MediaChild.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/WebBrowserPersistDocumentChild.h"
@@ -1377,25 +1375,21 @@ ContentChild::GetResultForRenderingInitF
   // the next ContentChild::RecvReinitRendering call.
   gfxCriticalNote << "Could not initialize rendering with GPU process";
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvRequestPerformanceMetrics()
 {
-#ifndef RELEASE_OR_BETA
+  MOZ_ASSERT(mozilla::dom::DOMPrefs::SchedulerLoggingEnabled());
   nsTArray<PerformanceInfo> info;
   CollectPerformanceInfo(info);
   SendAddPerformanceMetrics(info);
   return IPC_OK();
-#endif
-#ifdef RELEASE_OR_BETA
-  return IPC_OK();
-#endif
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvInitRendering(Endpoint<PCompositorManagerChild>&& aCompositor,
                                 Endpoint<PImageBridgeChild>&& aImageBridge,
                                 Endpoint<PVRManagerChild>&& aVRBridge,
                                 Endpoint<PVideoDecoderManagerChild>&& aVideoManager,
                                 nsTArray<uint32_t>&& namespaces)
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -179,19 +179,17 @@
 #include "nsOpenURIInFrameParams.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "gfxPlatform.h"
 #include "gfxPrefs.h"
 #include "prio.h"
 #include "private/pprio.h"
 #include "ContentProcessManager.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
-#ifndef RELEASE_OR_BETA
 #include "mozilla/PerformanceUtils.h"
-#endif
 #include "mozilla/psm/PSMContentListener.h"
 #include "nsPluginHost.h"
 #include "nsPluginTags.h"
 #include "nsIBlocklistService.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsICaptivePortalService.h"
@@ -3273,19 +3271,22 @@ ContentParent::RecvFinishMemoryReport(co
     mMemoryReportRequest = nullptr;
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvAddPerformanceMetrics(nsTArray<PerformanceInfo>&& aMetrics)
 {
-#ifndef RELEASE_OR_BETA
+  if (!mozilla::dom::DOMPrefs::SchedulerLoggingEnabled()) {
+    // The pref is off, we should not get a performance metrics from the content
+    // child
+    return IPC_OK();
+  }
   Unused << NS_WARN_IF(NS_FAILED(mozilla::NotifyPerformanceInfo(aMetrics)));
-#endif
   return IPC_OK();
 }
 
 PCycleCollectWithLogsParent*
 ContentParent::AllocPCycleCollectWithLogsParent(const bool& aDumpAllTraces,
                                                 const FileDescriptor& aGCLog,
                                                 const FileDescriptor& aCCLog)
 {
--- a/dom/tests/browser/browser.ini
+++ b/dom/tests/browser/browser.ini
@@ -1,9 +1,10 @@
 [DEFAULT]
+prefs = dom.performance.enable_scheduler_timing=true
 support-files =
   browser_frame_elements.html
   page_privatestorageevent.html
   page_localstorage_e10s.html
   position.html
   test-console-api.html
   test_bug1004814.html
   worker_bug1004814.js
@@ -69,9 +70,8 @@ support-files =
   test_new_window_from_content_child.html
 [browser_xhr_sandbox.js]
 [browser_noopener.js]
 support-files =
   test_noopener_source.html
   test_noopener_target.html
 [browser_noopener_null_uri.js]
 [browser_test_performance_metrics.js]
-run-if = nightly_build
\ No newline at end of file
--- a/dom/workers/WorkerDebugger.cpp
+++ b/dom/workers/WorkerDebugger.cpp
@@ -469,17 +469,16 @@ WorkerDebugger::ReportErrorToDebuggerOnM
   }
 
   WorkerErrorReport report;
   report.mMessage = aMessage;
   report.mFilename = aFilename;
   WorkerErrorReport::LogErrorToConsole(report, 0);
 }
 
-#ifndef RELEASE_OR_BETA
 PerformanceInfo
 WorkerDebugger::ReportPerformanceInfo()
 {
   AssertIsOnMainThread();
 #if defined(XP_WIN)
   uint32_t pid = GetCurrentProcessId();
 #else
   uint32_t pid = getpid();
@@ -510,12 +509,11 @@ WorkerDebugger::ReportPerformanceInfo()
     NS_ERROR("Could not complete the operation");
     return PerformanceInfo(uri->GetSpecOrDefault(), pid, wid, pwid, duration,
                             true, items);
   }
   perf->ResetPerformanceCounters();
   return PerformanceInfo(uri->GetSpecOrDefault(), pid, wid, pwid, duration,
                          true, items);
 }
-#endif
 
 } // dom namespace
 } // mozilla namespace
--- a/dom/workers/WorkerDebugger.h
+++ b/dom/workers/WorkerDebugger.h
@@ -39,24 +39,22 @@ public:
 
   void
   PostMessageToDebugger(const nsAString& aMessage);
 
   void
   ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno,
                         const nsAString& aMessage);
 
-#ifndef RELEASE_OR_BETA
   /*
    * Sends back a PerformanceInfo struct from the counters
    * in mWorkerPrivate. Counters are reset to zero after this call.
    */
   PerformanceInfo
   ReportPerformanceInfo();
-#endif
 
 private:
   virtual
   ~WorkerDebugger();
 
   void
   PostMessageToDebuggerOnMainThread(const nsAString& aMessage);
 
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -8,16 +8,17 @@
 
 #include "js/MemoryMetrics.h"
 #include "MessageEventRunnable.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/dom/ClientManager.h"
 #include "mozilla/dom/ClientSource.h"
 #include "mozilla/dom/ClientState.h"
 #include "mozilla/dom/Console.h"
+#include "mozilla/dom/DOMPrefs.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ErrorEventBinding.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/IndexedDatabaseManager.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
@@ -424,19 +425,19 @@ private:
       return false;
     }
 
     // PerformanceStorage & PerformanceCounter both need to be initialized
     // on the worker thread before being used on main-thread.
     // Let's be sure that it is created before any
     // content loading.
     aWorkerPrivate->EnsurePerformanceStorage();
-#ifndef RELEASE_OR_BETA
-    aWorkerPrivate->EnsurePerformanceCounter();
-#endif
+    if (mozilla::dom::DOMPrefs::SchedulerLoggingEnabled()) {
+      aWorkerPrivate->EnsurePerformanceCounter();
+    }
 
     ErrorResult rv;
     workerinternals::LoadMainScript(aWorkerPrivate, mScriptURL, WorkerScript, rv);
     rv.WouldReportJSException();
     // Explicitly ignore NS_BINDING_ABORTED on rv.  Or more precisely, still
     // return false and don't SetWorkerScriptExecutedSuccessfully() in that
     // case, but don't throw anything on aCx.  The idea is to not dispatch error
     // events if our load is canceled with that error code.
@@ -2676,19 +2677,17 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
   , mFetchHandlerWasAdded(false)
   , mOnLine(false)
   , mMainThreadObjectsForgotten(false)
   , mIsChromeWorker(aIsChromeWorker)
   , mParentFrozen(false)
   , mIsSecureContext(false)
   , mDebuggerRegistered(false)
   , mIsInAutomation(false)
-#ifndef RELEASE_OR_BETA
   , mPerformanceCounter(nullptr)
-#endif
 {
   MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
   mLoadInfo.StealFrom(aLoadInfo);
 
   if (aParent) {
     aParent->AssertIsOnWorkerThread();
 
     // Note that this copies our parent's secure context state into mJSSettings.
@@ -5371,33 +5370,32 @@ WorkerPrivate::DumpCrashInformation(nsAC
   nsTObserverArray<WorkerHolder*>::ForwardIterator iter(mHolders);
   while (iter.HasMore()) {
     WorkerHolder* holder = iter.GetNext();
     aString.Append("|");
     aString.Append(holder->Name());
   }
 }
 
-#ifndef RELEASE_OR_BETA
 void
 WorkerPrivate::EnsurePerformanceCounter()
 {
   AssertIsOnWorkerThread();
+  MOZ_ASSERT(mozilla::dom::DOMPrefs::SchedulerLoggingEnabled());
   if (!mPerformanceCounter) {
     mPerformanceCounter = new PerformanceCounter(NS_ConvertUTF16toUTF8(mWorkerName));
   }
 }
 
 PerformanceCounter*
 WorkerPrivate::GetPerformanceCounter()
 {
   MOZ_ASSERT(mPerformanceCounter);
   return mPerformanceCounter;
 }
-#endif
 
 PerformanceStorage*
 WorkerPrivate::GetPerformanceStorage()
 {
   AssertIsOnMainThread();
   MOZ_ASSERT(mPerformanceStorage);
   return mPerformanceStorage;
 }
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -545,20 +545,18 @@ public:
   DumpCrashInformation(nsACString& aString);
 
   bool
   EnsureClientSource();
 
   void
   EnsurePerformanceStorage();
 
-#ifndef RELEASE_OR_BETA
   void
   EnsurePerformanceCounter();
-#endif
 
   const ClientInfo&
   GetClientInfo() const;
 
   const ClientState
   GetClientState() const;
 
   const Maybe<ServiceWorkerDescriptor>
@@ -568,20 +566,18 @@ public:
   Control(const ServiceWorkerDescriptor& aServiceWorker);
 
   void
   ExecutionReady();
 
   PerformanceStorage*
   GetPerformanceStorage();
 
-#ifndef RELEASE_OR_BETA
   PerformanceCounter*
   GetPerformanceCounter();
-#endif
 
   bool
   IsAcceptingEvents()
   {
     AssertIsOnParentThread();
 
     MutexAutoLock lock(mMutex);
     return mParentStatus < Terminating;
@@ -1468,19 +1464,19 @@ private:
   bool mIsSecureContext;
 
   bool mDebuggerRegistered;
 
   // mIsInAutomation is true when we're running in test automation.
   // We expose some extra testing functions in that case.
   bool mIsInAutomation;
 
-#ifndef RELEASE_OR_BETA
+  // This pointer will be null if dom.performance.enable_scheduler_timing is
+  // false (default value)
   RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
-#endif
 };
 
 class AutoSyncLoopHolder
 {
   WorkerPrivate* mWorkerPrivate;
   nsCOMPtr<nsIEventTarget> mTarget;
   uint32_t mIndex;
 
--- a/dom/workers/WorkerThread.cpp
+++ b/dom/workers/WorkerThread.cpp
@@ -223,24 +223,22 @@ WorkerThread::Dispatch(already_AddRefed<
 
   // Workers only support asynchronous dispatch.
   if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL)) {
     return NS_ERROR_UNEXPECTED;
   }
 
   const bool onWorkerThread = PR_GetCurrentThread() == mThread;
 
-#ifndef RELEASE_OR_BETA
   if (GetSchedulerLoggingEnabled() && onWorkerThread && mWorkerPrivate) {
     PerformanceCounter* performanceCounter = mWorkerPrivate->GetPerformanceCounter();
     if (performanceCounter) {
       performanceCounter->IncrementDispatchCounter(DispatchCategory::Worker);
     }
   }
-#endif
 
 #ifdef DEBUG
   if (runnable && !onWorkerThread) {
     nsCOMPtr<nsICancelableRunnable> cancelable = do_QueryInterface(runnable);
 
     {
       MutexAutoLock lock(mLock);
 
@@ -319,26 +317,24 @@ WorkerThread::DelayedDispatch(already_Ad
 uint32_t
 WorkerThread::RecursionDepth(const WorkerThreadFriendKey& /* aKey */) const
 {
   MOZ_ASSERT(PR_GetCurrentThread() == mThread);
 
   return mNestedEventLoopDepth;
 }
 
-#ifndef RELEASE_OR_BETA
 PerformanceCounter*
 WorkerThread::GetPerformanceCounter(nsIRunnable* aEvent)
 {
   if (mWorkerPrivate) {
     return mWorkerPrivate->GetPerformanceCounter();
   }
   return nullptr;
 }
-#endif
 
 NS_IMPL_ISUPPORTS(WorkerThread::Observer, nsIThreadObserver)
 
 NS_IMETHODIMP
 WorkerThread::Observer::OnDispatchedEvent()
 {
   MOZ_CRASH("OnDispatchedEvent() should never be called!");
 }
--- a/dom/workers/WorkerThread.h
+++ b/dom/workers/WorkerThread.h
@@ -76,20 +76,18 @@ public:
 
   nsresult
   DispatchAnyThread(const WorkerThreadFriendKey& aKey,
            already_AddRefed<WorkerRunnable> aWorkerRunnable);
 
   uint32_t
   RecursionDepth(const WorkerThreadFriendKey& aKey) const;
 
-#ifndef RELEASE_OR_BETA
   PerformanceCounter*
   GetPerformanceCounter(nsIRunnable* aEvent) override;
-#endif
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(WorkerThread, nsThread)
 
 private:
   WorkerThread();
   ~WorkerThread();
 
   // This should only be called by consumers that have an
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -47,16 +47,17 @@ UNIFIED_SOURCES += [
     'TestStrings.cpp',
     'TestStringStream.cpp',
     'TestSynchronization.cpp',
     'TestTArray.cpp',
     'TestTArray2.cpp',
     'TestTaskQueue.cpp',
     'TestTextFormatter.cpp',
     'TestThreadManager.cpp',
+    'TestThreadMetrics.cpp',
     'TestThreadPool.cpp',
     'TestThreadPoolListener.cpp',
     'TestThreads.cpp',
     'TestThreadUtils.cpp',
     'TestTimers.cpp',
     'TestTimeStamp.cpp',
     'TestTokenizer.cpp',
     'TestUTF.cpp',
@@ -65,21 +66,16 @@ UNIFIED_SOURCES += [
 if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT') and CONFIG['OS_TARGET'] != 'Android':
     # FIXME bug 523392: TestDeadlockDetector doesn't like Windows
     # Bug 1054249: Doesn't work on Android
     UNIFIED_SOURCES += [
         'TestDeadlockDetector.cpp',
         'TestDeadlockDetectorScalability.cpp',
     ]
 
-if not CONFIG['RELEASE_OR_BETA']:
-    UNIFIED_SOURCES += [
-        'TestThreadMetrics.cpp',
-    ]
-
 if CONFIG['WRAP_STL_INCLUDES'] and CONFIG['CC_TYPE'] != 'clang-cl':
     UNIFIED_SOURCES += [
         'TestSTLWrappers.cpp',
     ]
 
 # Compile TestAllocReplacement separately so Windows headers don't pollute
 # the global namespace for other files.
 SOURCES += [
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -555,22 +555,20 @@ nsThread::nsThread(NotNull<SynchronizedE
   , mThread(nullptr)
   , mNestedEventLoopDepth(0)
   , mStackSize(aStackSize)
   , mShutdownContext(nullptr)
   , mShutdownRequired(false)
   , mIsMainThread(aMainThread)
   , mLastUnlabeledRunnable(TimeStamp::Now())
   , mCanInvokeJS(false)
-#ifndef RELEASE_OR_BETA
   , mCurrentEvent(nullptr)
   , mCurrentEventStart(TimeStamp::Now())
   , mCurrentEventLoopDepth(-1)
   , mCurrentPerformanceCounter(nullptr)
-#endif
 {
 }
 
 nsThread::~nsThread()
 {
   NS_ASSERTION(mRequestedShutdownContexts.IsEmpty(),
                "shouldn't be waiting on other threads to shutdown");
 #ifdef DEBUG
@@ -581,25 +579,23 @@ nsThread::~nsThread()
   // requesting shutdown on another, which can be helpful for diagnosing
   // the leak.
   for (size_t i = 0; i < mRequestedShutdownContexts.Length(); ++i) {
     Unused << mRequestedShutdownContexts[i].forget();
   }
 #endif
 }
 
-#ifndef RELEASE_OR_BETA
 bool
 nsThread::GetSchedulerLoggingEnabled() {
   if (!NS_IsMainThread() || !mozilla::Preferences::IsServiceAvailable()) {
     return false;
   }
   return mozilla::dom::DOMPrefs::SchedulerLoggingEnabled();
 }
-#endif
 
 nsresult
 nsThread::Init(const nsACString& aName)
 {
   // spawn thread and wait until it is fully setup
   RefPtr<nsThreadStartupEvent> startup = new nsThreadStartupEvent();
 
   NS_ADDREF_THIS();
@@ -920,32 +916,31 @@ GetLabeledRunnableName(nsIRunnable* aEve
   }
 
   if (!labeled && aPriority > EventPriority::Input) {
     aName.AppendLiteral("(unlabeled)");
   }
 
   return labeled;
 }
+#endif
 
 mozilla::PerformanceCounter*
 nsThread::GetPerformanceCounter(nsIRunnable* aEvent)
 {
   RefPtr<SchedulerGroup::Runnable> docRunnable = do_QueryObject(aEvent);
   if (docRunnable) {
     mozilla::dom::DocGroup* docGroup = docRunnable->DocGroup();
     if (docGroup) {
       return docGroup->GetPerformanceCounter();
     }
   }
   return nullptr;
 }
 
-#endif
-
 NS_IMETHODIMP
 nsThread::ProcessNextEvent(bool aMayWait, bool* aResult)
 {
   LOG(("THRD(%p) ProcessNextEvent [%u %u]\n", this, aMayWait,
        mNestedEventLoopDepth));
 
   if (NS_WARN_IF(PR_GetCurrentThread() != mThread)) {
     return NS_ERROR_NOT_SAME_THREAD;
@@ -1006,27 +1001,27 @@ nsThread::ProcessNextEvent(bool aMayWait
 
     if (event) {
       LOG(("THRD(%p) running [%p]\n", this, event.get()));
 
       if (MAIN_THREAD == mIsMainThread) {
         HangMonitor::NotifyActivity();
       }
 
-#ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
       bool schedulerLoggingEnabled = GetSchedulerLoggingEnabled();
       if (schedulerLoggingEnabled
           && mNestedEventLoopDepth > mCurrentEventLoopDepth
           && mCurrentPerformanceCounter) {
           // This is a recursive call, we're saving the time
           // spent in the parent event if the runnable is linked to a DocGroup.
           mozilla::TimeDuration duration = TimeStamp::Now() - mCurrentEventStart;
           mCurrentPerformanceCounter->IncrementExecutionDuration(duration.ToMicroseconds());
       }
 
+#ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
       Maybe<Telemetry::AutoTimer<Telemetry::MAIN_THREAD_RUNNABLE_MS>> timer;
       Maybe<Telemetry::AutoTimer<Telemetry::IDLE_RUNNABLE_BUDGET_OVERUSE_MS>> idleTimer;
 
       nsAutoCString name;
       if ((MAIN_THREAD == mIsMainThread) || mNextIdleDeadline) {
         bool labeled = GetLabeledRunnableName(event, name, priority);
 
         if (MAIN_THREAD == mIsMainThread) {
@@ -1075,32 +1070,30 @@ nsThread::ProcessNextEvent(bool aMayWait
         sMainThreadRunnableName[length] = '\0';
       }
 #endif
       Maybe<AutoTimeDurationHelper> timeDurationHelper;
       if (priority == EventPriority::Input) {
         timeDurationHelper.emplace();
       }
 
-#ifndef RELEASE_OR_BETA
       // The event starts to run, storing the timestamp.
       bool recursiveEvent = false;
       RefPtr<mozilla::PerformanceCounter> currentPerformanceCounter;
       if (schedulerLoggingEnabled) {
         recursiveEvent = mNestedEventLoopDepth > mCurrentEventLoopDepth;
         mCurrentEventStart = mozilla::TimeStamp::Now();
         mCurrentEvent = event;
         mCurrentEventLoopDepth = mNestedEventLoopDepth;
         mCurrentPerformanceCounter = GetPerformanceCounter(event);
         currentPerformanceCounter = mCurrentPerformanceCounter;
       }
-#endif
+
       event->Run();
 
-#ifndef RELEASE_OR_BETA
       // End of execution, we can send the duration for the group
       if (schedulerLoggingEnabled) {
        if (recursiveEvent) {
           // If we're in a recursive call, reset the timer,
           // so the parent gets its remaining execution time right.
           mCurrentEventStart = mozilla::TimeStamp::Now();
           mCurrentPerformanceCounter = currentPerformanceCounter;
         } else {
@@ -1109,17 +1102,16 @@ nsThread::ProcessNextEvent(bool aMayWait
             mozilla::TimeDuration duration = TimeStamp::Now() - mCurrentEventStart;
             currentPerformanceCounter->IncrementExecutionDuration(duration.ToMicroseconds());
           }
           mCurrentEvent = nullptr;
           mCurrentEventLoopDepth = -1;
           mCurrentPerformanceCounter = nullptr;
         }
       }
-#endif
     } else if (aMayWait) {
       MOZ_ASSERT(ShuttingDown(),
                  "This should only happen when shutting down");
       rv = NS_ERROR_UNEXPECTED;
     }
   }
 
   NOTIFY_EVENT_OBSERVERS(EventQueue()->EventObservers(), AfterProcessNextEvent, (this, *aResult));
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -125,19 +125,17 @@ public:
 
   mozilla::SynchronizedEventQueue* EventQueue() { return mEvents.get(); }
 
   bool ShuttingDown()
   {
     return mShutdownContext != nullptr;
   }
 
-#ifndef RELEASE_OR_BETA
   virtual mozilla::PerformanceCounter* GetPerformanceCounter(nsIRunnable* aEvent);
-#endif
 
 private:
   void DoMainThreadSpecificProcessing(bool aReallyWait);
 
 protected:
   friend class nsThreadShutdownEvent;
 
   virtual ~nsThread();
@@ -177,25 +175,23 @@ protected:
 
   // The time when we last ran an unlabeled runnable (one not associated with a
   // SchedulerGroup).
   mozilla::TimeStamp mLastUnlabeledRunnable;
 
   // Set to true if this thread creates a JSRuntime.
   bool mCanInvokeJS;
 
-#ifndef RELEASE_OR_BETA
   bool GetSchedulerLoggingEnabled();
   mozilla::TimeStamp mNextIdleDeadline;
   // Used to track which event is being executed by ProcessNextEvent
   nsCOMPtr<nsIRunnable> mCurrentEvent;
   mozilla::TimeStamp mCurrentEventStart;
   uint32_t mCurrentEventLoopDepth;
   RefPtr<mozilla::PerformanceCounter> mCurrentPerformanceCounter;
-#endif
 };
 
 #if defined(XP_UNIX) && !defined(ANDROID) && !defined(DEBUG) && HAVE_UALARM \
   && defined(_GNU_SOURCE)
 # define MOZ_CANARY
 
 extern int sCanaryOutputFD;
 #endif