Messages in this thread | | | From | Namhyung Kim <> | Date | Wed, 5 Jul 2023 23:06:58 -0700 | Subject | Re: [PATCH v2 5/7] scripts: python: implement get or create frame function |
| |
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?
> + 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.
> + 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.
Thanks, Namhyung
> + return frame > + > def _addThreadSample(pid, tid, threadName, time_stamp, stack): > thread = thread_map.get(tid) > if not thread: > -- > 2.34.1 >
| |