Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30031445rwd; Wed, 5 Jul 2023 23:10:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFnHMPgszECcb6Ds7k/ZIPhd4FSAwshAgx9KLGMsrzYuM32/po72TSGFPyWGBxHpRxMZWN X-Received: by 2002:a9d:6a84:0:b0:6b8:dc53:9efd with SMTP id l4-20020a9d6a84000000b006b8dc539efdmr1039571otq.3.1688623834509; Wed, 05 Jul 2023 23:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688623834; cv=none; d=google.com; s=arc-20160816; b=O9FqxkjjzBtkkb5HgO1B2tLI/sMWz3p7EvGNH9zlTiCRj7Ah0lOCm3u2T4V7MkxWoX oQSk4GAAFwIjBPJOqKNh4LyTol9Ep01YavOCt/Lj4HNQzAS+x2AFxsCNkapwkRrZvMZq q+aspB95/B1HehW5DsA9yf/f3UNWZLqxZEsuTPzJDx+v2NgXCqgkwHfNsyuyKBHxv5oe AGMM1/R10QE6s1FRGK+332k4tDIaiK19gWGWn/AHmW08St//9HMxJTqrNf9xIIPPliZE gPtA327370ZUSFQDJeAyHsNS8d/ZYAhzvvJs9UL6GZ646Gek2toda3k3cqlrvNYmnPll DfZg== 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=QxGrnvhApyAUxtVUCaELuHuH2RWgvQ8c+pfG2mGiyUs=; fh=M2Wb7ZmVzwfcnR5Fu72cJwECOoQLLjUEn+j0vvab/TY=; b=yEOVWR5xZAq0YptTk71vzjSxckVjzmdCRQKdkVE6mjWthjPymD8IjKFkt0Qrk+vr4g eZejIHlb4WdnCSS0pUYo2VKMTDMunpNV63aWSy1I2XxDQ1ryailvI5XZdYNWe9CFsL89 KccKVNeKr2y0bK7svJIl2LmM9NfapYs6z42iwyZbuMSfep/M0yxQ03Y3iBoOqqffB/BK RSTVFXRVEDA4Skwi/u2WvFIEw30K8vGTLF+oFdfDEEwldMZkbSKS4/+YJ/yY/T8ed44W rIrkZvHhl0aH1bCh+t9D9OTQPI8jkIiPQh192/I3ApO0g3XNfnKEnCOgwwIN5CnkVq/z UEcQ== 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 s7-20020a635247000000b0055acbe61853si783936pgl.430.2023.07.05.23.10.20; Wed, 05 Jul 2023 23:10:34 -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 S233016AbjGFF4M convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Jul 2023 01:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjGFF4K (ORCPT ); Thu, 6 Jul 2023 01:56:10 -0400 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FD391732; Wed, 5 Jul 2023 22:56:06 -0700 (PDT) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so3095835e9.3; Wed, 05 Jul 2023 22:56:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688622964; x=1691214964; 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=0TqatMR75Z/5NsmIWgZ6TKjuBUALAv5Ok5UmFVZ5PDI=; b=gc1yXiK/rVVKRAY1y1Bq/NaIAfP8k2zh4nPpbTZX0hLxithSkZFlmpZ9iXVWkXhfwg NfVxJS6Z4rYeXBR6C5+gyv4ToAtXAYkpXFTqUz6q0z+Nhx8Sdm+MhCdEDdqEQQtFGGHn zuMC/frJnq6RMligi7Hh711LcBESwVQuf8iL3pRLSpv09yk2n3HcWKQhqZkbes+7baeX s514t9hQeMVxhkEn38QaTv95qgRYHAur0pTgNuQxaLiVXreTKyuVArf6Ap0VUazExKyb v75/xXfxvaKc0mGtFw6aEZRh5mHIXB3btXp+pyDKVdCFXgP6VTo4h9/8bIQD4jKoGwXe nStQ== X-Gm-Message-State: ABy/qLYLa+Q6+2ZiwiBlq9X1qwdJUenegWqo3VP+L3W9YcIvkWmdmaWh 1Q2lN/Ebj+d2bkydmbz/gPubvnSUMHI9wFN63wA= X-Received: by 2002:a7b:c3cc:0:b0:3fb:c225:a75e with SMTP id t12-20020a7bc3cc000000b003fbc225a75emr479061wmj.24.1688622964426; Wed, 05 Jul 2023 22:56:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Namhyung Kim Date: Wed, 5 Jul 2023 22:55:52 -0700 Message-ID: Subject: Re: [PATCH v2 4/7] scripts: python: implement get or create stack 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_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. > + if stack is None: > + stack = len(stackTable['data']) It seems like a kind of index for the stackTable's data. > + stackTable['data'].append([prefix, frame]) > + stackMap[key] = stack > + return stack So this function returns an index, right? Thanks, Namhyung > > def _addThreadSample(pid, tid, threadName, time_stamp, stack): > thread = thread_map.get(tid) > -- > 2.34.1 >