Skip to content

Commit

Permalink
cli: add 'perf callstack'
Browse files Browse the repository at this point in the history
Use:

  perf callstack tracepoint

to list frequent callstacks for a tracepoint (from 'perf list')
  • Loading branch information
avikivity committed Jul 28, 2013
1 parent f44d739 commit 219dcfd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions console/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ register_command('perf', {
java.lang.Thread.sleep(1000)
}
},
callstack: function(args) {
var pkg = Packages.com.cloudius.trace
var tpname = args[0]
var tp = new pkg.Tracepoint(tpname)
var traces = pkg.Callstack.collect(tp, 10, 20, 5000)
printf('%10s %s\n', 'freq', 'callstack')
for (var i in traces) {
var tr = traces[i]
printf('%10.0f ', traces[i].getHits())
var pc = traces[i].getProgramCounters()
for (var j in pc) {
printf(' 0x%x', jlong(pc[j]))
}
printf('\n')
}
},
subcommands: {
list: {
invoke: function(args) { this.parent.list(args) },
Expand All @@ -94,6 +110,10 @@ register_command('perf', {
invoke: function(args) { this.parent.stat(args) },
usage: 'stat [[tag=]tracepoint]...',
},
callstack: {
invoke: function(args) { this.parent.callstack(args) },
usage: 'callstack tracepoint',
},
},
init: function() {
for (var k in this.subcommands) {
Expand Down

4 comments on commit 219dcfd

@problame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this functionality be used to create both on- and off-cpu flame graphs ( see http://www.brendangregg.com/blog/2015-02-26/linux-perf-off-cpu-flame-graph.html ) ?

We are debuggin MySQL CPU scalability problems on OSv (both upstream and our research fork), and we want to find out where MySQL spends its time... cc @nyh

@wkozaczuk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some information in this thread might help you - https://groups.google.com/forum/#!searchin/osv-dev/flame$20graphs%7Csort:date/osv-dev/vaMts9ew3GU/HP6WuaLEAwAJ. @tgrabiec may have even better info. I would actually reply to this post in google group to get best feedback.

If you end up writing some scripts please do not hesitate to contribute back.

@tgrabiec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@problame Checkout our tracing guide on the wiki. CPU sampling (on-cpu) is described here:
https://github.com/cloudius-systems/osv/wiki/Trace-analysis-using-trace.py#cpu-sampler

For off-cpu analysis you can look at the wait-profile:
https://github.com/cloudius-systems/osv/wiki/Trace-analysis-using-trace.py#wait-profile

@wkozaczuk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@problame Regarding your MySQL scalability problem it might be related to this issue - #450 and this commit b5eadc3 which was reverted due to some deadlock - 697943f. @nyh may have more information.

Please sign in to comment.