Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9879736rwd; Wed, 21 Jun 2023 13:06:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Uzui2kX0Kc6wBQQEvIySu/02UNSiM+Kux5q76mAjtrsPhr8Ea4sU/FrzmbPpgUI90Wgvr X-Received: by 2002:a05:6a20:4404:b0:121:a674:471 with SMTP id ce4-20020a056a20440400b00121a6740471mr13016053pzb.30.1687378010074; Wed, 21 Jun 2023 13:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687378010; cv=none; d=google.com; s=arc-20160816; b=rufChJ+CnokyN1AIwvBMAglhsybgWZqKrIPjj1jWVsJcuFrHrpcVC1JeSuWphJUOM+ 6EfDy5bk95hVXG7rvUV02spst8CAOPeDY7sWEH0/ojwoi+opAcqhjWUVOQaX02hVqiw1 Lr7fNaVQg60Dz/U6zAwAY4It4SCjEuPvV7Pa7zBypBcrjE4ghXTSJsjJQXlpwugcIjQM APUpXQIhQdKpXO3xFyWh2RM3yCOEwqX4TgTG65YyWbTKhvjWWnol5BnuVNjrACXFKgRl 6eZbRfyM292nUEs/1DjCWAdU7jYOpLKjiyC/w6e7IwKQRYiTA8P38z+V81eHGPZsfGqO kA7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=y6toF7rBgOobZWwzNn/wkMI+lBlT1PzkeUNueCz0uLY=; b=g6wpBCKZuNFUIzYe0+cpPm6eqbvRSTw9dWABTJzwsH8WCs/wxWEtp94JcXCqvAr4k7 dRpwoVYsODSi2z/hm/BImJ5MtZZJD724O80nA5E6tddsiNx8bO9qDAkVLlU0wLK8ND7B Ms6RBHtOY5mc+obxRqp/MkzOQBv0p1RH/3H017cDpdrQlgtIBeRgfAd3kQwypf4uiU/N 02S+ZIKjQYTM8j/taSvZqpnde8GF96BQ+ERI1RzSLuhfHciwPNF6WM72NiiSSDds2woH XBTli6TPH4hKIVw8VkeTABQXKwLu1drVjbffQkikQsGk39wVR9lOONCeJjVltOMpKuTz THgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BRxZv5Yb; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i28-20020a633c5c000000b005572aaee706si2677134pgn.689.2023.06.21.13.06.36; Wed, 21 Jun 2023 13:06:50 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BRxZv5Yb; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbjFUToq (ORCPT + 99 others); Wed, 21 Jun 2023 15:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjFUTop (ORCPT ); Wed, 21 Jun 2023 15:44:45 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4385D1733; Wed, 21 Jun 2023 12:44:44 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-668711086f4so3026796b3a.1; Wed, 21 Jun 2023 12:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687376684; x=1689968684; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=y6toF7rBgOobZWwzNn/wkMI+lBlT1PzkeUNueCz0uLY=; b=BRxZv5YbUO3mqeq5qnYxLw9p1M3Chql2NuBJIVn7S/h37+sCdQH2hvIf9uxu3GBKex RBFJ+U6Q4mVnwKcv9qpSuYIYRmrLl88/SyjZblDY40tyEWGkbBK+3bziACwCcUhwxEi8 JEr6w09TduzhVmaQY8w4V9B2Pwjn9IfsrhGew2f0mpprnU3dYWZmDf/aSCqgvwVyG9RR VKVJSCHHMcNLtWETYPzfyEjbeiCL3nGa6j+EkHxHMGRxSFFuML266+W5rxqxaQb0uoNX 11rN7GyFC5HuHTgQnBwxaFvFOEh1eVwaTZnxeVuE6Q73eYDhKWc73czoNshq5cqsB3AH a86w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687376684; x=1689968684; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y6toF7rBgOobZWwzNn/wkMI+lBlT1PzkeUNueCz0uLY=; b=OEtXtdV8fbkS0jrQ2jOKzJLlujNkZuiXoUB022Pe+avO1ysAMMcejJM5ymB4FS5kjg lB8wFP03WNz0Gabv9vpv/X6Zk09Leu8U8NhbHs+yBCZqw5oUHjDUAAGDRDH3ImbnDEy9 jHQ4kou8vEs/E3FUOQhu29VW9KguVjlaw9zGV/b+XrHV29IUCv8gk/AQVL7YLsXLr+MC 1PlSKM0S/KkN5uUiIQT13pMfvKJ87Y0pmjECDW1S71yrq/TnensFWOEcvHy9WsH4DMBo 6KCn17YRQkhtNiruHmwafRJ+f4UzwnCMZay/WIHA023nNKOkB18TFsq0efbT91/OQOAX jp9Q== X-Gm-Message-State: AC+VfDwgNNG74kB+fM/8OyHuHjAWWfUL0unSKef7aCtg8jWFIgoYWf3/ sWTKhl6dGK+mS5amqwlYbYI= X-Received: by 2002:a05:6a00:218e:b0:667:d0ff:6a0f with SMTP id h14-20020a056a00218e00b00667d0ff6a0fmr16310098pfi.5.1687376683591; Wed, 21 Jun 2023 12:44:43 -0700 (PDT) Received: from yoga ([2400:1f00:13:6258:556c:aad7:2240:7612]) by smtp.gmail.com with ESMTPSA id 17-20020aa79251000000b0063b6cccd5dfsm3257338pfp.195.2023.06.21.12.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 12:44:43 -0700 (PDT) Date: Thu, 22 Jun 2023 01:14:35 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] scripts: python: implement get or create stack function Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 The get_or_create_stack function is responsible for retrieving or creating a stack based on the provided frame and prefix. It first generates a key using the frame and prefix values. If the stack corresponding to the key is found in the stackMap, it is returned. Otherwise, a new stack is created by appending the prefix and frame to the stackTable's 'data' array. The key and the index of the newly created stack are added to the stackMap for future reference. Signed-off-by: Anup Sharma --- tools/perf/scripts/python/firefox-gecko-converter.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py index cdd7f901c13f..30fc542cfdeb 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -57,6 +57,18 @@ def convertPerfScriptProfile(profile): }, 'data': [], } + + stringTable = [] + + stackMap = dict() + def get_or_create_stack(frame, prefix): + key = f"{frame}" if prefix is None else f"{frame},{prefix}" + stack = stackMap.get(key) + if stack is None: + stack = len(stackTable['data']) + stackTable['data'].append([prefix, frame]) + stackMap[key] = stack + return stack def addSample(threadName, stackArray, time): nonlocal name -- 2.34.1