From: Andi Kleen <andi@firstfloor.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>,
Stephane Eranian <eranian@google.com>,
Minchan Kim <minchan@kernel.org>
Subject: Re: [RFC/PATCH v2] perf data: Add stat subcommand to show sample event stat
Date: Thu, 14 May 2015 21:32:05 +0200 [thread overview]
Message-ID: <20150514193205.GA2366@two.firstfloor.org> (raw)
In-Reply-To: <20150513120522.GA28136@danjae.kornet>
On Wed, May 13, 2015 at 09:05:22PM +0900, Namhyung Kim wrote:
> Hi Andi,
>
> On Mon, May 11, 2015 at 05:44:05PM +0200, Andi Kleen wrote:
> > > The sampling ratio was useful for me to determine how often the event
> > > was sampled - in this case the cpu cycles event was only sampled at 12%
> >
> > That's dangerous to determine without a plot. It could be that it was bimodal:
> > 100% busy and then idle. You may want to add something like the spark
> > plots I submitted for stat some time ago.
>
> Right, we cannot know the exact situation from a single number. But
> it was okay for me just to see overall status from the number. This
> is what we cannot know from the output of 'perf report' easily, so I'd
> like to add this info in some way.
>
> Anyway, I wrote a script to plot the number of samples and periods
> using python's matplotlib package. Maybe we can add it to the script
> database.
Looks good. Yes it would be useful to have in the database.
-Andi
>
> Thanks,
> Namhyung
>
>
> /* sample-chart.py */
> import os
> import sys
> import numpy as np
> import matplotlib.pyplot as plt
>
> sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
>
> from perf_trace_context import *
> from EventClass import *
>
> events = {}
> mode = None # 'cpu' or 'task'
> nr_events = 0
> first_time = 0
> last_time = 0
>
> def trace_begin():
> pass
>
> def trace_end():
> xcnt = last_time - first_time + 1
> xpos = np.arange(xcnt)
> times = np.arange(first_time, last_time + 1)
>
> fig, plt_array = plt.subplots(nrows = nr_events, ncols = 2)
> fig.suptitle("Event stat", fontsize=20)
>
> n = 0
> for e in events:
> p1 = plt_array[n][0]
> p2 = plt_array[n][1]
> for k in events[e]: # key = cpu or tid
> ev_stats = events[e][k]
>
> samples = np.zeros(xcnt)
> periods = np.zeros(xcnt)
> for t in ev_stats:
> samples[t - first_time] = ev_stats[t][0]
> periods[t - first_time] = ev_stats[t][1]
>
> key = "%s %d" % (mode, k)
>
> p1.plot(times, samples, 'o', linewidth=2, label=key)
> p2.plot(times, periods, '-', linewidth=2, label=key)
>
> expect = 400 * np.ones(xcnt)
> p1.plot(times, expect, '--')
>
> p1.set_title("Number of samples in '%s'" % e)
> p1.legend()
> p2.set_title("Event values in '%s'" % e)
> p2.legend()
> n += 1
>
> plt.show()
>
> def process_event(param_dict):
> evt = param_dict["ev_name"]
> cpu = param_dict["sample"]["cpu"]
> tid = param_dict["sample"]["tid"]
> time = param_dict["sample"]["time"] / 100000000 # 100 ms
> val = param_dict["sample"]["period"]
>
> if evt not in events:
> global nr_events
> nr_events += 1
> events[evt] = {}
>
> global mode
> if mode is None:
> if cpu >= 10000000:
> mode = 'task'
> else:
> mode = 'cpu'
>
> key = cpu if mode == 'cpu' else tid
> if key not in events[evt]:
> events[evt][key] = {}
>
> global first_time, last_time
> if first_time == 0 or first_time > time:
> first_time = time
> if last_time < time:
> last_time = time
>
> ev_stat = events[evt][key]
> if time not in ev_stat:
> ev_stat[time] = [0, 0] # (nr_sample, period)
> ev_stat[time][0] += 1
> ev_stat[time][1] += val
>
> def trace_unhandled(event_name, context, event_fields_dict):
> pass
>
--
ak@linux.intel.com -- Speaking for myself only.
prev parent reply other threads:[~2015-05-14 19:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 15:25 [RFC/PATCH v2] perf data: Add stat subcommand to show sample event stat Namhyung Kim
2015-05-11 15:44 ` Andi Kleen
2015-05-13 12:05 ` Namhyung Kim
2015-05-14 19:32 ` Andi Kleen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150514193205.GA2366@two.firstfloor.org \
--to=andi@firstfloor.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.