Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp129832rwp; Wed, 12 Jul 2023 10:42:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlE48RyG65eWNO9EiihcmTiwLGTlyRXejrKH1RXmM84n2xSNlLXpPyAwb/6PaS0PWuAuDZ+i X-Received: by 2002:a17:906:1b03:b0:992:9ea0:2317 with SMTP id o3-20020a1709061b0300b009929ea02317mr19914385ejg.61.1689183767881; Wed, 12 Jul 2023 10:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689183767; cv=none; d=google.com; s=arc-20160816; b=oDBesbehvvp2ZeY4QVowdFfYwwBSW77cWJ9mS43trWE8gDS0Mlh05Sd+4j4xmHist+ q3mLLhsig7KmZP12CFDMG86qYJoND+YUeS+x0pbBXwXKIhjr0ixCLB3VIWCwpO93NEuh 3FHf9pnNtAqEpr/UYhAiyEXPwMIQjy2RtGDPUjQ+QRIqfdy37WecQcngyQ6pjOCu9Dbl yV3qL1EgyBP9wthGyw2sh47G13m0K7/1QTS+iA82trOY7eJ13H0AFRPI2hWO13/4dp+3 LJ81Qb4KpQ72EYuR0z8SgoAfiRW1xoIu7WBaLNqQN92Q+8od+hqaNgUFMDk6CaQzeKy+ vFFQ== 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 :dkim-signature; bh=AqtCYATG8ChMapzp5kNLa9Py9zbnEsVcqTU7Ga9LoGc=; fh=r6t8ZIiaysjVIQ+d75wHhRrXERh1gbUWb6hp/nHvAjY=; b=ZYldO5UV9/KHLHi7H+grV4525XWsv0TKDOfYLr9ghqMT0189I0vGIP11tvsHCujcQk 2rK+wM8FSxW9vqTEtzlkmP3tKHKwB9RPmIGilH+Tb2J95pCU8IXTc20hiHhQuNV3PTVB PjHkbJ9zNF0TeD0mkpbepCetKrG/05bVpQWpduEf3qHCnjjDR3cW6TYVlb/I4DfvV7xR S+pc2w8A4jAZD9rp0lNURPBD1OdfhUe33wSRYDJozWLOSNsc5xpHMnlx3BX0UOlTUjaL 3yJ4MTZcyfSwjTWa29GvJ2/cepn3IRFFdJXhIrs7jfWz0Ky00zf01kzuuJYprrXssbOU gx6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OqdAti8O; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170906094d00b00992d262f9f7si5250453ejd.933.2023.07.12.10.42.23; Wed, 12 Jul 2023 10:42:47 -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=@google.com header.s=20221208 header.b=OqdAti8O; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjGLREN (ORCPT + 99 others); Wed, 12 Jul 2023 13:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232609AbjGLREL (ORCPT ); Wed, 12 Jul 2023 13:04:11 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0950C1BD6 for ; Wed, 12 Jul 2023 10:04:10 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-4036bd4fff1so13681cf.0 for ; Wed, 12 Jul 2023 10:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689181449; x=1691773449; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AqtCYATG8ChMapzp5kNLa9Py9zbnEsVcqTU7Ga9LoGc=; b=OqdAti8OKkViVwVuE8lSLXuosWAZC4YxyaEzBVjKFo6TVWyxahb0+Hswoyt1XV482L w8pxK2aWUUBMLj4T7NywMW3+OpubE1uliG+eQFEjzQaG7QRN5ky835S29FcwAb1EmI1R 6/afyR0w9CQSJqZyqvndjhAf0bKkxSE2SvMpHkGqk5kCCfDdtwo38tUKxCMyWj/kitw7 UA8WIl+e7xIjlqIOZho234gBXDEtuVYh4CKKHOMINX5G0LotYdDP5yqvVXXSrFXaqsyA fvbCwzAqPGDVL4GrHTSHm8+Wf+sMcvW27MR5zixM2vThLjHJBDhAsxgpRPlKtxyd90pX QcIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689181449; x=1691773449; 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=AqtCYATG8ChMapzp5kNLa9Py9zbnEsVcqTU7Ga9LoGc=; b=Z5VRijXePY3yq9o3fkxk9eTHrJJTFIpIBx3FaLGATq+cjj3OyUc2O/1JWfQcycWYrv 7U1/ivbBjfwKp3Ovfg7+tiC4CmHYIGFuV8kFD9f/XDB/YtIeZAOQxo4A2ay7FBx6+dS6 CFI7vOTnRQ2qj5r2hPgwfVvqe2X22eDGgHRkyDQnfTxhT3dUUtp4U/fQ2R0F7pPUW6GE 3fzFTIXM9F2fDchmCp0GSt+eZFtW64h/QHkgkPzyShNP2+9yqbyzkWGQxJtQDz638n0v qk3RInfNr32WOvEBcK8Vd0yPMHzXTX4gaZsmRgICntCljzpwOsAPyBPG25JINA2ho0L3 0xcQ== X-Gm-Message-State: ABy/qLarK+wvUhnDyLi7db8FuJmsb7daARdlOSezy7w2zivVpEQI3rmI 0w987lG8YfT2jX/rKce/zMYSX0t2dp7jGkW4gf+HUkiHFtd0kuZx8Io= X-Received: by 2002:a05:622a:1805:b0:3ef:3361:75d5 with SMTP id t5-20020a05622a180500b003ef336175d5mr281741qtc.11.1689181449011; Wed, 12 Jul 2023 10:04:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ian Rogers Date: Wed, 12 Jul 2023 10:03:57 -0700 Message-ID: Subject: Re: [PATCH v3 2/6] scripts: python: Extact necessary information from process event To: Anup Sharma Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 12, 2023 at 10:01=E2=80=AFAM Ian Rogers wr= ote: > > On Mon, Jul 10, 2023 at 4:10=E2=80=AFPM Anup Sharma wrote: > > > > The script takes in a sample event dictionary(param_dict) and retrieves > > relevant data such as time stamp, PID, TID, thread name. Also start tim= e > > is defined. > > > > Signed-off-by: Anup Sharma > > --- > > .../perf/scripts/python/firefox-gecko-converter.py | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/too= ls/perf/scripts/python/firefox-gecko-converter.py > > index 5b342641925c..765f1775cee5 100644 > > --- a/tools/perf/scripts/python/firefox-gecko-converter.py > > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py > > @@ -21,8 +21,19 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ > > from perf_trace_context import * > > from Core import * > > > > It'd be nice to have a comment here, perhaps: > # The time stamp from the first of the time ordered events. > > > +start_time =3D None > > + > > def trace_end(): > > pass > > > > def process_event(param_dict): > > - pass > > + global start_time > > + # Extract relevant information from the event parameters. The e= vent parameters > > + # are in a dictionary: > > + time_stamp =3D (param_dict['sample']['time'] // 1000) / 1000 > > + pid =3D param_dict['sample']['pid'] > > + tid =3D param_dict['sample']['tid'] > > + thread_name =3D param_dict['comm'] > > + > > + # Assume that start time is the time of the first event. > > + start_time =3D time_stamp if not start_time else start_time > > I appreciate that this is one line, but it takes some getting your > head around that start_time is being assigned to itself in the common > case. I think this would be more readable as: > > if not start_time: > start_time =3D time_stamp I believe the events are guaranteed time ordered in perf script. The ordered_event logic handles this, but I likely haven't got a full grasp on all the corners of it. You can always assert the behavior (comments with guarantees :-) ): assert start_time <=3D time_stamp, "Events aren't time ordered" Thanks, Ian > Thanks, > Ian > > > -- > > 2.34.1 > >