Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35962140rwd; Mon, 10 Jul 2023 15:43:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfeYdrd0lhzKBK7wlg3nSCg/EkV/IE671InJn3zrPop/PDPbFUgFLI5TTCzmcSgBZHlqec X-Received: by 2002:a17:906:74c8:b0:993:ed3c:dee2 with SMTP id z8-20020a17090674c800b00993ed3cdee2mr8761636ejl.5.1689029023186; Mon, 10 Jul 2023 15:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689029023; cv=none; d=google.com; s=arc-20160816; b=IMqxnIEsqfLQumCp+Exhj+Dve07V/GGOQtn85ck7Zzjaa85sQDoW3Uz3be2FnY9NOH WSykzWScJIbXetWLyrY1u2XrpeTc53uGcn24z7GNV/ecutCytsm9vLXN4HWK+h/5Tb56 zur+XKtHsjCXidatEp1H4VnjY0SOGSfDM5UwJoojcRtkz/XTrXMwnvLtpyxS3W1hVqAt TdlNUrn+Tqaf3cwck9/+919mmtrdUPOuw72ejCDZEBPcNv5eoNfsKly55cN674qKhWPD IHXVIpIgFHkwiMjuVSaPbJ+4onwtytZN8WX/trTS//C0QBjjeEeyJYaUT717jMYt8xsY IfiQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=noXk0R27HPx3THK3yfqnsU/gqkuv8yKrLuQKPLP+V2A=; fh=ySq3lQcDqZDk4DVIg5WDWmDtxewj8RCaiNhSFwRH11M=; b=PF0+R9P1eZxvJbeagwi4VoeU9/haQutObHBjpfEAVJeNexcmw/Oo0mrKWCX2fu97ul DqC1hECeF03Tl0J1R+grsWtfxW5TFvMoD6uqYNXTUsvBu1OeoqXZeA192rRCm1+wCd2W GNP0lkG4iMPVRWma13miMXyTNEf4jRBbXUpEEwqn0/R/B90yZiVeGU/ftF7IP9V7bs10 7Ey/06JEcXFwT1eU/Pb+CsM56mlGg/SksOkYpeYJR/uli95jKlfMvvV34KsAtWdN3ltA R7GJBXLopIO1utV/ob5E/vrSV4Wv7c7754h5hJSXynbjT7c+KyC6tLf5sv3MpyU61kf0 YshA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=nGu3r0sV; 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 s23-20020a170906961700b0098d5b116e6fsi600979ejx.856.2023.07.10.15.43.18; Mon, 10 Jul 2023 15:43:43 -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=nGu3r0sV; 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 S230073AbjGJWBV (ORCPT + 99 others); Mon, 10 Jul 2023 18:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbjGJWBT (ORCPT ); Mon, 10 Jul 2023 18:01:19 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 069EFDB; Mon, 10 Jul 2023 15:01:19 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b8ad907ba4so24823775ad.0; Mon, 10 Jul 2023 15:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689026478; x=1691618478; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=noXk0R27HPx3THK3yfqnsU/gqkuv8yKrLuQKPLP+V2A=; b=nGu3r0sV3DJyP0P2MeifuOet0MgQekGDmeWLcDPUE1xP4123fWOR4Cb5X5qMoYi3Am PcBNhepVVlV3wvm5HymMyCPiTc+i1w+fG4qUxaZcfa7g2ntLLJho10RCQ2B66YU94NwF U829Q13l3mRUxjw1fWICWNHT6nBbbou0yntiUCDqCkEjJ/EgiUTrU78dR/V4EfGg3Gbd 9UD4TOIS91gX6yY98aSeG607aDZ4zqZfIszzQNJZsjb2PD9FLGmHF9AKqF90A5vcXFoS t5Qx0j3/ACqCTHhNcR5J39c4/PFAGrq1kaJF5oIZd7cHKPOcng4ki0WAQiebBf9O1BZZ Xt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689026478; x=1691618478; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=noXk0R27HPx3THK3yfqnsU/gqkuv8yKrLuQKPLP+V2A=; b=Iv7hI8mxwa8QiVOap/6hT7p/W62bR4LInfN8pSs4iA82paQR0p0QWT3dqe6f1kjYa5 MxFamqK8u6TpbtUbFotAB3wu+gaKGFeXPUSfVTa5Uq9dgfiIxRwSzM0OJhod801zYNQb 0E/M+aRjmVt6n1C5wPZmFkjQD4Am8SJDJZ+7ajl5wHnbkTKgi9ht/aFo+Lv2uqTw40ba 6vJXjU271Ow7r7tsqa7yxHYhUBrMm1svtGMQJc3BvJCU2e6fHnS59zcyYL3x6Ho3QnJ1 jNxQ24rhAS/A6ikSVaUAzidq89EMuR8vULr1kHCUyrRARb8deHU8FlZ33l9buZP/tQdv Ws6Q== X-Gm-Message-State: ABy/qLZBydgj3D2BcX9jyxLZxU2vm/ljQ6k8A5wx38+3ZoEmdL2GXlXI hB23S/ntvqaOC4UY164AMf1XS9fMaSkND19s X-Received: by 2002:a17:903:482:b0:1b8:a2af:fe23 with SMTP id jj2-20020a170903048200b001b8a2affe23mr10920008plb.2.1689026478150; Mon, 10 Jul 2023 15:01:18 -0700 (PDT) Received: from yoga ([2400:1f00:13:76f2:d743:45e6:d02:e038]) by smtp.gmail.com with ESMTPSA id j13-20020a170902da8d00b001b3df3ae3f8sm349404plx.281.2023.07.10.15.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 15:01:17 -0700 (PDT) From: Anup Sharma X-Google-Original-From: Anup Sharma Date: Tue, 11 Jul 2023 03:31:10 +0530 To: Namhyung Kim Cc: Anup Sharma , 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 Subject: Re: [PATCH v2 4/7] scripts: python: implement get or create stack function Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, Jul 05, 2023 at 10:55:52PM -0700, Namhyung Kim wrote: > On Wed, Jul 5, 2023 at 12:48 PM Anup Sharma wrote: > > > > 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 | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py > > index e56864e78dc1..6f69c083d3ff 100644 > > --- a/tools/perf/scripts/python/firefox-gecko-converter.py > > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py > > @@ -65,6 +65,17 @@ def process_event(param_dict): > > }, > > '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) > > I'm confused about what the 'stack' is. The stack is a list of frames. > > + if stack is None: > > + stack = len(stackTable['data']) > > It seems like a kind of index for the stackTable's data. Yes, it is an index. > > + stackTable['data'].append([prefix, frame]) > > + stackMap[key] = stack > > + return stack > > So this function returns an index, right? Correct, it returns an index. This index allows to access or identify a specific stack within the table. > Thanks, > Namhyung > > > > > > def _addThreadSample(pid, tid, threadName, time_stamp, stack): > > thread = thread_map.get(tid) > > -- > > 2.34.1 > >