Messages in this thread | | | Date | Thu, 20 Dec 2012 11:59:01 +0900 | From | Namhyung Kim <> | Subject | Re: [PATCH 07/14] perf ui/hist: Add support for event group view |
| |
On Tue, Dec 18, 2012 at 04:47:10PM +0100, Jiri Olsa wrote: > On Mon, Dec 17, 2012 at 03:38:58PM +0900, Namhyung Kim wrote: > > From: Namhyung Kim <namhyung.kim@lge.com> > > > > Show group members' overhead also when showing the leader's if event > > group is enabled. Use macro for defining hpp functions which looks > > almost identical. > > SNIP > > > - > > -static int hpp__color_overhead_us(struct perf_hpp_fmt *fmt __maybe_unused, > > - struct perf_hpp *hpp, struct hist_entry *he) > > +static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he, > > + u64 (*get_field)(struct hist_entry *), > > + const char *fmt, hpp_snprint_fn print_fn) > > it's hard to tell from diff, but the function looks like this (group part):
Exactly.
> > if (symbol_conf.event_group) { > int prev_idx, idx_delta, i; > struct perf_evsel *evsel = hists_to_evsel(hists); > struct hist_entry *pair; > int nr_members = evsel->nr_members; > > if (nr_members <= 1) > return ret; > > prev_idx = perf_evsel__group_idx(evsel); > > list_for_each_entry(pair, &he->pairs.head, pairs.node) { > u64 period = get_field(pair); > u64 total = pair->hists->stats.total_period; > > if (!total) > continue; > > evsel = hists_to_evsel(pair->hists); > idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1; > > for (i = 0; i < idx_delta; i++) { > ret += print_fn(hpp->buf + ret, hpp->size - ret, > fmt, 0.0); > } > > ret += print_fn(hpp->buf + ret, hpp->size - ret, > fmt, 100.0 * period / total); > > prev_idx += 1 + idx_delta; > } > > idx_delta = nr_members - prev_idx - 1; > > for (i = 0; i < idx_delta; i++) { > ret += print_fn(hpp->buf + ret, hpp->size - ret, > fmt, 0.0); > } > } > > The temporary array (initial send) was more clear to me.. but if > this is the preffered way I wont object, since this is another place > that would benefit from hist_entries array linking.. when (and if) > there's ever patch for that ;-) > > I think this code now suffers from mischosen data layer
Yes, I admit that using array can make things simple. But I also don't like a temporary array due to its runtime cost. Linking hist entries by array can be a solution since it can be reused for output resorting and (multiple) hpp column(s). In addition, it might have a smaller memory footprint than the list method for the leader-only sample feature since it'll make every hist entries to be linked IMHO.
Thanks, Namhyung
| |