perf ui: New hists tree widget
Commit-ID: 0f0cbf7aa3d3460a3eb201a772326739a0c0210a Gitweb: http://git.kernel.org/tip/0f0cbf7aa3d3460a3eb201a772326739a0c0210a Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 26 Jul 2010 17:13:40 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 27 Jul 2010 11:24:31 -0300
perf ui: New hists tree widget
The stock newt checkbox tree widget we were using was not really suitable for hist entry + callchain browsing.
The problems with it were manifold:
- We needed to traverse the whole hist_entry rb_tree to add each entry + callchains beforehand.
- No control over the colors used for each row
So a new tree widget, based mostly on slang, was written.
It extends the ui_browser class already used for annotate to allow the user to fold/unfold branches in the callchains tree, using extra fields in the symbol_map class that is embedded in hist_entry and callchain_node instances to store the folding state and when changing this state calculates the number of rows that are produced when showing a particular hist_entry instance.
This greatly speeds up browsing as we don't have to upfront touch all the entries and only calculate callchain related operations when some callchain branch is actually unfolded.
The memory footprint is also reduced as the data structure is not duplicated, just some extra fields for controling callchain state and to simplify the process of seeking thru entries (nr_rows, row_offset) were added.
Cc: Frederic Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <new-submission>
--- tools/perf/util/hist.c | 3 + tools/perf/util/newt.c | 972 +++++++++++++++++++++++++++++++--------------- tools/perf/util/sort.h | 12 + tools/perf/util/symbol.h | 2 + 4 files changed, 678 insertions(+), 311 deletions(-)
tools/perf/util/hist.c +3 -0
@@ -885,6 +885,9 @@ static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h,return ; ++self->nr_entries; +if (h->ms.unfolded) + self->nr_entries += h->nr_rows; + h->row_offset =0 ; self->stats.total_period += h->period; self->stats.nr_events[PERF_RECORD_SAMPLE ] += h->nr_events;
tools/perf/util/newt.c +661 -311
1,044 lines not on this page · raw message
tools/perf/util/sort.h +12 -0
@@ -38,6 +38,12 @@ extern struct sort_entry sort_sym;extern struct sort_entry sort_parent;extern enum sort_type sort__first_dimension; +/** +* struct hist_entry - histogram entry +* +* @row_offset - offset from the first callchain expanded to appear on screen +* @nr_rows - rows expanded in callchain, recalculated on folding/unfolding +*/ struct hist_entry {struct rb_node rb_node;u64 period;
@@ -50,6 +56,12 @@ struct hist_entry {u64 ip;s32 cpu;u32 nr_events; + +/* XXX These two should move to some tree widget lib */ +u16 row_offset; +u16 nr_rows; + +bool init_have_children;char level;u8 filtered;struct symbol *parent;
tools/perf/util/symbol.h +2 -0
@@ -102,6 +102,8 @@ struct ref_reloc_sym {struct map_symbol {struct map *map;struct symbol *sym; +bool unfolded; +bool has_children; };struct addr_location {