зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1630895 - Infer categories for Java frames. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D71383
This commit is contained in:
Родитель
31c7a3bec0
Коммит
ddece4ba4f
|
@ -72,6 +72,24 @@
|
||||||
BEGIN_CATEGORY(DOM, "DOM", "blue") \
|
BEGIN_CATEGORY(DOM, "DOM", "blue") \
|
||||||
SUBCATEGORY(DOM, DOM, "Other") \
|
SUBCATEGORY(DOM, DOM, "Other") \
|
||||||
END_CATEGORY \
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_ANDROID, "Android", "yellow") \
|
||||||
|
SUBCATEGORY(JAVA_ANDROID, JAVA_ANDROID, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_ANDROIDX, "AndroidX", "orange") \
|
||||||
|
SUBCATEGORY(JAVA_ANDROIDX, JAVA_ANDROIDX, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_LANGUAGE, "Java", "blue") \
|
||||||
|
SUBCATEGORY(JAVA_LANGUAGE, JAVA_LANGUAGE, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_MOZILLA, "Mozilla", "green") \
|
||||||
|
SUBCATEGORY(JAVA_MOZILLA, JAVA_MOZILLA, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_KOTLIN, "Kotlin", "purple") \
|
||||||
|
SUBCATEGORY(JAVA_KOTLIN, JAVA_KOTLIN, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_BLOCKED, "Blocked", "lightblue") \
|
||||||
|
SUBCATEGORY(JAVA_BLOCKED, JAVA_BLOCKED, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
BEGIN_CATEGORY(IPC, "IPC", "lightgreen") \
|
BEGIN_CATEGORY(IPC, "IPC", "lightgreen") \
|
||||||
SUBCATEGORY(IPC, IPC, "Other") \
|
SUBCATEGORY(IPC, IPC, "Other") \
|
||||||
END_CATEGORY
|
END_CATEGORY
|
||||||
|
|
|
@ -82,6 +82,27 @@ namespace baseprofiler {
|
||||||
END_CATEGORY \
|
END_CATEGORY \
|
||||||
BEGIN_CATEGORY(DOM, "DOM", "blue") \
|
BEGIN_CATEGORY(DOM, "DOM", "blue") \
|
||||||
SUBCATEGORY(DOM, DOM, "Other") \
|
SUBCATEGORY(DOM, DOM, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_ANDROID, "Android", "yellow") \
|
||||||
|
SUBCATEGORY(JAVA_ANDROID, JAVA_ANDROID, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_ANDROIDX, "AndroidX", "orange") \
|
||||||
|
SUBCATEGORY(JAVA_ANDROIDX, JAVA_ANDROIDX, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_LANGUAGE, "Java", "blue") \
|
||||||
|
SUBCATEGORY(JAVA_LANGUAGE, JAVA_LANGUAGE, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_MOZILLA, "Mozilla", "green") \
|
||||||
|
SUBCATEGORY(JAVA_MOZILLA, JAVA_MOZILLA, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_KOTLIN, "Kotlin", "purple") \
|
||||||
|
SUBCATEGORY(JAVA_KOTLIN, JAVA_KOTLIN, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(JAVA_BLOCKED, "Blocked", "lightblue") \
|
||||||
|
SUBCATEGORY(JAVA_BLOCKED, JAVA_BLOCKED, "Other") \
|
||||||
|
END_CATEGORY \
|
||||||
|
BEGIN_CATEGORY(IPC, "IPC", "lightgreen") \
|
||||||
|
SUBCATEGORY(IPC, IPC, "Other") \
|
||||||
END_CATEGORY
|
END_CATEGORY
|
||||||
|
|
||||||
// An enum that lists all possible category pairs in one list.
|
// An enum that lists all possible category pairs in one list.
|
||||||
|
|
|
@ -2327,6 +2327,40 @@ static void StreamPages(PSLockRef aLock, SpliceableJSONWriter& aWriter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GP_OS_android)
|
#if defined(GP_OS_android)
|
||||||
|
template <int N>
|
||||||
|
static bool StartsWith(const nsACString& string, const char (&prefix)[N]) {
|
||||||
|
if (N - 1 > string.Length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return memcmp(string.Data(), prefix, N - 1) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JS::ProfilingCategoryPair InferJavaCategory(nsACString& aName) {
|
||||||
|
if (aName.EqualsLiteral("android.os.MessageQueue.nativePollOnce()")) {
|
||||||
|
return JS::ProfilingCategoryPair::IDLE;
|
||||||
|
}
|
||||||
|
if (aName.EqualsLiteral("java.lang.Object.wait()")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_BLOCKED;
|
||||||
|
}
|
||||||
|
if (StartsWith(aName, "android.") || StartsWith(aName, "com.android.")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_ANDROID;
|
||||||
|
}
|
||||||
|
if (StartsWith(aName, "mozilla.") || StartsWith(aName, "org.mozilla.")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_MOZILLA;
|
||||||
|
}
|
||||||
|
if (StartsWith(aName, "java.") || StartsWith(aName, "sun.") ||
|
||||||
|
StartsWith(aName, "com.sun.")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_LANGUAGE;
|
||||||
|
}
|
||||||
|
if (StartsWith(aName, "kotlin.") || StartsWith(aName, "kotlinx.")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_KOTLIN;
|
||||||
|
}
|
||||||
|
if (StartsWith(aName, "androidx.")) {
|
||||||
|
return JS::ProfilingCategoryPair::JAVA_ANDROIDX;
|
||||||
|
}
|
||||||
|
return JS::ProfilingCategoryPair::OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
static UniquePtr<ProfileBuffer> CollectJavaThreadProfileData(
|
static UniquePtr<ProfileBuffer> CollectJavaThreadProfileData(
|
||||||
BlocksRingBuffer& bufferManager) {
|
BlocksRingBuffer& bufferManager) {
|
||||||
// locked_profiler_start uses sample count is 1000 for Java thread.
|
// locked_profiler_start uses sample count is 1000 for Java thread.
|
||||||
|
@ -2345,7 +2379,6 @@ static UniquePtr<ProfileBuffer> CollectJavaThreadProfileData(
|
||||||
|
|
||||||
buffer->AddThreadIdEntry(0);
|
buffer->AddThreadIdEntry(0);
|
||||||
buffer->AddEntry(ProfileBufferEntry::Time(sampleTime));
|
buffer->AddEntry(ProfileBufferEntry::Time(sampleTime));
|
||||||
bool parentFrameWasIdleFrame = false;
|
|
||||||
int frameId = 0;
|
int frameId = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
jni::String::LocalRef frameName =
|
jni::String::LocalRef frameName =
|
||||||
|
@ -2355,22 +2388,9 @@ static UniquePtr<ProfileBuffer> CollectJavaThreadProfileData(
|
||||||
}
|
}
|
||||||
nsCString frameNameString = frameName->ToCString();
|
nsCString frameNameString = frameName->ToCString();
|
||||||
|
|
||||||
// Compute a category pair for the frame:
|
auto categoryPair = InferJavaCategory(frameNameString);
|
||||||
// - IDLE for the wait function android.os.MessageQueue.nativePollOnce()
|
|
||||||
// - OTHER for any function that's directly called by that wait function
|
|
||||||
// - no category on everything else
|
|
||||||
Maybe<JS::ProfilingCategoryPair> categoryPair;
|
|
||||||
if (frameNameString.EqualsLiteral(
|
|
||||||
"android.os.MessageQueue.nativePollOnce()")) {
|
|
||||||
categoryPair = Some(JS::ProfilingCategoryPair::IDLE);
|
|
||||||
parentFrameWasIdleFrame = true;
|
|
||||||
} else if (parentFrameWasIdleFrame) {
|
|
||||||
categoryPair = Some(JS::ProfilingCategoryPair::OTHER);
|
|
||||||
parentFrameWasIdleFrame = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer->CollectCodeLocation("", frameNameString.get(), 0, 0, Nothing(),
|
buffer->CollectCodeLocation("", frameNameString.get(), 0, 0, Nothing(),
|
||||||
Nothing(), categoryPair);
|
Nothing(), Some(categoryPair));
|
||||||
}
|
}
|
||||||
sampleId++;
|
sampleId++;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче