Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 1 | Demonstrations of ucalls. |
| 2 | |
| 3 | |
| 4 | ucalls summarizes method calls in various high-level languages, including Java, |
Sasha Goldshtein | cfb5ee7 | 2017-02-08 14:32:51 -0500 | [diff] [blame] | 5 | Python, Ruby, PHP, and Linux system calls. It displays statistics on the most |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 6 | frequently called methods, as well as the latency (duration) of these methods. |
| 7 | |
| 8 | Through the syscalls support, ucalls can provide basic information on a |
| 9 | process' interaction with the system including syscall counts and latencies. |
| 10 | This can then be used for further exploration with other BCC tools like trace, |
| 11 | argdist, biotop, fileslower, and others. |
| 12 | |
| 13 | For example, to trace method call latency in a Java application: |
| 14 | |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 15 | # ucalls -L $(pidof java) |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 16 | Tracing calls in process 26877 (language: java)... Ctrl-C to quit. |
| 17 | |
| 18 | METHOD # CALLS TIME (us) |
| 19 | java/io/BufferedInputStream.getBufIfOpen 1 7.00 |
| 20 | slowy/App.isSimplePrime 8970 8858.35 |
| 21 | slowy/App.isDivisible 3228196 3076985.12 |
| 22 | slowy/App.isPrime 8969 4841017.64 |
| 23 | ^C |
| 24 | |
| 25 | |
| 26 | To trace only syscalls in a particular process and print the top 10 most |
| 27 | frequently-invoked ones: |
| 28 | |
| 29 | # ucalls -ST 10 3018 |
| 30 | Attached 375 kernel probes for syscall tracing. |
| 31 | Tracing calls in process 3018 (language: none)... Ctrl-C to quit. |
| 32 | |
| 33 | METHOD # CALLS |
| 34 | sys_rt_sigaction 4 |
| 35 | SyS_rt_sigprocmask 4 |
| 36 | sys_mprotect 5 |
| 37 | sys_read 22 |
| 38 | SyS_write 39 |
| 39 | SyS_epoll_wait 42 |
| 40 | sys_futex 177 |
| 41 | SyS_mmap 180 |
| 42 | sys_mmap_pgoff 181 |
| 43 | sys_munmap 817 |
| 44 | ^C |
| 45 | Detaching kernel probes, please wait... |
| 46 | |
| 47 | |
| 48 | To print only the top 5 methods and report times in milliseconds (the default |
| 49 | is microseconds): |
| 50 | |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 51 | # ucalls -mT 5 $(pidof python) |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 52 | Tracing calls in process 26914 (language: python)... Ctrl-C to quit. |
| 53 | |
| 54 | METHOD # CALLS |
| 55 | <stdin>.<module> 1 |
| 56 | <stdin>.fibo 14190928 |
| 57 | ^C |
| 58 | |
| 59 | |
| 60 | USAGE message: |
| 61 | |
| 62 | # ./ucalls.py -h |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 63 | usage: ucalls.py [-h] [-l {java,python,ruby,php,none}] [-T TOP] [-L] [-S] [-v] |
| 64 | [-m] |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 65 | pid [interval] |
| 66 | |
| 67 | Summarize method calls in high-level languages. |
| 68 | |
| 69 | positional arguments: |
| 70 | pid process id to attach to |
| 71 | interval print every specified number of seconds |
| 72 | |
| 73 | optional arguments: |
| 74 | -h, --help show this help message and exit |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 75 | -l {java,python,ruby,php,none}, --language {java,python,ruby,php,none} |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 76 | language to trace (if none, trace syscalls only) |
| 77 | -T TOP, --top TOP number of most frequent/slow calls to print |
| 78 | -L, --latency record method latency from enter to exit (except |
| 79 | recursive calls) |
| 80 | -S, --syscalls record syscall latency (adds overhead) |
| 81 | -v, --verbose verbose mode: print the BPF program (for debugging |
| 82 | purposes) |
| 83 | -m, --milliseconds report times in milliseconds (default is microseconds) |
| 84 | |
| 85 | examples: |
| 86 | ./ucalls -l java 185 # trace Java calls and print statistics on ^C |
| 87 | ./ucalls -l python 2020 1 # trace Python calls and print every second |
| 88 | ./ucalls -l java 185 -S # trace Java calls and syscalls |
| 89 | ./ucalls 6712 -S # trace only syscall counts |
| 90 | ./ucalls -l ruby 1344 -T 10 # trace top 10 Ruby method calls |
| 91 | ./ucalls -l ruby 1344 -L # trace Ruby calls including latency |
Sasha Goldshtein | cfb5ee7 | 2017-02-08 14:32:51 -0500 | [diff] [blame] | 92 | ./ucalls -l php 443 -LS # trace PHP calls and syscalls with latency |
Sasha Goldshtein | 070c1df | 2016-10-29 13:08:39 -0700 | [diff] [blame] | 93 | ./ucalls -l python 2020 -mL # trace Python calls including latency in ms |