diff options
author | Mike Galbraith <efault@gmx.de> | 2009-05-25 03:57:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-25 07:01:17 -0400 |
commit | d94b943054721c346b0881865d645f000cd19880 (patch) | |
tree | 59a40841c54ccddd158fafef84e9e44c0985fb44 /Documentation/perf_counter | |
parent | 85a9f9200226ddffc2ea50dae6a8df04c033ecd4 (diff) |
perf top: Reduce display overhead
Iterate over the symbol table once per display interval, and
copy/sort/tally/decay only those symbols which are active.
Before:
top - 10:14:53 up 4:08, 17 users, load average: 1.17, 1.53, 1.49
Tasks: 273 total, 5 running, 268 sleeping, 0 stopped, 0 zombie
Cpu(s): 6.9%us, 38.2%sy, 0.0%ni, 19.9%id, 0.0%wa, 0.0%hi, 35.0%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ P COMMAND
28504 root 20 0 1044 260 164 S 58 0.0 0:04.19 2 netserver
28499 root 20 0 1040 412 316 R 51 0.0 0:04.15 0 netperf
28500 root 20 0 1040 408 316 R 50 0.0 0:04.14 1 netperf
28503 root 20 0 1044 260 164 S 50 0.0 0:04.01 1 netserver
28501 root 20 0 1044 260 164 S 49 0.0 0:03.99 0 netserver
28502 root 20 0 1040 412 316 S 43 0.0 0:03.96 2 netperf
28468 root 20 0 1892m 325m 972 S 16 10.8 0:10.50 3 perf
28467 root 20 0 1892m 325m 972 R 2 10.8 0:00.72 3 perf
After:
top - 10:16:30 up 4:10, 17 users, load average: 2.27, 1.88, 1.62
Tasks: 273 total, 6 running, 267 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.5%us, 39.7%sy, 0.0%ni, 24.6%id, 0.0%wa, 0.0%hi, 33.3%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ P COMMAND
28590 root 20 0 1040 412 316 S 54 0.0 0:07.85 2 netperf
28589 root 20 0 1044 260 164 R 54 0.0 0:07.84 0 netserver
28588 root 20 0 1040 412 316 R 50 0.0 0:07.89 1 netperf
28591 root 20 0 1044 256 164 S 50 0.0 0:07.82 1 netserver
28587 root 20 0 1040 408 316 R 47 0.0 0:07.61 0 netperf
28592 root 20 0 1044 260 164 R 47 0.0 0:07.85 2 netserver
28378 root 20 0 8732 1300 860 R 2 0.0 0:01.81 3 top
28577 root 20 0 1892m 165m 972 R 2 5.5 0:00.48 3 perf
28578 root 20 0 1892m 165m 972 S 2 5.5 0:00.04 3 perf
[ Impact: optimization ]
Signed-off-by: Mike Galbraith <efault@gmx.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter')
-rw-r--r-- | Documentation/perf_counter/builtin-top.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c index 74021ac90f51..4bed265926dd 100644 --- a/Documentation/perf_counter/builtin-top.c +++ b/Documentation/perf_counter/builtin-top.c | |||
@@ -374,18 +374,26 @@ static struct sym_entry tmp[MAX_SYMS]; | |||
374 | 374 | ||
375 | static void print_sym_table(void) | 375 | static void print_sym_table(void) |
376 | { | 376 | { |
377 | int i, printed; | 377 | int i, j, active_count, printed; |
378 | int counter; | 378 | int counter; |
379 | float events_per_sec = events/delay_secs; | 379 | float events_per_sec = events/delay_secs; |
380 | float kevents_per_sec = (events-userspace_events)/delay_secs; | 380 | float kevents_per_sec = (events-userspace_events)/delay_secs; |
381 | float sum_kevents = 0.0; | 381 | float sum_kevents = 0.0; |
382 | 382 | ||
383 | events = userspace_events = 0; | 383 | events = userspace_events = 0; |
384 | memcpy(tmp, sym_table, sizeof(sym_table[0])*sym_table_count); | ||
385 | qsort(tmp, sym_table_count, sizeof(tmp[0]), compare); | ||
386 | 384 | ||
387 | for (i = 0; i < sym_table_count && tmp[i].count[0]; i++) | 385 | /* Iterate over symbol table and copy/tally/decay active symbols. */ |
388 | sum_kevents += tmp[i].count[0]; | 386 | for (i = 0, active_count = 0; i < sym_table_count; i++) { |
387 | if (sym_table[i].count[0]) { | ||
388 | tmp[active_count++] = sym_table[i]; | ||
389 | sum_kevents += sym_table[i].count[0]; | ||
390 | |||
391 | for (j = 0; j < nr_counters; j++) | ||
392 | sym_table[i].count[j] = zero ? 0 : sym_table[i].count[j] * 7 / 8; | ||
393 | } | ||
394 | } | ||
395 | |||
396 | qsort(tmp, active_count + 1, sizeof(tmp[0]), compare); | ||
389 | 397 | ||
390 | write(1, CONSOLE_CLEAR, strlen(CONSOLE_CLEAR)); | 398 | write(1, CONSOLE_CLEAR, strlen(CONSOLE_CLEAR)); |
391 | 399 | ||
@@ -433,29 +441,23 @@ static void print_sym_table(void) | |||
433 | " ______ ______ _____ ________________ _______________\n\n" | 441 | " ______ ______ _____ ________________ _______________\n\n" |
434 | ); | 442 | ); |
435 | 443 | ||
436 | for (i = 0, printed = 0; i < sym_table_count; i++) { | 444 | for (i = 0, printed = 0; i < active_count; i++) { |
437 | float pcnt; | 445 | float pcnt; |
438 | int count; | ||
439 | 446 | ||
440 | if (printed <= 18 && tmp[i].count[0] >= count_filter) { | 447 | if (++printed > 18 || tmp[i].count[0] < count_filter) |
441 | pcnt = 100.0 - (100.0*((sum_kevents-tmp[i].count[0])/sum_kevents)); | 448 | break; |
442 | 449 | ||
443 | if (nr_counters == 1) | 450 | pcnt = 100.0 - (100.0*((sum_kevents-tmp[i].count[0])/sum_kevents)); |
444 | printf("%19.2f - %4.1f%% - %016llx : %s\n", | 451 | |
445 | sym_weight(tmp + i), | 452 | if (nr_counters == 1) |
446 | pcnt, tmp[i].addr, tmp[i].sym); | 453 | printf("%19.2f - %4.1f%% - %016llx : %s\n", |
447 | else | 454 | sym_weight(tmp + i), |
448 | printf("%8.1f %10ld - %4.1f%% - %016llx : %s\n", | 455 | pcnt, tmp[i].addr, tmp[i].sym); |
449 | sym_weight(tmp + i), | 456 | else |
450 | tmp[i].count[0], | 457 | printf("%8.1f %10ld - %4.1f%% - %016llx : %s\n", |
451 | pcnt, tmp[i].addr, tmp[i].sym); | 458 | sym_weight(tmp + i), |
452 | printed++; | 459 | tmp[i].count[0], |
453 | } | 460 | pcnt, tmp[i].addr, tmp[i].sym); |
454 | /* | ||
455 | * Add decay to the counts: | ||
456 | */ | ||
457 | for (count = 0; count < nr_counters; count++) | ||
458 | sym_table[i].count[count] = zero ? 0 : sym_table[i].count[count] * 7 / 8; | ||
459 | } | 461 | } |
460 | 462 | ||
461 | if (sym_filter_entry) | 463 | if (sym_filter_entry) |