Bug 1346415 - Collect native stacks at the same time as pseudostacks on nightly, r=mconley

This commit is contained in:
Michael Layzell 2017-04-18 17:17:06 -04:00
Родитель 58464c1919
Коммит 5f77ef972f
2 изменённых файлов: 37 добавлений и 1 удалений

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

@ -73,9 +73,17 @@ public:
HangStack(HangStack&& aOther)
: mImpl(mozilla::Move(aOther.mImpl))
, mBuffer(mozilla::Move(aOther.mBuffer))
, mNativeFrames(mozilla::Move(aOther.mNativeFrames))
{
}
HangStack& operator=(HangStack&& aOther) {
mImpl = mozilla::Move(aOther.mImpl);
mBuffer = mozilla::Move(aOther.mBuffer);
mNativeFrames = mozilla::Move(aOther.mNativeFrames);
return *this;
}
bool operator==(const HangStack& aOther) const {
for (size_t i = 0; i < length(); i++) {
if (!IsSameAsEntry(operator[](i), aOther[i])) {
@ -231,6 +239,7 @@ private:
public:
TimeHistogram mActivity;
mozilla::Vector<HangHistogram, 4> mHangs;
uint32_t mNativeStackCnt;
explicit ThreadHangStats(const char* aName)
: mName(aName)
@ -240,6 +249,7 @@ public:
: mName(mozilla::Move(aOther.mName))
, mActivity(mozilla::Move(aOther.mActivity))
, mHangs(mozilla::Move(aOther.mHangs))
, mNativeStackCnt(0)
{
}
const char* GetName() const {

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

@ -32,6 +32,16 @@
// It can be scaled back again in the future
#define BHR_BETA_MOD 1;
// This variable controls the maximum number of native hang stacks which may be
// attached to a ping. This is due to how large native stacks can be. We want to
// reduce the chance of a ping being discarded due to it exceeding the maximum
// ping size.
//
// NOTE: 300 native hang stacks would, by a rough estimation based on stacks
// collected from nightly on March 21, 2017, take up approximately 168kb of
// space.
static const uint32_t kMaximumNativeHangStacks = 300;
// Maximum depth of the call stack in the reported thread hangs. This value represents
// the 99.9th percentile of the thread hangs stack depths reported by Telemetry.
static const size_t kMaxThreadHangStackDepth = 30;
@ -180,6 +190,8 @@ public:
ThreadStackHelper mStackHelper;
// Stack of current hang
Telemetry::HangStack mHangStack;
// Native stack of current hang
Telemetry::HangStack mNativeHangStack;
// Statistics for telemetry
Telemetry::ThreadHangStats mStats;
// Annotations for the current hang
@ -337,6 +349,16 @@ BackgroundHangManager::RunMonitorThread()
currentThread->mHanging = true;
currentThread->mAnnotations =
currentThread->mAnnotators.GatherAnnotations();
#ifdef NIGHTLY_BUILD
// NOTE: In nightly builds of firefox we want to collect native stacks
// for all hangs, not just permahangs.
currentThread->mStats.mNativeStackCnt += 1;
if (currentThread->mStats.mNativeStackCnt <= kMaximumNativeHangStacks) {
currentThread->mStackHelper.GetNativeStack(
currentThread->mNativeHangStack);
}
#endif
}
} else {
if (MOZ_LIKELY(interval != currentThread->mHangStart)) {
@ -452,6 +474,7 @@ BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
}
Telemetry::HangHistogram newHistogram(Move(mHangStack));
newHistogram.GetNativeStack() = Move(mNativeHangStack);
for (Telemetry::HangHistogram* oldHistogram = mStats.mHangs.begin();
oldHistogram != mStats.mHangs.end(); oldHistogram++) {
if (newHistogram == *oldHistogram) {
@ -477,7 +500,10 @@ BackgroundHangThread::ReportPermaHang()
Telemetry::HangHistogram& hang = ReportHang(mMaxTimeout);
Telemetry::HangStack& stack = hang.GetNativeStack();
if (stack.empty()) {
mStackHelper.GetNativeStack(stack);
mStats.mNativeStackCnt += 1;
if (mStats.mNativeStackCnt <= kMaximumNativeHangStacks) {
mStackHelper.GetNativeStack(stack);
}
}
}