Bug 1447338 - Add thread "responsiveness" as a configurable feature to the Gecko Profiler; r=mstange

MozReview-Commit-ID: KTJRvQzUwsf

--HG--
extra : rebase_source : 8692309978447fcccb2b6463c15fccda23cd3069
This commit is contained in:
Greg Tatum 2018-03-28 15:28:54 -05:00
Родитель 8b89b31d17
Коммит e642a3ee41
8 изменённых файлов: 33 добавлений и 12 удалений

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

@ -29,6 +29,7 @@
"mainthreadio",
"memory",
"privacy",
"responsiveness",
"restyle",
"screenshots",
"stackwalk",

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

@ -95,6 +95,12 @@ const featureCheckboxes = [
title: "Record JavaScript stack information, and interleave it with native stacks.",
recommended: true
},
{
name: "Responsiveness",
value: "responsiveness",
title: "Collect thread responsiveness information.",
recommended: true
},
{
name: "Java",
value: "java",

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

@ -88,7 +88,7 @@ function entries(state = 10000000, action) {
* The features that are enabled for the profiler.
* @param {array} state
*/
function features(state = ["js", "stackwalk"], action) {
function features(state = ["js", "stackwalk", "responsiveness"], action) {
switch (action.type) {
case "CHANGE_FEATURES":
return action.features;

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

@ -55,7 +55,8 @@ exports.PerfActor = ActorClassWithSpec(perfSpec, {
const settings = {
entries: options.entries || 1000000,
interval: options.interval || 1,
features: options.features || ["js", "stackwalk", "threads", "leaf"],
features: options.features ||
["js", "stackwalk", "responsiveness", "threads", "leaf"],
threads: options.threads || ["GeckoMain", "Compositor"]
};

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

@ -18,11 +18,14 @@
#endif
ProfiledThreadData::ProfiledThreadData(ThreadInfo* aThreadInfo,
nsIEventTarget* aEventTarget)
nsIEventTarget* aEventTarget,
bool aIncludeResponsiveness)
: mThreadInfo(aThreadInfo)
{
MOZ_COUNT_CTOR(ProfiledThreadData);
mResponsiveness.emplace(aEventTarget, aThreadInfo->IsMainThread());
if (aIncludeResponsiveness) {
mResponsiveness.emplace(aEventTarget, aThreadInfo->IsMainThread());
}
}
ProfiledThreadData::~ProfiledThreadData()

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

@ -42,7 +42,8 @@
class ProfiledThreadData final
{
public:
ProfiledThreadData(ThreadInfo* aThreadInfo, nsIEventTarget* aEventTarget);
ProfiledThreadData(ThreadInfo* aThreadInfo, nsIEventTarget* aEventTarget,
bool aIncludeResponsiveness);
~ProfiledThreadData();
void NotifyUnregistered(uint64_t aBufferPosition)
@ -63,8 +64,8 @@ public:
const mozilla::TimeStamp& aProcessStartTime,
double aSinceTime);
// Returns nullptr if this is not the main thread or if this thread is not
// being profiled.
// Returns nullptr if this is not the main thread, the responsiveness
// feature is not turned on, or if this thread is not being profiled.
ThreadResponsiveness* GetThreadResponsiveness()
{
ThreadResponsiveness* responsiveness = mResponsiveness.ptrOr(nullptr);

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

@ -1794,7 +1794,8 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock,
// java thread, we have to get thread id and name via JNI.
RefPtr<ThreadInfo> threadInfo =
new ThreadInfo("Java Main Thread", 0, false);
ProfiledThreadData profiledThreadData(threadInfo, nullptr);
ProfiledThreadData profiledThreadData(threadInfo, nullptr,
ActivePS::FeatureResponsiveness(aLock));
profiledThreadData.StreamJSON(*javaBuffer.get(), nullptr, aWriter,
CorePS::ProcessStartTime(), aSinceTime);
@ -2089,7 +2090,10 @@ SamplerThread::Run()
}
}
profiledThreadData->GetThreadResponsiveness()->Update();
ThreadResponsiveness* resp = profiledThreadData->GetThreadResponsiveness();
if (resp) {
resp->Update();
}
TimeStamp now = TimeStamp::Now();
SuspendAndSampleAndResumeThread(lock, *registeredThread,
@ -2269,7 +2273,8 @@ locked_register_thread(PSLockRef aLock, const char* aName, void* aStackTop)
nsCOMPtr<nsIEventTarget> eventTarget = registeredThread->GetEventTarget();
ProfiledThreadData* profiledThreadData =
ActivePS::AddLiveProfiledThread(aLock, registeredThread.get(),
MakeUnique<ProfiledThreadData>(info, eventTarget));
MakeUnique<ProfiledThreadData>(info, eventTarget,
ActivePS::FeatureResponsiveness(aLock)));
if (ActivePS::FeatureJS(aLock)) {
// This StartJSSampling() call is on-thread, so we can poll manually to
@ -2871,7 +2876,8 @@ locked_profiler_start(PSLockRef aLock, uint32_t aEntries, double aInterval,
nsCOMPtr<nsIEventTarget> eventTarget = registeredThread->GetEventTarget();
ProfiledThreadData* profiledThreadData =
ActivePS::AddLiveProfiledThread(aLock, registeredThread.get(),
MakeUnique<ProfiledThreadData>(info, eventTarget));
MakeUnique<ProfiledThreadData>(info, eventTarget,
ActivePS::FeatureResponsiveness(aLock)));
if (ActivePS::FeatureJS(aLock)) {
registeredThread->StartJSSampling(
ActivePS::FeatureTrackOptimizations(aLock));

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

@ -122,8 +122,11 @@ class TimeStamp;
/* Do not include user-identifiable information. */ \
macro(5, "privacy", Privacy) \
\
/* Collect thread responsiveness information. */ \
macro(6, "responsiveness", Responsiveness) \
\
/* Restyle profiling. */ \
macro(6, "restyle", Restyle) \
macro(7, "restyle", Restyle) \
\
/* Take a snapshot of the window on every composition. */ \
macro(7, "screenshots", Screenshots) \