[PATCH 3/3] perf diff: Use internal rb tree for compute resort
From: Namhyung Kim There's no reason to run hists_compute_resort() using output tree. Convert it to use internal tree so that it can remove unnecessary _output_resort. Also move position computation below the resort since it changes the output ordering. Cc: Jiri Olsa Cc: Stephane Eranian Signed-off-by: Namhyung Kim --- tools/perf/builtin-diff.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index b52f5d8c4a6b..4e18cea7c845 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -435,19 +435,25 @@ static void insert_hist_entry_by_compute(struct rb_root *root, static void hists__compute_resort(struct hists *hists) { - struct rb_root tmp = RB_ROOT; - struct rb_node *next = rb_first(&hists->entries); + struct rb_root *root; + struct rb_node *next; + + if (sort__need_collapse) + root = &hists->entries_collapsed; + else + root = hists->entries_in; + + hists->entries = RB_ROOT; + next = rb_first(root); while (next != NULL) { - struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); + struct hist_entry *he; - next = rb_next(&he->rb_node); + he = rb_entry(next, struct hist_entry, rb_node_in); + next = rb_next(&he->rb_node_in); - rb_erase(&he->rb_node, &hists->entries); - insert_hist_entry_by_compute(&tmp, he, compute); + insert_hist_entry_by_compute(&hists->entries, he, compute); } - - hists->entries = tmp; } static void hists__process(struct hists *old, struct hists *new) @@ -459,16 +465,16 @@ static void hists__process(struct hists *old, struct hists *new) else hists__link(new, old); - hists__output_resort(new); - - if (show_displacement) - hists__compute_position(new); - if (sort_compute) { hists__precompute(new); hists__compute_resort(new); + } else { + hists__output_resort(new); } + if (show_displacement) + hists__compute_position(new); + hists__fprintf(new, true, 0, 0, stdout); } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 3/3] perf diff: Use internal rb tree for compute resort
On Tue, 4 Dec 2012 10:45:44 -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Dec 04, 2012 at 01:44:25PM +0900, Namhyung Kim escreveu: >> From: Namhyung Kim >> >> There's no reason to run hists_compute_resort() using output tree. >> Convert it to use internal tree so that it can remove unnecessary >> _output_resort. Also move position computation below the resort since >> it changes the output ordering. > > Have you tested this with 'perf top'? With the highest frequency? After testing 'perf top -F 10' couple of minutes, I couldn't find any visible problem. Basically this patchset changes hists__link/match path which only called from 'perf diff' - I'm working on making use of that for event group report though. So I didn't check perf top side seriously. Any reason do you mention it that I'm missing? Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 3/3] perf diff: Use internal rb tree for compute resort
Em Tue, Dec 04, 2012 at 01:44:25PM +0900, Namhyung Kim escreveu: > From: Namhyung Kim > > There's no reason to run hists_compute_resort() using output tree. > Convert it to use internal tree so that it can remove unnecessary > _output_resort. Also move position computation below the resort since > it changes the output ordering. Have you tested this with 'perf top'? With the highest frequency? - Arnaldo > Cc: Jiri Olsa > Cc: Stephane Eranian > Signed-off-by: Namhyung Kim > --- > tools/perf/builtin-diff.c | 32 +++- > 1 file changed, 19 insertions(+), 13 deletions(-) > > diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c > index b52f5d8c4a6b..4e18cea7c845 100644 > --- a/tools/perf/builtin-diff.c > +++ b/tools/perf/builtin-diff.c > @@ -435,19 +435,25 @@ static void insert_hist_entry_by_compute(struct rb_root > *root, > > static void hists__compute_resort(struct hists *hists) > { > - struct rb_root tmp = RB_ROOT; > - struct rb_node *next = rb_first(&hists->entries); > + struct rb_root *root; > + struct rb_node *next; > + > + if (sort__need_collapse) > + root = &hists->entries_collapsed; > + else > + root = hists->entries_in; > + > + hists->entries = RB_ROOT; > + next = rb_first(root); > > while (next != NULL) { > - struct hist_entry *he = rb_entry(next, struct hist_entry, > rb_node); > + struct hist_entry *he; > > - next = rb_next(&he->rb_node); > + he = rb_entry(next, struct hist_entry, rb_node_in); > + next = rb_next(&he->rb_node_in); > > - rb_erase(&he->rb_node, &hists->entries); > - insert_hist_entry_by_compute(&tmp, he, compute); > + insert_hist_entry_by_compute(&hists->entries, he, compute); > } > - > - hists->entries = tmp; > } > > static void hists__process(struct hists *old, struct hists *new) > @@ -459,16 +465,16 @@ static void hists__process(struct hists *old, struct > hists *new) > else > hists__link(new, old); > > - hists__output_resort(new); > - > - if (show_displacement) > - hists__compute_position(new); > - > if (sort_compute) { > hists__precompute(new); > hists__compute_resort(new); > + } else { > + hists__output_resort(new); > } > > + if (show_displacement) > + hists__compute_position(new); > + > hists__fprintf(new, true, 0, 0, stdout); > } > > -- > 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] perf diff: Use internal rb tree for compute resort
From: Namhyung Kim There's no reason to run hists_compute_resort() using output tree. Convert it to use internal tree so that it can remove unnecessary _output_resort. Also move position computation below the resort since it changes the output ordering. Cc: Jiri Olsa Cc: Stephane Eranian Signed-off-by: Namhyung Kim --- tools/perf/builtin-diff.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index b52f5d8c4a6b..4e18cea7c845 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -435,19 +435,25 @@ static void insert_hist_entry_by_compute(struct rb_root *root, static void hists__compute_resort(struct hists *hists) { - struct rb_root tmp = RB_ROOT; - struct rb_node *next = rb_first(&hists->entries); + struct rb_root *root; + struct rb_node *next; + + if (sort__need_collapse) + root = &hists->entries_collapsed; + else + root = hists->entries_in; + + hists->entries = RB_ROOT; + next = rb_first(root); while (next != NULL) { - struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); + struct hist_entry *he; - next = rb_next(&he->rb_node); + he = rb_entry(next, struct hist_entry, rb_node_in); + next = rb_next(&he->rb_node_in); - rb_erase(&he->rb_node, &hists->entries); - insert_hist_entry_by_compute(&tmp, he, compute); + insert_hist_entry_by_compute(&hists->entries, he, compute); } - - hists->entries = tmp; } static void hists__process(struct hists *old, struct hists *new) @@ -459,16 +465,16 @@ static void hists__process(struct hists *old, struct hists *new) else hists__link(new, old); - hists__output_resort(new); - - if (show_displacement) - hists__compute_position(new); - if (sort_compute) { hists__precompute(new); hists__compute_resort(new); + } else { + hists__output_resort(new); } + if (show_displacement) + hists__compute_position(new); + hists__fprintf(new, true, 0, 0, stdout); } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/