Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30043019rwd; Wed, 5 Jul 2023 23:24:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiKFs1egcVn9PwsbgUiZDO9BThi2HZtcZ4ULuuPfU+LIROcCatuhPu4v6P8ewVS2omBz9A X-Received: by 2002:a17:902:7798:b0:1b5:5a5f:369b with SMTP id o24-20020a170902779800b001b55a5f369bmr615015pll.65.1688624666982; Wed, 05 Jul 2023 23:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688624666; cv=none; d=google.com; s=arc-20160816; b=Bkn3Lx2tjWEwI8xqGiiV1bWGTdmWJoFscmn41UTbOKA2AX3qQpmB38YWL+r7BY9Ob5 O7cxkNgSksmDlsYGOG6ik08q5KAb2ilcMKyJYF9+hp7s1zi4rqWaskYA7Y3N7W9axQQT +hkPQfb3ooD8AXQtqWGq4YpFvMmn2jtEFcf2GseUtJC9TzPAKTXuWI6LsJkzK0u+8L4a RKk6VN5r9hIVY5aSCoiUjL/LUMpVHXb7YsXhbZqVwmexLZFGBM/LpUuXNYnT21AhGTi8 +jUeZ+XS/JYIzWg+sDpm3wOGrM/QIpLiwyCcMnSSxfzpo5xlp4067EPd38qW528aBn4X fSaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=p86w90/ZmNVOCWpK0A9uNTgA6BjQ/agmVZXofavpFrA=; fh=M2Wb7ZmVzwfcnR5Fu72cJwECOoQLLjUEn+j0vvab/TY=; b=p8zcyUW4SWx1D31Z1uhBM8JNKyzCYEWea8SHInzdlodeIDswwKBs9iSEPo3q+fdk/q tpAhoBN8kTI2zBxd7gpoF1Y5kVsWWLKPxQBY/xn1HNc58vBLsKvgt27aglnF21BoFx3S vFrcb4py/dxF9yU7RqaxfmfmMeNQ1u4iFKXYwRnkyaPBHguIzdzMDDwQRzPRk7+qtS04 tY0FX272xRWQAp/XNs07JLGyURMeuM7YvwRfV23XIELItcB3qweaOEOXSCz2TKEfviY9 r2SzRgz2qWi99tv8WBcQx4B4D2+NmwexRQsEewlIL2fidUR7Uqhcp1JaM4sWlRNE6HQn tR4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a1709027c9600b001b02bd00c67si660560pll.324.2023.07.05.23.24.11; Wed, 05 Jul 2023 23:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233505AbjGFGJB convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Jul 2023 02:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbjGFGIs (ORCPT ); Thu, 6 Jul 2023 02:08:48 -0400 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 896FA1FD4; Wed, 5 Jul 2023 23:07:12 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-4fb9fd28025so293965e87.2; Wed, 05 Jul 2023 23:07:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688623631; x=1691215631; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=stDwC3ubWk7UbpFGcin9q0Sf3tcXcBNG3Nx064U9y4M=; b=Vw3a1VWpJV59uqZCBdlQFMYQgbLG2dGlyvzWXfvONYpOHQuLZt1X3jkLpyUq0H7LUN dxE5E1PfgFxsMT98DMk2I9ik46aJ5Ol5Y+W5JvnMXLBlao3KNTMWBVlR3XEIcokcgR4l gtbuUbp1zyjLMsz4kVUVVyRXIQKdgEQ+F+XptXowoDw9XnYQv8+1sjdIPbIFXY7fdliJ mqY4s3ojc2w6PEGWUaAn4fXs732DjGqAAgVSm+LnbCZgqhHZCIMnzODAf/akEr20fF2l c0CqPey8//z5tTMY4a1VgIi7g2FhxUr3L6n0qo+Ey9/vLwgnbTGe+kYqQp+zPR1pqyKh n0cg== X-Gm-Message-State: ABy/qLZ40xSBDRApmgk5a6Vc/27YQueENcbReqh2rZEnsmWmRELV4CPd 97PLhHVoG0Shgt337q43GxZgEGdGMogOiA6dTck= X-Received: by 2002:a05:6512:1584:b0:4fb:8359:e8c with SMTP id bp4-20020a056512158400b004fb83590e8cmr866572lfb.34.1688623630488; Wed, 05 Jul 2023 23:07:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Namhyung Kim Date: Wed, 5 Jul 2023 23:06:58 -0700 Message-ID: Subject: Re: [PATCH v2 5/7] scripts: python: implement get or create frame function To: Anup Sharma Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 5, 2023 at 12:48 PM Anup Sharma 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 > --- > .../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 >