author | Nicholas Nethercote <nnethercote@mozilla.com> |
Mon, 24 Apr 2017 09:49:28 +1000 | |
changeset 355422 | 27ac1ce3ebc8f9a10a84c4c044c50789eaf5333b |
parent 355421 | af4f0150320bb7139a0a5ec84c8a6df49a5d671a |
child 355423 | 572e82ea517b893af4733c2b67a974ed2fa62f12 |
push id | 89677 |
push user | nnethercote@mozilla.com |
push date | Fri, 28 Apr 2017 07:51:16 +0000 |
treeherder | mozilla-inbound@658b857c35f8 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mstange |
bugs | 1359000 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -2401,41 +2401,39 @@ locked_profiler_start(PSLockRef aLock, i // Fall back to the default values if the passed-in values are unreasonable. int entries = aEntries > 0 ? aEntries : PROFILE_DEFAULT_ENTRIES; double interval = aInterval > 0 ? aInterval : PROFILE_DEFAULT_INTERVAL; ActivePS::Create(aLock, entries, interval, aFeatures, aFeatureCount, aFilters, aFilterCount); // Set up profiling for each registered thread, if appropriate. + Thread::tid_t tid = Thread::GetCurrentId(); const CorePS::ThreadVector& liveThreads = CorePS::LiveThreads(aLock); for (uint32_t i = 0; i < liveThreads.size(); i++) { ThreadInfo* info = liveThreads.at(i); if (ActivePS::ShouldProfileThread(aLock, info)) { info->StartProfiling(); if (ActivePS::FeatureJS(aLock)) { info->Stack()->startJSSampling(); + if (info->ThreadId() == tid) { + // We can manually poll the current thread so it starts sampling + // immediately. + info->Stack()->pollJSSampling(); + } } } } // Dead ThreadInfos are deleted in profiler_stop(), and dead ThreadInfos // aren't saved when the profiler is inactive. Therefore the dead threads // vector should be empty here. MOZ_RELEASE_ASSERT(CorePS::DeadThreads(aLock).empty()); - if (ActivePS::FeatureJS(aLock)) { - // We just called startJSSampling() on all relevant threads. We can also - // manually poll the current thread so it starts sampling immediately. - if (PseudoStack* pseudoStack = tlsPseudoStack.get()) { - pseudoStack->pollJSSampling(); - } - } - #ifdef MOZ_TASK_TRACER if (featureTaskTracer) { mozilla::tasktracer::StartLogging(); } #endif #if defined(PROFILE_JAVA) if (ActivePS::FeatureJava(aLock)) { @@ -2496,43 +2494,40 @@ locked_profiler_stop(PSLockRef aLock) #ifdef MOZ_TASK_TRACER if (ActivePS::FeatureTaskTracer(aLock)) { mozilla::tasktracer::StopLogging(); } #endif // Stop sampling live threads. + Thread::tid_t tid = Thread::GetCurrentId(); CorePS::ThreadVector& liveThreads = CorePS::LiveThreads(aLock); for (uint32_t i = 0; i < liveThreads.size(); i++) { ThreadInfo* info = liveThreads.at(i); if (info->IsBeingProfiled()) { if (ActivePS::FeatureJS(aLock)) { info->Stack()->stopJSSampling(); + if (info->ThreadId() == tid) { + // We can manually poll the current thread so it stops profiling + // immediately. + info->Stack()->pollJSSampling(); + } } info->StopProfiling(); } } // This is where we destroy the ThreadInfos for all dead threads. CorePS::ThreadVector& deadThreads = CorePS::DeadThreads(aLock); while (deadThreads.size() > 0) { delete deadThreads.back(); deadThreads.pop_back(); } - if (ActivePS::FeatureJS(aLock)) { - // We just called stopJSSampling() (through ThreadInfo::StopProfiling) on - // all relevant threads. We can also manually poll the current thread so - // it stops profiling immediately. - if (PseudoStack* stack = tlsPseudoStack.get()) { - stack->pollJSSampling(); - } - } - // The Stop() call doesn't actually stop Run(); that happens in this // function's caller when the sampler thread is destroyed. Stop() just gives // the SamplerThread a chance to do some cleanup with gPSMutex locked. SamplerThread* samplerThread = ActivePS::Destroy(aLock); samplerThread->Stop(aLock); return samplerThread; }