diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index c60121956621..91d151b126bf 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -11170,6 +11170,8 @@ bool ConnectionPool::ScheduleTransaction(TransactionInfo* aTransactionInfo, nsresult rv = NS_NewNamedThread(runnable->GetThreadName(), getter_AddRefs(newThread), runnable); if (NS_SUCCEEDED(rv)) { + newThread->SetNameForWakeupTelemetry( + NS_LITERAL_CSTRING("IndexedDB (all)")); MOZ_ASSERT(newThread); IDB_DEBUG_LOG(("ConnectionPool created thread %" PRIu32, diff --git a/xpcom/threads/LazyIdleThread.cpp b/xpcom/threads/LazyIdleThread.cpp index 723a0808f521..d2aebf892157 100644 --- a/xpcom/threads/LazyIdleThread.cpp +++ b/xpcom/threads/LazyIdleThread.cpp @@ -445,6 +445,11 @@ LazyIdleThread::GetLastLongNonIdleTaskEnd(TimeStamp* _retval) { return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +LazyIdleThread::SetNameForWakeupTelemetry(const nsACString& aName) { + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP LazyIdleThread::AsyncShutdown() { ASSERT_OWNING_THREAD(); diff --git a/xpcom/threads/nsIThread.idl b/xpcom/threads/nsIThread.idl index aef54081d572..28368e1e7792 100644 --- a/xpcom/threads/nsIThread.idl +++ b/xpcom/threads/nsIThread.idl @@ -176,4 +176,6 @@ interface nsIThread : nsISerialEventTarget */ [noscript] readonly attribute TimeStamp lastLongTaskEnd; [noscript] readonly attribute TimeStamp lastLongNonIdleTaskEnd; + + [noscript] void setNameForWakeupTelemetry(in ACString name); }; diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index 7c469fb91899..99043e5ef252 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -779,6 +779,14 @@ nsThread::GetLastLongNonIdleTaskEnd(TimeStamp* _retval) { return NS_OK; } +NS_IMETHODIMP +nsThread::SetNameForWakeupTelemetry(const nsACString& aName) { +#ifdef EARLY_BETA_OR_EARLIER + mNameForWakeupTelemetry = aName; +#endif + return NS_OK; +} + NS_IMETHODIMP nsThread::AsyncShutdown() { LOG(("THRD(%p) async shutdown\n", this)); @@ -1137,7 +1145,9 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult) { if (ms < 0) { ms = 0; } - const char* name = PR_GetThreadName(mThread); + const char* name = !mNameForWakeupTelemetry.IsEmpty() + ? mNameForWakeupTelemetry.get() + : PR_GetThreadName(mThread); if (!name) { name = IsMainThread() ? "MainThread" : "(nameless thread)"; } diff --git a/xpcom/threads/nsThread.h b/xpcom/threads/nsThread.h index 9f1868253cfb..8c8f67d6b122 100644 --- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -245,6 +245,7 @@ class nsThread : public nsIThreadInternal, mozilla::TimeStamp mNextIdleDeadline; #ifdef EARLY_BETA_OR_EARLIER + nsCString mNameForWakeupTelemetry; mozilla::TimeStamp mLastWakeupCheckTime; uint32_t mWakeupCount = 0; #endif