From: Anup Sharma <anupnewsmail@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
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>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/7] scripts: python: implement get or create frame function
Date: Tue, 11 Jul 2023 04:12:57 +0530 [thread overview]
Message-ID: <ZKyJcbX89y5ziqNi@yoga> (raw)
In-Reply-To: <CAM9d7ciZcO_kVwRhOoz0xt-hdguoTHUd8RPSpSOwiCFOTbYNKw@mail.gmail.com>
On Wed, Jul 05, 2023 at 11:06:58PM -0700, Namhyung Kim wrote:
> On Wed, Jul 5, 2023 at 12:48 PM Anup Sharma <anupnewsmail@gmail.com> wrote:
> >
> > The get_or_create_frame function is responsible for retrieving or
> > creating a frame based on the provided frameString. If the frame
> > corresponding to the frameString is found in the frameMap, it is
> > returned. Otherwise, a new frame is created by appending relevant
> > information to the frameTable's 'data' array and adding the
> > frameString to the stringTable.
> >
> > The index of the newly created frame is added to the frameMap.
> >
> > Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> > ---
> > .../scripts/python/firefox-gecko-converter.py | 33 +++++++++++++++++++
> > 1 file changed, 33 insertions(+)
> >
> > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
> > index 6f69c083d3ff..d5b9fb16e520 100644
> > --- a/tools/perf/scripts/python/firefox-gecko-converter.py
> > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py
> > @@ -77,6 +77,39 @@ def process_event(param_dict):
> > stackMap[key] = stack
> > return stack
> >
> > + frameMap = dict()
> > + def get_or_create_frame(frameString):
> > + frame = frameMap.get(frameString)
> > + if frame is None:
> > + frame = len(frameTable['data'])
> > + location = len(stringTable)
> > + stringTable.append(frameString)
>
> Looks like it just always appending a new string.
> Any deduplication work later?
Although this initially came to my mind and almost all stack frames
seem to be similar for a repeated call, but I am not sure if we can dedup
because some frames do differ as the call stack progresses. For example,
a process exits a function and then calls another function, resulting in
most of the stack frames being the same but the last one being different.
> > + category = KERNEL_CATEGORY_INDEX if frameString.find('kallsyms') != -1 \
> > + or frameString.find('/vmlinux') != -1 \
> > + or frameString.endswith('.ko)') \
> > + else USER_CATEGORY_INDEX
>
> I think you can use param_dict['sample']['cpumode'].
> Please see include/uapi/linux/perf_event.h for cpumode
> values.
I am actively working on incorporating the use of param_dict
['sample']['cpumode'] to determine the category in the
upcoming v4 update. I saw in param_dict['sample']['cpumode']
values exist as 1 and 2. Can you point me to exact line in
include/uapi/linux/perf_event.h . I am not able to find it.
> > + implementation = None
> > + optimizations = None
> > + line = None
> > + relevantForJS = False
> > + subcategory = None
> > + innerWindowID = 0
> > + column = None
> > +
> > + frameTable['data'].append([
> > + location,
> > + relevantForJS,
> > + innerWindowID,
> > + implementation,
> > + optimizations,
> > + line,
> > + column,
> > + category,
> > + subcategory,
> > + ])
> > + frameMap[frameString] = frame
>
> I think it'd be better if you define the frameTable in this
> commit.
Certainly, my apologies for the disorder.
> Thanks,
> Namhyung
>
>
> > + return frame
> > +
> > def _addThreadSample(pid, tid, threadName, time_stamp, stack):
> > thread = thread_map.get(tid)
> > if not thread:
> > --
> > 2.34.1
> >
next prev parent reply other threads:[~2023-07-10 22:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 19:40 [PATCH v2 0/7] Add support for Firefox's gecko profile format Anup Sharma
2023-07-05 19:42 ` [PATCH v2 1/7] scripts: python: Extact necessary information from process event Anup Sharma
2023-07-06 5:35 ` Namhyung Kim
2023-07-07 21:12 ` Anup Sharma
2023-07-05 19:44 ` [PATCH v2 2/7] scripts: python: Introduce thread sample processing to create thread Anup Sharma
2023-07-06 5:42 ` Namhyung Kim
2023-07-10 21:51 ` Anup Sharma
2023-07-05 19:47 ` [PATCH v2 3/7] scripts: python: create threads with schemas Anup Sharma
2023-07-06 5:46 ` Namhyung Kim
2023-07-10 21:54 ` Anup Sharma
2023-07-05 19:48 ` [PATCH v2 4/7] scripts: python: implement get or create stack function Anup Sharma
2023-07-06 5:55 ` Namhyung Kim
2023-07-10 22:01 ` Anup Sharma
2023-07-05 19:48 ` [PATCH v2 5/7] scripts: python: implement get or create frame function Anup Sharma
2023-07-06 6:06 ` Namhyung Kim
2023-07-10 22:42 ` Anup Sharma [this message]
2023-07-05 19:49 ` [PATCH v2 6/7] scripts: python: implement add sample function and return finish Anup Sharma
2023-07-05 19:49 ` [PATCH v2 7/7] scripts: python: Add trace end processing and JSON output 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=ZKyJcbX89y5ziqNi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).