Skip to content

tools/perf: Update rbtree implementation and optimize users

Davidlohr Bueso lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest7 patches 2 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7tools/perf: Update rbtree implementationtools/include/linux/rbtree.h tools/include/linux/rbtree_augmented.h tools/lib/rbtree.c+229 -610 replies
2/7perf machine: Use cached rbtreestools/perf/builtin-report.c tools/perf/util/build-id.c tools/perf/util/machine.c +2 more+50 -360 replies
3/7perf callchain: Use cached rbtreestools/perf/util/dso.c tools/perf/util/dso.h tools/perf/util/srcline.c +1 more+36 -280 replies
4/7perf util: Use cached rbtree for rbliststools/perf/util/intlist.h tools/perf/util/metricgroup.c tools/perf/util/rb_resort.h +4 more+24 -160 replies
5/7perf symbols: Use cached rbtreestools/perf/builtin-annotate.c tools/perf/util/dso.c tools/perf/util/dso.h +5 more+67 -580 replies
6/7perf hist: Use cached rbtreestools/perf/builtin-annotate.c tools/perf/builtin-c2c.c tools/perf/builtin-diff.c +11 more+167 -1412 replies
7/7perf sched: Use cached rbtreestools/perf/builtin-sched.c+25 -200 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 -tip 0/7] tools/perf: Update rbtree implementation and optimize users

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(-)
Signature · 1 line
2.16.4