Bug 1423890 - Add markers for background hangs r=dthayer,mstange

MozReview-Commit-ID: 484UZEbbd12

--HG--
extra : rebase_source : f739ce23944205cb88e8ea40289c8de6f07d1034
This commit is contained in:
Alexandre Poirot 2017-12-07 02:35:36 -08:00
Родитель aefd728c18
Коммит f572e41c43
5 изменённых файлов: 47 добавлений и 4 удалений

Просмотреть файл

@ -26,6 +26,10 @@
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
#include "GeckoProfiler.h"
#ifdef MOZ_GECKO_PROFILER
#include "mozilla/TimeStamp.h"
#include "ProfilerMarkerPayload.h"
#endif
#include "nsNetCID.h"
#include "HangDetails.h"
@ -214,7 +218,7 @@ public:
// Report a hang; aManager->mLock IS locked. The hang will be processed
// off-main-thread, and will then be submitted back.
void ReportHang(PRIntervalTime aHangTime);
void ReportHang(PRIntervalTime aHangTime, TimeStamp aHangEndTime);
// Report a permanent hang; aManager->mLock IS locked
void ReportPermaHang();
// Called by BackgroundHangMonitor::NotifyActivity
@ -386,7 +390,7 @@ BackgroundHangManager::RunMonitorThread()
} else {
if (MOZ_LIKELY(interval != currentThread->mHangStart)) {
// A hang ended
currentThread->ReportHang(intervalNow - currentThread->mHangStart);
currentThread->ReportHang(intervalNow - currentThread->mHangStart, TimeStamp::Now());
currentThread->mHanging = false;
}
}
@ -464,12 +468,13 @@ BackgroundHangThread::~BackgroundHangThread()
}
void
BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
BackgroundHangThread::ReportHang(PRIntervalTime aHangTime, TimeStamp aHangEndTime)
{
// Recovered from a hang; called on the monitor thread
// mManager->mLock IS locked
HangDetails hangDetails(aHangTime,
aHangEndTime,
XRE_GetProcessType(),
mThreadName,
mRunnableName,
@ -501,7 +506,7 @@ BackgroundHangThread::ReportPermaHang()
//
// We currently don't look at hang reports outside of nightly, and already
// collect native stacks eagerly on nightly, so this should be OK.
ReportHang(mMaxTimeout);
ReportHang(mMaxTimeout, TimeStamp::Now());
}
MOZ_ALWAYS_INLINE void

Просмотреть файл

@ -5,6 +5,9 @@
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Unused.h"
#include "mozilla/GfxMessageUtils.h" // For ParamTraits<GeckoProcessType>
#ifdef MOZ_GECKO_PROFILER
#include "ProfilerMarkerPayload.h"
#endif
namespace mozilla {
@ -269,6 +272,16 @@ nsHangDetails::Submit()
NS_WARNING("Unsupported BHR process type - discarding hang.");
break;
}
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
TimeStamp endTime = hangDetails->mDetails.mEndTime;
TimeStamp startTime = endTime -
TimeDuration::FromMilliseconds(hangDetails->mDetails.mDuration);
profiler_add_marker(
"BHR-detected hang",
MakeUnique<HangMarkerPayload>(startTime, endTime));
}
#endif
});
nsresult rv = SystemGroup::Dispatch(TaskCategory::Other,

Просмотреть файл

@ -15,6 +15,7 @@
#include "mozilla/HangAnnotations.h"
#include "nsTArray.h"
#include "nsIHangDetails.h"
#include "mozilla/TimeStamp.h"
namespace mozilla {
@ -31,6 +32,7 @@ class HangDetails
public:
HangDetails()
: mDuration(0)
, mEndTime(TimeStamp::Now())
, mProcess(GeckoProcessType_Invalid)
, mRemoteType(VoidString())
{}
@ -38,12 +40,14 @@ public:
HangDetails(const HangDetails& aOther) = default;
HangDetails(HangDetails&& aOther) = default;
HangDetails(uint32_t aDuration,
TimeStamp aEndTime,
GeckoProcessType aProcess,
const nsACString& aThreadName,
const nsACString& aRunnableName,
HangStack&& aStack,
HangMonitor::HangAnnotations&& aAnnotations)
: mDuration(aDuration)
, mEndTime(aEndTime)
, mProcess(aProcess)
, mRemoteType(VoidString())
, mThreadName(aThreadName)
@ -53,6 +57,7 @@ public:
{}
uint32_t mDuration;
TimeStamp mEndTime;
GeckoProcessType mProcess;
// NOTE: mRemoteType is set in nsHangDetails::Submit before the HangDetails
// object is sent to the parent process.

Просмотреть файл

@ -157,3 +157,11 @@ GCMinorMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
aWriter.NullProperty("nursery");
}
}
void
HangMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks)
{
StreamCommonProps("BHR-detected hang", aWriter, aProcessStartTime, aUniqueStacks);
}

Просмотреть файл

@ -250,4 +250,16 @@ private:
JS::UniqueChars mTimingData;
};
class HangMarkerPayload : public ProfilerMarkerPayload
{
public:
HangMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime)
{}
DECL_STREAM_PAYLOAD
private:
};
#endif // ProfilerMarkerPayload_h