diff options
author | Anton Blanchard <anton@samba.org> | 2010-05-04 07:19:15 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-04 09:54:09 -0400 |
commit | 02bf60aad7d5912dfcdbe0154f1bd67ea7a8301e (patch) | |
tree | 4d0c009e30079b127e0d7b01cdd30d8375e44c7c /tools/perf/util/header.c | |
parent | 11d232ec285b07860670277c8ab3f6076f7bce1e (diff) |
perf: Fix performance issue with perf report
On a large machine we spend a lot of time in perf_header__find_attr when
running perf report.
If we are parsing a file without PERF_SAMPLE_ID then for each sample we call
perf_header__find_attr and loop through all counter IDs, never finding a match.
As the machine gets larger there are more per cpu counters and we spend an
awful lot of time in there.
The patch below initialises each sample id to -1ULL and checks for this in
perf_header__find_attr. We may need to do something more intelligent eventually
(eg a hash lookup from counter id to attr) but this at least fixes the most
common usage of perf report.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Eric B Munson <ebmunson@us.ibm.com>
Acked-by: Eric B Munson <ebmunson@us.ibm.com>
LKML-Reference: <20100504111915.GB14636@kryten>
Signed-off-by: Anton Blanchard <anton@samba.org>
--
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 2b9f898efea6..8847bec64c54 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -922,6 +922,14 @@ perf_header__find_attr(u64 id, struct perf_header *header) | |||
922 | { | 922 | { |
923 | int i; | 923 | int i; |
924 | 924 | ||
925 | /* | ||
926 | * We set id to -1 if the data file doesn't contain sample | ||
927 | * ids. Check for this and avoid walking through the entire | ||
928 | * list of ids which may be large. | ||
929 | */ | ||
930 | if (id == -1ULL) | ||
931 | return NULL; | ||
932 | |||
925 | for (i = 0; i < header->attrs; i++) { | 933 | for (i = 0; i < header->attrs; i++) { |
926 | struct perf_header_attr *attr = header->attr[i]; | 934 | struct perf_header_attr *attr = header->attr[i]; |
927 | int j; | 935 | int j; |