mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1635442 - Only initialize LUL when the StackWalk feature is requested on Linux, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D113693
This commit is contained in:
parent
0a1e115f5b
commit
3e63d9143b
@ -411,14 +411,15 @@ static void* ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5)))) {
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
lul::LUL* lul = CorePS::Lul(aLock);
|
||||
if (!lul) {
|
||||
if (!lul && aStackWalkEnabled) {
|
||||
CorePS::SetLul(aLock, MakeUnique<lul::LUL>(logging_sink_for_LUL));
|
||||
// Read all the unwind info currently available.
|
||||
lul = CorePS::Lul(aLock);
|
||||
|
@ -179,7 +179,8 @@ static void* ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
|
@ -213,7 +213,8 @@ static unsigned int __stdcall ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
|
@ -570,7 +570,8 @@ ProfileChunkedBuffer& profiler_get_core_buffer() {
|
||||
class SamplerThread;
|
||||
|
||||
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,
|
||||
double aInterval);
|
||||
double aInterval,
|
||||
bool aStackWalkEnabled);
|
||||
|
||||
struct LiveProfiledThreadData {
|
||||
RegisteredThread* mRegisteredThread;
|
||||
@ -680,7 +681,9 @@ class ActivePS {
|
||||
// The new sampler thread doesn't start sampling immediately because the
|
||||
// main loop within Run() is blocked until this function's caller
|
||||
// unlocks gPSMutex.
|
||||
mSamplerThread(NewSamplerThread(aLock, mGeneration, aInterval)),
|
||||
mSamplerThread(
|
||||
NewSamplerThread(aLock, mGeneration, aInterval,
|
||||
ProfilerFeature::HasStackWalk(aFeatures))),
|
||||
mIsPaused(false),
|
||||
mIsSamplingPaused(false)
|
||||
#if defined(GP_OS_linux) || defined(GP_OS_freebsd)
|
||||
@ -2211,7 +2214,7 @@ class SamplerThread {
|
||||
public:
|
||||
// Creates a sampler thread, but doesn't start it.
|
||||
SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds);
|
||||
double aIntervalMilliseconds, bool aStackWalkEnabled);
|
||||
~SamplerThread();
|
||||
|
||||
// This runs on (is!) the sampler thread.
|
||||
@ -2250,8 +2253,9 @@ class SamplerThread {
|
||||
// ActivePS's constructor, but SamplerThread is defined after ActivePS. It
|
||||
// could probably be removed by moving some code around.
|
||||
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,
|
||||
double aInterval) {
|
||||
return new SamplerThread(aLock, aGeneration, aInterval);
|
||||
double aInterval,
|
||||
bool aStackWalkEnabled) {
|
||||
return new SamplerThread(aLock, aGeneration, aInterval, aStackWalkEnabled);
|
||||
}
|
||||
|
||||
// This function is the sampler thread. This implementation is used for all
|
||||
@ -2415,7 +2419,10 @@ void SamplerThread::Run() {
|
||||
// involves doing I/O (fprintf, __android_log_print, etc.) and so
|
||||
// can't safely be done from the critical section inside
|
||||
// SuspendAndSampleAndResumeThread, which is why it is done here.
|
||||
CorePS::Lul(lock)->MaybeShowStats();
|
||||
lul::LUL* lul = CorePS::Lul(lock);
|
||||
if (lul) {
|
||||
lul->MaybeShowStats();
|
||||
}
|
||||
#endif
|
||||
TimeStamp threadsSampled = TimeStamp::NowUnfuzzed();
|
||||
|
||||
|
@ -461,14 +461,15 @@ static void* ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5)))) {
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
lul::LUL* lul = CorePS::Lul(aLock);
|
||||
if (!lul) {
|
||||
if (!lul && aStackWalkEnabled) {
|
||||
CorePS::SetLul(aLock, MakeUnique<lul::LUL>(logging_sink_for_LUL));
|
||||
// Read all the unwind info currently available.
|
||||
lul = CorePS::Lul(aLock);
|
||||
|
@ -222,7 +222,8 @@ static void* ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
|
@ -232,7 +232,8 @@ static unsigned int __stdcall ThreadEntry(void* aArg) {
|
||||
}
|
||||
|
||||
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds)
|
||||
double aIntervalMilliseconds,
|
||||
bool aStackWalkEnabled)
|
||||
: mSampler(aLock),
|
||||
mActivityGeneration(aActivityGeneration),
|
||||
mIntervalMicroseconds(
|
||||
|
@ -703,7 +703,8 @@ ProfileChunkedBuffer& profiler_get_core_buffer() {
|
||||
class SamplerThread;
|
||||
|
||||
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,
|
||||
double aInterval);
|
||||
double aInterval,
|
||||
bool aStackWalkEnabled);
|
||||
|
||||
struct LiveProfiledThreadData {
|
||||
RegisteredThread* mRegisteredThread;
|
||||
@ -816,7 +817,9 @@ class ActivePS {
|
||||
// The new sampler thread doesn't start sampling immediately because the
|
||||
// main loop within Run() is blocked until this function's caller
|
||||
// unlocks gPSMutex.
|
||||
mSamplerThread(NewSamplerThread(aLock, mGeneration, aInterval)),
|
||||
mSamplerThread(
|
||||
NewSamplerThread(aLock, mGeneration, aInterval,
|
||||
ProfilerFeature::HasStackWalk(aFeatures))),
|
||||
mInterposeObserver((ProfilerFeature::HasMainThreadIO(aFeatures) ||
|
||||
ProfilerFeature::HasFileIO(aFeatures) ||
|
||||
ProfilerFeature::HasFileIOAll(aFeatures))
|
||||
@ -3253,7 +3256,7 @@ class SamplerThread {
|
||||
public:
|
||||
// Creates a sampler thread, but doesn't start it.
|
||||
SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
|
||||
double aIntervalMilliseconds);
|
||||
double aIntervalMilliseconds, bool aStackWalkEnabled);
|
||||
~SamplerThread();
|
||||
|
||||
// This runs on (is!) the sampler thread.
|
||||
@ -3356,8 +3359,9 @@ bool ActivePS::AppendPostSamplingCallback(PSLockRef aLock,
|
||||
// ActivePS's constructor, but SamplerThread is defined after ActivePS. It
|
||||
// could probably be removed by moving some code around.
|
||||
static SamplerThread* NewSamplerThread(PSLockRef aLock, uint32_t aGeneration,
|
||||
double aInterval) {
|
||||
return new SamplerThread(aLock, aGeneration, aInterval);
|
||||
double aInterval,
|
||||
bool aStackWalkEnabled) {
|
||||
return new SamplerThread(aLock, aGeneration, aInterval, aStackWalkEnabled);
|
||||
}
|
||||
|
||||
// This function is the sampler thread. This implementation is used for all
|
||||
@ -3794,7 +3798,10 @@ void SamplerThread::Run() {
|
||||
// involves doing I/O (fprintf, __android_log_print, etc.) and so
|
||||
// can't safely be done from the critical section inside
|
||||
// SuspendAndSampleAndResumeThread, which is why it is done here.
|
||||
CorePS::Lul(lock)->MaybeShowStats();
|
||||
lul::LUL* lul = CorePS::Lul(lock);
|
||||
if (lul) {
|
||||
lul->MaybeShowStats();
|
||||
}
|
||||
#endif
|
||||
TimeStamp threadsSampled = TimeStamp::NowUnfuzzed();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user