зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323100 - Register most of the remaining threadfunc threads with the profiler. r=froydnj
As far as I can tell, this covers all the remaining threads which we start using PR_CreateThread, except the ones that are created inside NSPR or NSS. This adds a AutoProfilerRegister stack class for easy registering and unregistering. There are a few places where we still call profiler_register_thread() and profiler_unregister_thread() manually, either because registration happens conditionally, or because there is a variable that gets put on the stack before the AutoProfilerRegister (e.g. a dynamically generated thread name). AutoProfilerRegister needs to be the first object on the stack because it uses its own `this` pointer as the stack top address. MozReview-Commit-ID: 3vwhS55Yzt --HG-- extra : rebase_source : dffab11abf7d4b57fa54475fd22e71b84375cd7b
This commit is contained in:
Родитель
38bf16074f
Коммит
48513de60f
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "HRTFDatabaseLoader.h"
|
||||
#include "HRTFDatabase.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -151,6 +152,7 @@ void HRTFDatabaseLoader::MainThreadRelease()
|
|||
// Asynchronously load the database in this thread.
|
||||
static void databaseLoaderEntry(void* threadData)
|
||||
{
|
||||
AutoProfilerRegister registerThread("HRTFDatabaseLdr");
|
||||
PR_SetCurrentThreadName("HRTFDatabaseLdr");
|
||||
|
||||
HRTFDatabaseLoader* loader = reinterpret_cast<HRTFDatabaseLoader*>(threadData);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "mozilla/IOInterposer.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Tokenizer.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
// How long we collect write oprerations
|
||||
// before they are flushed to the database
|
||||
|
@ -337,6 +338,7 @@ DOMStorageDBThread::SetDefaultPriority()
|
|||
void
|
||||
DOMStorageDBThread::ThreadFunc(void* aArg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("localStorage DB");
|
||||
PR_SetCurrentThreadName("localStorage DB");
|
||||
mozilla::IOInterposer::RegisterCurrentThread();
|
||||
|
||||
|
|
|
@ -1166,6 +1166,7 @@ AutoLockWatchdog::~AutoLockWatchdog()
|
|||
static void
|
||||
WatchdogMain(void* arg)
|
||||
{
|
||||
mozilla::AutoProfilerRegister registerThread("JS Watchdog");
|
||||
PR_SetCurrentThreadName("JS Watchdog");
|
||||
|
||||
Watchdog* self = static_cast<Watchdog*>(arg);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsPrintfCString.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/IOInterposer.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
|
@ -437,6 +438,7 @@ already_AddRefed<nsIEventTarget> CacheIOThread::Target()
|
|||
// static
|
||||
void CacheIOThread::ThreadFunc(void* aClosure)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Cache2 I/O");
|
||||
PR_SetCurrentThreadName("Cache2 I/O");
|
||||
mozilla::IOInterposer::RegisterCurrentThread();
|
||||
CacheIOThread* thread = static_cast<CacheIOThread*>(aClosure);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsURLHelper.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "GetAddrInfo.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
@ -1435,12 +1436,15 @@ nsHostResolver::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const
|
|||
void
|
||||
nsHostResolver::ThreadFunc(void *arg)
|
||||
{
|
||||
char stackTop;
|
||||
|
||||
LOG(("DNS lookup thread - starting execution.\n"));
|
||||
|
||||
static nsThreadPoolNaming naming;
|
||||
nsCString name = naming.GetNextThreadName("DNS Resolver");
|
||||
|
||||
PR_SetCurrentThreadName(name.BeginReading());
|
||||
profiler_register_thread(name.BeginReading(), &stackTop);
|
||||
|
||||
#if defined(RES_RETRY_ON_FAILURE)
|
||||
nsResState rs;
|
||||
|
@ -1511,6 +1515,8 @@ nsHostResolver::ThreadFunc(void *arg)
|
|||
resolver->mThreadCount--;
|
||||
NS_RELEASE(resolver);
|
||||
LOG(("DNS lookup thread - queue empty, thread finished.\n"));
|
||||
|
||||
profiler_unregister_thread();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsNSSShutDown.h"
|
||||
#include "PSMRunnable.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::psm;
|
||||
|
@ -114,6 +115,7 @@ nsresult nsKeygenThread::ConsumeResult(
|
|||
|
||||
static void nsKeygenThreadRunner(void *arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Keygen");
|
||||
PR_SetCurrentThreadName("Keygen");
|
||||
nsKeygenThread *self = static_cast<nsKeygenThread *>(arg);
|
||||
self->Run();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsPKCS11Slot.h"
|
||||
#include "nsProtectedAuthThread.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::psm;
|
||||
|
@ -19,6 +20,7 @@ NS_IMPL_ISUPPORTS(nsProtectedAuthThread, nsIProtectedAuthThread)
|
|||
|
||||
static void nsProtectedAuthThreadRunner(void *arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Protected Auth");
|
||||
PR_SetCurrentThreadName("Protected Auth");
|
||||
|
||||
nsProtectedAuthThread *self = static_cast<nsProtectedAuthThread *>(arg);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nspr.h"
|
||||
#include "pk11func.h"
|
||||
|
||||
|
@ -390,6 +391,7 @@ const SECMODModule* SmartCardMonitoringThread::GetModule()
|
|||
// C-like calling sequence to glue into PR_CreateThread.
|
||||
void SmartCardMonitoringThread::LaunchExecute(void* arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("SmartCard");
|
||||
PR_SetCurrentThreadName("SmartCard");
|
||||
|
||||
((SmartCardMonitoringThread*)arg)->Execute();
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
#define SC_ENDIAN "big"
|
||||
|
@ -503,6 +504,7 @@ StartupCache::WaitOnWriteThread()
|
|||
void
|
||||
StartupCache::ThreadedWrite(void *aClosure)
|
||||
{
|
||||
AutoProfilerRegister registerThread("StartupCache");
|
||||
PR_SetCurrentThreadName("StartupCache");
|
||||
mozilla::IOInterposer::RegisterCurrentThread();
|
||||
/*
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#if defined(MOZ_CRASHREPORTER)
|
||||
#include "nsExceptionHandler.h"
|
||||
#endif
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include <windows.h>
|
||||
|
@ -124,6 +125,7 @@ struct Options {
|
|||
void
|
||||
RunWatchdog(void* arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Shutdown Hang Terminator");
|
||||
PR_SetCurrentThreadName("Shutdown Hang Terminator");
|
||||
|
||||
// Let's copy and deallocate options, that's one less leak to worry
|
||||
|
@ -214,6 +216,7 @@ PRMonitor* gWriteReady = nullptr;
|
|||
|
||||
void RunWriter(void* arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Shutdown Statistics Writer");
|
||||
PR_SetCurrentThreadName("Shutdown Statistics Writer");
|
||||
|
||||
MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(arg);
|
||||
|
|
|
@ -122,6 +122,7 @@ class EventLoopLagDispatcher : public Runnable
|
|||
*/
|
||||
void TracerThread(void *arg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Event Tracer");
|
||||
PR_SetCurrentThreadName("Event Tracer");
|
||||
|
||||
TracerStartClosure* threadArgs = static_cast<TracerStartClosure*>(arg);
|
||||
|
|
|
@ -248,6 +248,14 @@ static inline bool profiler_in_privacy_mode() { return false; }
|
|||
static inline void profiler_log(const char *str) {}
|
||||
static inline void profiler_log(const char *fmt, va_list args) {}
|
||||
|
||||
class AutoProfilerRegister final MOZ_STACK_CLASS
|
||||
{
|
||||
AutoProfilerRegister(const char* aName) {}
|
||||
private:
|
||||
AutoProfilerRegister(const AutoProfilerRegister&) = delete;
|
||||
AutoProfilerRegister& operator=(const AutoProfilerRegister&) = delete;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include "GeckoProfilerImpl.h"
|
||||
|
|
|
@ -461,6 +461,26 @@ private:
|
|||
void* mHandle;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience class to register and unregister a thread with the profiler.
|
||||
* Needs to be the first object on the stack of the thread.
|
||||
*/
|
||||
class MOZ_STACK_CLASS AutoProfilerRegister final
|
||||
{
|
||||
public:
|
||||
explicit AutoProfilerRegister(const char* aName)
|
||||
{
|
||||
profiler_register_thread(aName, this);
|
||||
}
|
||||
~AutoProfilerRegister()
|
||||
{
|
||||
profiler_unregister_thread();
|
||||
}
|
||||
private:
|
||||
AutoProfilerRegister(const AutoProfilerRegister&) = delete;
|
||||
AutoProfilerRegister& operator=(const AutoProfilerRegister&) = delete;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
inline PseudoStack* mozilla_get_pseudo_stack(void)
|
||||
|
|
|
@ -114,6 +114,7 @@ MainThreadIOLoggerImpl::Init()
|
|||
/* static */ void
|
||||
MainThreadIOLoggerImpl::sIOThreadFunc(void* aArg)
|
||||
{
|
||||
AutoProfilerRegister registerThread("MainThreadIOLogger");
|
||||
PR_SetCurrentThreadName("MainThreadIOLogger");
|
||||
MainThreadIOLoggerImpl* obj = static_cast<MainThreadIOLoggerImpl*>(aArg);
|
||||
obj->IOThreadFunc();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -54,6 +55,7 @@ private:
|
|||
// Background hang monitor thread function
|
||||
static void MonitorThread(void* aData)
|
||||
{
|
||||
AutoProfilerRegister registerThread("BgHangMonitor");
|
||||
PR_SetCurrentThreadName("BgHangManager");
|
||||
|
||||
/* We do not hold a reference to BackgroundHangManager here
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#endif
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
|
@ -209,6 +210,7 @@ GetChromeHangReport(Telemetry::ProcessedStack& aStack,
|
|||
void
|
||||
ThreadMain(void*)
|
||||
{
|
||||
AutoProfilerRegister registerThread("Hang Monitor");
|
||||
PR_SetCurrentThreadName("Hang Monitor");
|
||||
|
||||
MonitorAutoLock lock(*gMonitor);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -235,10 +236,13 @@ assembleCmdLine(char* const* aArgv, wchar_t** aWideCmdLine, UINT aCodePage)
|
|||
void
|
||||
nsProcess::Monitor(void* aArg)
|
||||
{
|
||||
char stackBaseGuess;
|
||||
|
||||
RefPtr<nsProcess> process = dont_AddRef(static_cast<nsProcess*>(aArg));
|
||||
|
||||
if (!process->mBlocking) {
|
||||
PR_SetCurrentThreadName("RunProcess");
|
||||
profiler_register_thread("RunProcess", &stackBaseGuess);
|
||||
}
|
||||
|
||||
#if defined(PROCESSMODEL_WINAPI)
|
||||
|
@ -304,6 +308,10 @@ nsProcess::Monitor(void* aArg)
|
|||
} else {
|
||||
NS_DispatchToMainThread(NewRunnableMethod(process, &nsProcess::ProcessComplete));
|
||||
}
|
||||
|
||||
if (!process->mBlocking) {
|
||||
profiler_unregister_thread();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче