All users were logged out of Bugzilla on October 13th, 2018

Write a simple whole-system CPU profiler for B2G

RESOLVED WONTFIX

Status

RESOLVED WONTFIX
6 years ago
8 months ago

People

(Reporter: justin.lebar+bug, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
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.
(Reporter)

Updated

6 years ago
Blocks: 847592
(Reporter)

Updated

6 years ago
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.
(Reporter)

Comment 2

6 years ago
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
(Reporter)

Comment 4

6 years ago
Wow, that's actually pretty cool.

Comment 6

8 months ago
Firefox OS is not being worked on
Status: NEW → RESOLVED
Last Resolved: 8 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.