lkml.org 
[lkml]   [2020]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH 4/7] perf metricgroup: Order event groups by size
    From
    When adding event groups to the group list, insert them in size order.
    This performs an insertion sort on the group list. By placing the
    largest groups at the front of the group list it is possible to see if a
    larger group contains the same events as a later group. This can make
    the later group redundant - it can reuse the events from the large group.
    A later patch will add this sharing.

    Signed-off-by: Ian Rogers <irogers@google.com>
    ---
    tools/perf/util/metricgroup.c | 16 +++++++++++++++-
    1 file changed, 15 insertions(+), 1 deletion(-)

    diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
    index afd960d03a77..52e4c3e4748a 100644
    --- a/tools/perf/util/metricgroup.c
    +++ b/tools/perf/util/metricgroup.c
    @@ -508,7 +508,21 @@ static int __metricgroup__add_metric(struct list_head *group_list,
    return -EINVAL;
    }

    - list_add_tail(&eg->nd, group_list);
    + if (list_empty(group_list))
    + list_add(&eg->nd, group_list);
    + else {
    + struct list_head *pos;
    +
    + /* Place the largest groups at the front. */
    + list_for_each_prev(pos, group_list) {
    + struct egroup *old = list_entry(pos, struct egroup, nd);
    +
    + if (hashmap__size(&eg->pctx.ids) <=
    + hashmap__size(&old->pctx.ids))
    + break;
    + }
    + list_add(&eg->nd, pos);
    + }

    return 0;
    }
    --
    2.26.2.761.g0e0b3e54be-goog
    \
     
     \ /
      Last update: 2020-05-20 09:29    [W:2.608 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site