Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11089179imu; Thu, 6 Dec 2018 11:20:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3xhEzPlw4vtZGxXqXdIjuALRX+DiPZV+3beUE4hjFTjnYSYf2JXMrZBpQG3yqnKplGAYG X-Received: by 2002:a17:902:e10a:: with SMTP id cc10mr14977856plb.165.1544124017034; Thu, 06 Dec 2018 11:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544124017; cv=none; d=google.com; s=arc-20160816; b=SdVxAeP/NGX1CEq1PUQoQ6Q6O/GVPNNUzZavEOUowv2DuLLutZbZo5D+mapdxHu28k 4PyV9v5oeDX5u5wnuB91uQria9d84RGU8bPqu69osBgGTGu91GvVkhXoCfFB83SMeBfF LpbO+FLSqQDthOl2nx6+G4RF6H7bNu6ggtJi3Mw9Em4m+XMbs+O1d2+H+EFuZGQVmX2C wjG1LzcluUls+RXqh3EZjjSGXPKOwiceJzTa0gAZuqT9IGNASGciLfH5XjltrNLhi9LI npmHt1aWjuQ49LH2ho1E3JWaZmyRP5WBA3Ai6phGhQFskMHmkgT0win5gaZSDccz0MfZ A+IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=GHH+OIzPlUsTzoADn9i224WuBCNuIlcbLbyuL0QIOds=; b=DGX+3XbbrHp0ilHeFx0xcLKlM5C7R72d21Qmxxoh5uNEtbCKgLRiGrUFJ84pzRt7Eq 6eNpDPuNdGrB+k4wkOecKP0fN86E0kCmk86TYOKgCoGcSzhiSR66o/JFujroqujkee0R epqTm8BU8WYFPSNPWAP63ULVWHbkOc+3GT+Olzh4MGu8WT2FPUesC+6FxLJ9nPuOFMZE d9LZSDejrsLXkJljz3UCc+x4WkLhRT/Or4M+nZSnK4qZlD1uox53rT+yrLymUqi+FEsU K6NYw5yEFaiRNFtdKtDLil3Q846up5qCUvmfbSOq7z2Lc8RWC8xO5l1ZF2MhGTNtInZd DFUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o28si904955pgm.238.2018.12.06.11.20.01; Thu, 06 Dec 2018 11:20:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbeLFTSm (ORCPT + 99 others); Thu, 6 Dec 2018 14:18:42 -0500 Received: from smtp2.provo.novell.com ([137.65.250.81]:57033 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbeLFTSl (ORCPT ); Thu, 6 Dec 2018 14:18:41 -0500 Received: from linux-r8p5.suse.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Thu, 06 Dec 2018 12:18:30 -0700 From: Davidlohr Bueso To: acme@kernel.org Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, dave@stgolabs.net Subject: [PATCH v2 -tip 0/7] tools/perf: Update rbtree implementation and optimize users Date: Thu, 6 Dec 2018 11:18:12 -0800 Message-Id: <20181206191819.30182-1-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Per acme's request, this is a rebase (and basically rewrite) of v1. The following optimizes the rb_first() lookups in perf tooling such that we can avoid walking down the tree finding the first element. Tree traversals (and overall computing the first node in the tree) is a surprisingly common operation. On a Xeon E5-2450 @ 2.10GHz, the cost of an rb_first() was ~60 cycles for 100 nodes, and ~75 cycles with 1000 nodes. The first patch adds the updated implementation of rbtrees, including the cached interfaces, taken from the kernel. The rest of the patches make use of this for the users I thought might care the most. With these patches I am able to build and use perf without anything going wrong (but needs more testing no doubt, as changes while redundant can be a little tricky depending on if the user get smart about the trees). I'm sorry if some patches seem too big, I've tried to split them the best I could. Applies on today's -tip tree. Please consider for v4.21. Thanks! Davidlohr Bueso (7): tools/perf: Update rbtree implementation perf machine: Use cached rbtrees perf callchain: Use cached rbtrees perf util: Use cached rbtree for rblists perf symbols: Use cached rbtrees perf hist: Use cached rbtrees perf sched: Use cached rbtrees tools/include/linux/rbtree.h | 52 ++++++++- tools/include/linux/rbtree_augmented.h | 60 ++++++++-- tools/lib/rbtree.c | 178 ++++++++++++++++++++++------- tools/perf/builtin-annotate.c | 4 +- tools/perf/builtin-c2c.c | 6 +- tools/perf/builtin-diff.c | 10 +- tools/perf/builtin-report.c | 3 +- tools/perf/builtin-sched.c | 45 ++++---- tools/perf/builtin-top.c | 2 +- tools/perf/tests/hists_common.c | 8 +- tools/perf/tests/hists_cumulate.c | 14 +-- tools/perf/tests/hists_link.c | 8 +- tools/perf/tests/hists_output.c | 32 +++--- tools/perf/ui/browsers/hists.c | 6 +- tools/perf/ui/gtk/hists.c | 4 +- tools/perf/ui/stdio/hist.c | 3 +- tools/perf/util/build-id.c | 12 +- tools/perf/util/dso.c | 8 +- tools/perf/util/dso.h | 10 +- tools/perf/util/hist.c | 199 +++++++++++++++++++-------------- tools/perf/util/hist.h | 10 +- tools/perf/util/intlist.h | 2 +- tools/perf/util/machine.c | 53 +++++---- tools/perf/util/machine.h | 12 +- tools/perf/util/map.c | 8 +- tools/perf/util/metricgroup.c | 2 +- tools/perf/util/probe-event.c | 3 +- tools/perf/util/rb_resort.h | 8 +- tools/perf/util/rblist.c | 28 +++-- tools/perf/util/rblist.h | 2 +- tools/perf/util/sort.h | 4 +- tools/perf/util/srcline.c | 43 ++++--- tools/perf/util/srcline.h | 13 ++- tools/perf/util/stat-shadow.c | 2 +- tools/perf/util/strlist.h | 2 +- tools/perf/util/symbol.c | 87 +++++++------- tools/perf/util/symbol.h | 13 ++- tools/perf/util/symbol_fprintf.c | 2 +- 38 files changed, 598 insertions(+), 360 deletions(-) -- 2.16.4