mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1128768: Part 3 - Update BHR to allow for hang annotations; r=vladan
This commit is contained in:
parent
f357a87f9a
commit
c68a3139c4
@ -140,6 +140,10 @@ public:
|
||||
Telemetry::HangStack mHangStack;
|
||||
// Statistics for telemetry
|
||||
Telemetry::ThreadHangStats mStats;
|
||||
// Annotations for the current hang
|
||||
UniquePtr<HangMonitor::HangAnnotations> mAnnotations;
|
||||
// Annotators registered for this thread
|
||||
HangMonitor::Observer::Annotators mAnnotators;
|
||||
|
||||
BackgroundHangThread(const char* aName,
|
||||
uint32_t aTimeoutMs,
|
||||
@ -274,6 +278,8 @@ BackgroundHangManager::RunMonitorThread()
|
||||
currentThread->mStackHelper.GetStack(currentThread->mHangStack);
|
||||
currentThread->mHangStart = interval;
|
||||
currentThread->mHanging = true;
|
||||
currentThread->mAnnotations =
|
||||
currentThread->mAnnotators.GatherAnnotations();
|
||||
}
|
||||
} else {
|
||||
if (MOZ_LIKELY(interval != currentThread->mHangStart)) {
|
||||
@ -372,12 +378,12 @@ BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
|
||||
oldHistogram != mStats.mHangs.end(); oldHistogram++) {
|
||||
if (newHistogram == *oldHistogram) {
|
||||
// New histogram matches old one
|
||||
oldHistogram->Add(aHangTime);
|
||||
oldHistogram->Add(aHangTime, Move(mAnnotations));
|
||||
return *oldHistogram;
|
||||
}
|
||||
}
|
||||
// Add new histogram
|
||||
newHistogram.Add(aHangTime);
|
||||
newHistogram.Add(aHangTime, Move(mAnnotations));
|
||||
mStats.mHangs.append(Move(newHistogram));
|
||||
return mStats.mHangs.back();
|
||||
}
|
||||
@ -556,6 +562,33 @@ BackgroundHangMonitor::Allow()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
BackgroundHangMonitor::RegisterAnnotator(HangMonitor::Annotator& aAnnotator)
|
||||
{
|
||||
#ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
|
||||
BackgroundHangThread* thisThread = BackgroundHangThread::FindThread();
|
||||
if (!thisThread) {
|
||||
return false;
|
||||
}
|
||||
return thisThread->mAnnotators.Register(aAnnotator);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
BackgroundHangMonitor::UnregisterAnnotator(HangMonitor::Annotator& aAnnotator)
|
||||
{
|
||||
#ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
|
||||
BackgroundHangThread* thisThread = BackgroundHangThread::FindThread();
|
||||
if (!thisThread) {
|
||||
return false;
|
||||
}
|
||||
return thisThread->mAnnotators.Unregister(aAnnotator);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Because we are iterating through the BackgroundHangThread linked list,
|
||||
we need to take a lock. Using MonitorAutoLock as a base class makes
|
||||
|
@ -7,8 +7,9 @@
|
||||
#ifndef mozilla_BackgroundHangMonitor_h
|
||||
#define mozilla_BackgroundHangMonitor_h
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/HangAnnotations.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -227,6 +228,21 @@ public:
|
||||
* \see Prohibit()
|
||||
*/
|
||||
static void Allow();
|
||||
|
||||
/**
|
||||
* Register an annotator with BHR for the current thread.
|
||||
* @param aAnnotator annotator to register
|
||||
* @return true if the annotator was registered, otherwise false.
|
||||
*/
|
||||
static bool RegisterAnnotator(HangMonitor::Annotator& aAnnotator);
|
||||
|
||||
/**
|
||||
* Unregister an annotator that was previously registered via
|
||||
* RegisterAnnotator.
|
||||
* @param aAnnotator annotator to unregister
|
||||
* @return true if there are still remaining annotators registered
|
||||
*/
|
||||
static bool UnregisterAnnotator(HangMonitor::Annotator& aAnnotator);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user