Closed
Bug 788022
Opened 11 years ago
Closed 11 years ago
Add support for dalvik profiling
Categories
(Core :: Gecko Profiler, defect)
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: jrmuizel, Assigned: BenWa)
References
Details
Attachments
(1 file, 11 obsolete files)
33.45 KB,
patch
|
BenWa
:
review+
|
Details | Diff | Splinter Review |
I think we should be able to dvmDumpThreadStack safely from a signal handler. This should give us the information we need. We may need some dirtyness to hook this up though. Dalvik has a hacky dvmDumpRunningThreadStack that suggests that this is remotely possible. It may also be worth investigating what the debugger does to get stacks.
Assignee | ||
Comment 1•11 years ago
|
||
I've discussed this a bit with snorp and blassey. There's a few options but we're not sure at this point if they are signal safe. We could always spawn a JVM sampling thread and use: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#getAllStackTraces%28%29
Assignee | ||
Comment 2•11 years ago
|
||
This patch appears to be working. It's missing (1) stopping, (2) ifdefs, (3) controlling interval & sample size. This patch will also need cleopatra changes to handle the new thread in the profile file.
Assignee: nobody → bgirard
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•11 years ago
|
||
Here's an example of what I have so far. Of course we can't easily visualize it until bug 837460 is fixed: { "name": "Java Main Thread", "samples": [ { "frames": [ { "location": "android.os.MessageQueue.nativePollOnce()" }, { "location": "android.os.MessageQueue.next()" }, { "location": "android.os.Looper.loop()" }, { "location": "android.app.ActivityThread.main()" }, { "location": "java.lang.reflect.Method.invokeNative()" }, { "location": "java.lang.reflect.Method.invoke()" }, { "location": "com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()" }, { "location": "com.android.internal.os.ZygoteInit.main()" }, { "location": "dalvik.system.NativeStart.main()" } ] }, ...
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #709451 -
Attachment is obsolete: true
Assignee | ||
Comment 5•11 years ago
|
||
Attachment #709716 -
Attachment is obsolete: true
Updated•11 years ago
|
OS: Mac OS X → Android
Hardware: x86 → All
Assignee | ||
Comment 6•11 years ago
|
||
Attachment #709717 -
Attachment is obsolete: true
Attachment #709911 -
Flags: review?(snorp)
Assignee | ||
Comment 7•11 years ago
|
||
Attachment #709911 -
Attachment is obsolete: true
Attachment #709911 -
Flags: review?(snorp)
Attachment #709912 -
Flags: review?(snorp)
Assignee | ||
Comment 8•11 years ago
|
||
Note that this can land before bug 837460 but we can't see the results in it lands.
Assignee | ||
Comment 9•11 years ago
|
||
Now that bug 837460 is landed I can post links to sample profile: http://people.mozilla.com/~bgirard/cleopatra/#report=2c44df22ccb94a5edf0645171ede974b134b0193
Comment 10•11 years ago
|
||
Comment on attachment 709912 [details] [diff] [review] patch Review of attachment 709912 [details] [diff] [review]: ----------------------------------------------------------------- Looks good modulo the nits ::: mobile/android/base/GeckoJavaSampler.java @@ +16,5 @@ > + private static Thread sSamplingThread = null; > + private static boolean sPauseSampler = false; > + private static boolean sStopSampler = false; > + > + private static Sample[][] sSamples; So this is supposed to be sSamples[threadId][sampleIndex]? Maybe use a Map or something instead? Map<int, Sample[]> @@ +17,5 @@ > + private static boolean sPauseSampler = false; > + private static boolean sStopSampler = false; > + > + private static Sample[][] sSamples; > + private static int sSamplePos; I don't think any of this should be static except maybe sMainThread and LOGTAG. @@ +23,5 @@ > + > + private static class Sample { > + public Frame[] mFrames; > + public double mTime; > + public Sample(StackTraceElement[] pBT) { What is pBT? Seems like a weird name. @@ +36,5 @@ > + } > + } > + } > + private static class Frame { > + public String mFileName; I think if you're going to use it as a bare struct, just drop the mFoo stuff. mFileName -> fileName, etc. @@ +97,5 @@ > + } > + return null; > + } > + > + private synchronized static Sample getSample(int aThreadId, int aSampleId) { These methods don't need to be static once the members are fixed
Attachment #709912 -
Flags: review?(snorp) → review+
Assignee | ||
Comment 11•11 years ago
|
||
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #10) > @@ +17,5 @@ > > + private static boolean sPauseSampler = false; > > + private static boolean sStopSampler = false; > > + > > + private static Sample[][] sSamples; > > + private static int sSamplePos; > > I don't think any of this should be static except maybe sMainThread and > LOGTAG. > I don't have any instances of GeckoJavaSampler. Are you suggesting that I create a singleton? I could move some of this into SamplingThread but not sSamplingThread. I synchronize all the access on 'GeckoJavaSampler.class' so this should be safe.
Comment 12•11 years ago
|
||
(In reply to Benoit Girard (:BenWa) from comment #11) > (In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #10) > > @@ +17,5 @@ > > > + private static boolean sPauseSampler = false; > > > + private static boolean sStopSampler = false; > > > + > > > + private static Sample[][] sSamples; > > > + private static int sSamplePos; > > > > I don't think any of this should be static except maybe sMainThread and > > LOGTAG. > > > > I don't have any instances of GeckoJavaSampler. Are you suggesting that I > create a singleton? I could move some of this into SamplingThread but not > sSamplingThread. I synchronize all the access on 'GeckoJavaSampler.class' so > this should be safe. Oh, I actually misread the first time. Yeah, I think most of it should be in SamplingThread. Static state bugs me.
Assignee | ||
Comment 13•11 years ago
|
||
Re-requesting review for non trivial changes: -Cap the sampling interval to 10ms for the java thread because 1ms has too many gaps. -Lowered java samples to 1000. With 10ms interval we need less samples. This will give less OOM failures -I moved some variables into SamplingThread. This still leaves several static methods and I'm not convinced this was an improvement.
Attachment #709912 -
Attachment is obsolete: true
Attachment #710928 -
Flags: review?(snorp)
Updated•11 years ago
|
Attachment #710928 -
Flags: review?(snorp) → review+
Assignee | ||
Comment 14•11 years ago
|
||
Blocking on bug 779291 to minimize conflicts. If there's a strong demand for this ASAP then I may revisit this decision. It should be easy to apply locally.
Depends on: 779291
Assignee | ||
Comment 15•11 years ago
|
||
Kats can you review the changes to the jni-stubs?
Attachment #710928 -
Attachment is obsolete: true
Attachment #739403 -
Flags: review?(bugmail.mozilla)
Assignee | ||
Comment 16•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=f91d748329ca
Comment 17•11 years ago
|
||
Comment on attachment 739403 [details] [diff] [review] patch rebased r=snorp Review of attachment 739403 [details] [diff] [review]: ----------------------------------------------------------------- Looks fine. If you want you can also put the native method in GeckoJavaSampler directly (and make it private), and add GeckoJavaSampler.java to the CLASSES_WITH_JNI variable in the Makefile. It'll be more encapsulated that way. I did the same thing in https://bugzilla.mozilla.org/attachment.cgi?id=739196&action=diff if you want an example.
Attachment #739403 -
Flags: review?(bugmail.mozilla) → review+
Assignee | ||
Comment 18•11 years ago
|
||
Attachment #739403 -
Attachment is obsolete: true
Attachment #739683 -
Flags: review+
Assignee | ||
Comment 19•11 years ago
|
||
Attachment #739683 -
Attachment is obsolete: true
Attachment #739693 -
Flags: review+
Assignee | ||
Comment 20•11 years ago
|
||
Rebased again. This patch queue is really tied together.
Attachment #739693 -
Attachment is obsolete: true
Attachment #739744 -
Flags: review+
Assignee | ||
Comment 21•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/26ab26b299a5
Comment 22•11 years ago
|
||
Backed out for bustage: https://tbpl.mozilla.org/php/getParsedLog.php?id=22091352&tree=Mozilla-Inbound remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/c2d4abcf30df
Assignee | ||
Comment 23•11 years ago
|
||
I keep forgetting that ANDROID also implies b2g :(
Attachment #739744 -
Attachment is obsolete: true
Attachment #740365 -
Flags: review+
Assignee | ||
Comment 24•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=cd8ceefc2683
Assignee | ||
Comment 25•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=44aae84a0c0a
Assignee | ||
Comment 26•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=0cc538e7a31a
Assignee | ||
Comment 27•11 years ago
|
||
JNI symbol name fix
Attachment #740365 -
Attachment is obsolete: true
Attachment #740899 -
Flags: review+
Comment 28•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/42f859a219d6 https://hg.mozilla.org/mozilla-central/rev/22b4a153b3c5
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Comment 29•11 years ago
|
||
It looks like the commit here broke profiling on fennec, at least on my Galaxy Nexus.
Assignee | ||
Comment 30•11 years ago
|
||
(In reply to William Lachance (:wlach) from comment #29) > It looks like the commit here broke profiling on fennec, at least on my > Galaxy Nexus. wlach, this is referring to the bug where the awesome bar causes javascript to stop executing right?
Comment 31•11 years ago
|
||
(In reply to Benoit Girard (:BenWa) from comment #30) > (In reply to William Lachance (:wlach) from comment #29) > > It looks like the commit here broke profiling on fennec, at least on my > > Galaxy Nexus. > > wlach, this is referring to the bug where the awesome bar causes javascript > to stop executing right? No, I think this was bug 865915. I must have misdiagnosed the cause of problems: I'm not having any problems with profiling these days aside from it crashing when profiling sites that use canvas (which is actually not a profiler problem since they crash on their own too).
You need to log in
before you can comment on or make changes to this bug.
Description
•