All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Sharma <anupnewsmail@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Anup Sharma <anupnewsmail@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/6] scripts: python: Extact necessary information from process event
Date: Mon, 17 Jul 2023 21:01:53 +0530	[thread overview]
Message-ID: <ZLVe6Xz1dnFEnaG4@yoga> (raw)
In-Reply-To: <CAP-5=fW0DT+JkU07K8brv2O_T6=hTM3SQMoji0o2rnsF6w+Y_Q@mail.gmail.com>

On Wed, Jul 12, 2023 at 10:03:57AM -0700, Ian Rogers wrote:
> On Wed, Jul 12, 2023 at 10:01 AM Ian Rogers <irogers@google.com> wrote:
> >
> > On Mon, Jul 10, 2023 at 4:10 PM Anup Sharma <anupnewsmail@gmail.com> wrote:
> > >
> > > The script takes in a sample event dictionary(param_dict) and retrieves
> > > relevant data such as time stamp, PID, TID, thread name. Also start time
> > > is defined.
> > >
> > > Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> > > ---
> > >  .../perf/scripts/python/firefox-gecko-converter.py  | 13 ++++++++++++-
> > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
> > > index 5b342641925c..765f1775cee5 100644
> > > --- a/tools/perf/scripts/python/firefox-gecko-converter.py
> > > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py
> > > @@ -21,8 +21,19 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> > >  from perf_trace_context import *
> > >  from Core import *
> > >
> >
> > It'd be nice to have a comment here, perhaps:
> > # The time stamp from the first of the time ordered events.
> >

Sure. I will add it.

> > > +start_time = None
> > > +
> > >  def trace_end():
> > >         pass
> > >
> > >  def process_event(param_dict):
> > > -       pass
> > > +       global start_time
> > > +       # Extract relevant information from the event parameters. The event parameters
> > > +       # are in a dictionary:
> > > +       time_stamp = (param_dict['sample']['time'] // 1000) / 1000
> > > +       pid = param_dict['sample']['pid']
> > > +       tid = param_dict['sample']['tid']
> > > +       thread_name = param_dict['comm']
> > > +
> > > +       # Assume that start time is the time of the first event.
> > > +       start_time = time_stamp if not start_time else start_time
> >
> > I appreciate that this is one line, but it takes some getting your
> > head around that start_time is being assigned to itself in the common
> > case. I think this would be more readable as:
> >
> > if not start_time:
> >   start_time = time_stamp

Sure. I will change it.

> I believe the events are guaranteed time ordered in perf script. The
> ordered_event logic handles this, but I likely haven't got a full
> grasp on all the corners of it. You can always assert the behavior
> (comments with guarantees :-) ):
> 
> assert start_time <= time_stamp, "Events aren't time ordered"

I dont think assert is usefull here as start_time will be initialized
and assigned only once for all the process event triggers. So, the
significance of assert is not clear to me.

> Thanks,
> Ian
> 
> > Thanks,
> > Ian
> >
> > > --
> > > 2.34.1
> > >

  reply	other threads:[~2023-07-17 15:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 23:08 [PATCH v3 0/6] Add support for Firefox's gecko profile format Anup Sharma
2023-07-10 23:09 ` [PATCH v3 1/6] scripts: python: Add initial script file with imports Anup Sharma
2023-07-12 16:50   ` Ian Rogers
2023-07-17 15:20     ` Anup Sharma
2023-07-10 23:10 ` [PATCH v3 2/6] scripts: python: Extact necessary information from process event Anup Sharma
2023-07-12 17:01   ` Ian Rogers
2023-07-12 17:03     ` Ian Rogers
2023-07-17 15:31       ` Anup Sharma [this message]
2023-07-10 23:13 ` [PATCH v3 3/6] scripts: python: thread sample processing to create thread with schemas Anup Sharma
2023-07-12 17:25   ` Ian Rogers
2023-07-17 15:43     ` Anup Sharma
2023-07-10 23:13 ` [PATCH v3 4/6] scripts: python: Add trace end processing and JSON output Anup Sharma
2023-07-12 17:28   ` Ian Rogers
2023-07-14  2:31     ` Namhyung Kim
2023-07-17 15:53       ` Anup Sharma
2023-07-10 23:14 ` [PATCH v3 5/6] scripts: python: Implement add sample function and return finish Anup Sharma
2023-07-12 17:35   ` Ian Rogers
2023-07-17 15:59     ` Anup Sharma
2023-07-10 23:15 ` [PATCH v3 6/6] scripts: python: implement get or create frame and stack function Anup Sharma
2023-07-12 17:44   ` Ian Rogers
2023-07-17 16:12     ` Anup Sharma
2023-07-14 21:36 ` [PATCH v3 0/6] Add support for Firefox's gecko profile format Anup Sharma

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=ZLVe6Xz1dnFEnaG4@yoga \
    --to=anupnewsmail@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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.