Closed Bug 860273 Opened 11 years ago Closed 7 years ago

Write a simple whole-system CPU profiler for B2G

Categories

(Firefox OS Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: justin.lebar+bug, Unassigned)

References

Details

For debugging bug 847592, it would be helpful to know which processes are sucking up the most CPU.

I'm writing a simple whole-system profiler which reads /proc/pid/stat and should be able to tell us this.  We can hopefully check it in to gonk-misc.
Blocks: 847592
Summary: Write a simple whole-system profiler for B2G → Write a simple whole-system CPU profiler for B2G
We also have a not-so-simple whole-system profiler for B2G, in the form of recompiling everything where we have source with a modified GCC so that the kernel can unwind its stacks, running perf(1), and converting the perf data into SPS/Cleopatra format so we can look at things with the convenient timeline display.

See bug 831611 comment #53, and 60.  Note that perf defaults to profiling based on a cycle counter, which doesn't advance when the CPU is asleep; adding "-e cpu-clock" uses some kind of interval timer instead, which is more convenient but seems to top out at 2.5 kHz on unagi.

This is not landed, and it's still an open question how and in what form that might happen, but my collection of forked repositories has been successfully used by people who are not me.

If we just want to know what threads are running when, rebuilding the world to allow user stack unwinding ins't necessary; just the scripts I wrote (run-perf.sh and perf-to-sps.py) and the perf binaries (host and target).  However, there's a kernel bug such that it doesn't have the user-mode PC when perf(1)ing on ARM, so you don't have frame pointers then the process/thread is all you have.
And even still, such a profiler only sees the Gecko processes, right?
(In reply to Justin Lebar [:jlebar] from comment #2)
> And even still, such a profiler only sees the Gecko processes, right?

`perf record -a` records *everything*.  More precisely, it attaches a sampler to each CPU, and whenever one fires, whatever was running on that CPU is sampled.  For example, here's me typing, complete with kernel threads, the `perf record` process itself, and even a few samples from an sh(1):

http://people.mozilla.com/~bgirard/cleopatra/#report=5ec1583fe16e12a60b3e2da49c4e3563a1d93e11
Wow, that's actually pretty cool.
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.