Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp26206ybk; Fri, 8 May 2020 17:27:03 -0700 (PDT) X-Google-Smtp-Source: APiQypJXPTt5shAQtQiQzXoa6fomvyiZAbVUdnDKrtptvSCqbMfFXiilWD4Yharel5xjFpCRfP9n X-Received: by 2002:a17:906:2511:: with SMTP id i17mr4226474ejb.165.1588984023005; Fri, 08 May 2020 17:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588984022; cv=none; d=google.com; s=arc-20160816; b=e7fn5Gr/Nyq5FsSTSI1xfdDyxbgNbExVsqafKN4fcL0Fig/F5LNfP/sGnZE9jsoMBa z3N26nyLuh5990VL655sqPVMdtDHIj00DDgmG5Szpr7tIx22OOkcuFKA9oGDOl/YwEJf 9SE0DMmNBDy6gFNwUXl1Zh/pmgUbEGPHIPGejTTd2GWhkWFC1xpQbSEY3/fLl9JX3l7/ DTv9qIWK56G9rff/Vqubuu13gJW3FT1gGrwIOeU/d5EDvCc7usTj9x4dIjNMfk53AMex D2cIpEpiFFd54QyxNVzY5r+jLbBS0HXYoBDLJ5E9PPhakjNYz/XB5zy/7AR1nyTE5mD2 NscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=GUMDi8uQAlk4RGaDvyOzS7yJVwWHFnsT7vUDb3ZnHYs=; b=peZ7cVlgrowipxEvfZYXclwOQ5/whn9BqV7cR1grhEEWibm4Sh+YgYoP3uH2L9KSDS P0jDVdRliPfUrVWAgC3qV5CrOy68s7H9uCAEAda8mwWmZQylMd7k4XIsdfNc28pf2ZcP RQubJDCT8u2V1CfaHYDTKMBFUeN6VJt/UjVb0ZxpFYFnJAel+lxr0+AyBK4eyoS14tTi lAQcrtZ2XTzE+LtMwuuSIgCysu7PYvLGWWZ1q2FpHF9JWVMu8EJnA+LM8wIfOqnch25Q puJZu9KG6HHzrUo7Vz7tDpDU0T3yAZCW7oLDXwEgGIYJVJycNivN/KEn7ehABCVCmuTl YvAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si1795861edb.529.2020.05.08.17.26.38; Fri, 08 May 2020 17:27:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728354AbgEIAZU (ORCPT + 99 others); Fri, 8 May 2020 20:25:20 -0400 Received: from mga18.intel.com ([134.134.136.126]:21538 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727959AbgEIAZU (ORCPT ); Fri, 8 May 2020 20:25:20 -0400 IronPort-SDR: pIo6F0/8O7TC2UXmiMHEksOej2ZCyC8bMh/SQpPqVqCot+CTTOOAmHk4vLT0ESPUil4bNWQTO1 v2Ryrah2CXcw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 17:25:19 -0700 IronPort-SDR: kp/Bvufejq8QaWyJR4D2rYpIQqVsAZcRWvpWTSQV2Ju9IakfrwneT2vv3QgUINgRL/7grVRuo7 RISbptYjt02w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,369,1583222400"; d="scan'208";a="370671781" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.21]) by fmsmga001.fm.intel.com with ESMTP; 08 May 2020 17:25:18 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id A22B6301C4C; Fri, 8 May 2020 17:25:18 -0700 (PDT) Date: Fri, 8 May 2020 17:25:18 -0700 From: Andi Kleen To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian Subject: Re: [RFC PATCH v3 12/14] perf metricgroup: order event groups by size Message-ID: <20200509002518.GF3538@tassilo.jf.intel.com> References: <20200508053629.210324-1-irogers@google.com> <20200508053629.210324-13-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200508053629.210324-13-irogers@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 07, 2020 at 10:36:27PM -0700, Ian Rogers wrote: > When adding event groups to the group list, insert them in size order. > This performs an insertion sort on the group list. By placing the > largest groups at the front of the group list it is possible to see if a > larger group contains the same events as a later group. This can make > the later group redundant - it can reuse the events from the large group. > A later patch will add this sharing. I'm not sure if size is that great an heuristic. The dedup algorithm should work in any case even if you don't order by size, right? I suppose in theory some kind of topological sort would be better. -Andi > > Signed-off-by: Ian Rogers > --- > tools/perf/util/metricgroup.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index 2a6456fa178b..69fbff47089f 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -520,7 +520,21 @@ static int __metricgroup__add_metric(struct list_head *group_list, > return -EINVAL; > } > > - list_add_tail(&eg->nd, group_list); > + if (list_empty(group_list)) > + list_add(&eg->nd, group_list); > + else { > + struct list_head *pos; > + > + /* Place the largest groups at the front. */ > + list_for_each_prev(pos, group_list) { > + struct egroup *old = list_entry(pos, struct egroup, nd); > + > + if (hashmap__size(&eg->pctx.ids) <= > + hashmap__size(&old->pctx.ids)) > + break; > + } > + list_add(&eg->nd, pos); > + } > > return 0; > } > -- > 2.26.2.645.ge9eca65c58-goog >