path: bpfcc_0.35.0+ds-1.1/tools/funclatency_example.txt Run a quick-and-dirty profiler over all the functions in an executable: # ./funclatency /home/user/primes:* -p $(pidof primes) -F Tracing 15 functions for "/home/user/primes:*"... Hit Ctrl-C to end. ^C path: bpfcc_0.35.0+ds-1.1/tools/funclatency_example.txt there is considerable lock contention: # ./funclatency pthread:pthread_mutex_lock -p $(pidof contentions) Tracing 1 function for "pthread:pthread_mutex_lock"... Hit Ctrl-C to end. nsecs : count distribution path: bpfcc_0.35.0+ds-1.1/tools/cpudist_example.txt of microseconds: # ./cpudist.py -p $(pidof parprimes) -mL Tracing on-CPU time... Hit Ctrl-C to end. path: bpfcc_0.35.0+ds-1.1/tools/cpudist_example.txt particular process -- this helps reduce noise: # ./cpudist.py -p $(pidof parprimes) Tracing on-CPU time... Hit Ctrl-C to end. ^C path: bpfcc_0.35.0+ds-1.1/tools/dbslower_example.txt necessary, you can specify the process ids with the -p switch: # dbslower mysql -p $(pidof mysql) Tracing database queries for pids 25776 slower than 1 ms... TIME(s) PID MS QUERY path: bpfcc_0.35.0+ds-1.1/tools/dbslower.py elif args.db == "postgres": args.pids = map(int, subprocess.check_output( "pidof postgres".split()).split()) usdts = list(map(lambda pid: USDT(pid=pid), args.pids)) path: bpfcc_0.35.0+ds-1.1/tools/dbslower.py if args.db == "mysql": args.pids = map(int, subprocess.check_output( "pidof mysqld".split()).split()) elif args.db == "postgres": args.pids = map(int, subprocess.check_output( path: bpfcc_0.35.0+ds-1.1/tools/trace_example.txt the --enable-dtrace configure flag): # trace 'u:ruby:method__entry "%s.%s", arg1, arg2' -p $(pidof irb) -T TIME PID COMM FUNC - 12:08:43 18420 irb method__entry IRB::Context.verbose? path: bpfcc_0.35.0+ds-1.1/tools/funcinterval.py ./funcinterval t:vmscan:mm_vmscan_direct_reclaim_begin # time the interval of c:malloc used by top every 3 seconds ./funcinterval -p `pidof -s top` -i 3 c:malloc # time /usr/local/bin/python main function ./funcinterval /usr/local/bin/python:main path: bpfcc_0.35.0+ds-1.1/libbpf-tools/syscount.c "EXAMPLES:\n" " syscount # print top 10 syscalls by count every second\n" " syscount -p $(pidof dd) # look only at a particular process\n" " syscount -L # measure and sort output by latency\n" " syscount -P # group statistics by pid, not by syscall\n" path: bpfcc_0.35.0+ds-1.1/tools/old/memleak.py ./memleak -p $(pidof allocs) -t Trace allocations and display each individual call to malloc/free ./memleak -ap $(pidof allocs) 10 Trace allocations and display allocated addresses, sizes, and stacks every 10 seconds for outstanding allocations path: bpfcc_0.35.0+ds-1.1/tools/old/memleak.py Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds ./memleak -p $(pidof allocs) -t Trace allocations and display each individual call to malloc/free ./memleak -ap $(pidof allocs) 10 path: bpfcc_0.35.0+ds-1.1/tools/old/memleak.py EXAMPLES: ./memleak -p $(pidof allocs) Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds path: bpfcc_0.35.0+ds-1.1/tools/memleak.py ./memleak -p $(pidof allocs) -t Trace allocations and display each individual allocator function call ./memleak -ap $(pidof allocs) 10 Trace allocations and display allocated addresses, sizes, and stacks every 10 seconds for outstanding allocations path: bpfcc_0.35.0+ds-1.1/tools/memleak.py EXAMPLES: ./memleak -p $(pidof allocs) Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds path: bpfcc_0.35.0+ds-1.1/tools/memleak.py Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds ./memleak -p $(pidof allocs) -t Trace allocations and display each individual allocator function call ./memleak -ap $(pidof allocs) 10 path: bpfcc_0.35.0+ds-1.1/tools/numasched_example.txt # taskset 'yes' task to NUMA2(cpu=48): $ taskset -p 0x1000000000000 $(pidof yes) path: bpfcc_0.35.0+ds-1.1/tools/numasched_example.txt # taskset 'yes' task to NUMA1(cpu=24): $ taskset -p 0x1000000 $(pidof yes) # taskset 'yes' task to NUMA2(cpu=48): path: bpfcc_0.35.0+ds-1.1/tools/dbstat.py elif args.db == "postgres": args.pids = map(int, subprocess.check_output( "pidof postgres".split()).split()) program = """ path: bpfcc_0.35.0+ds-1.1/tools/dbstat.py if args.db == "mysql": args.pids = map(int, subprocess.check_output( "pidof mysqld".split()).split()) elif args.db == "postgres": args.pids = map(int, subprocess.check_output( path: bpfcc_0.35.0+ds-1.1/tools/stackcount_example.txt process, use the pthread_create USDT tracepoint: # ./stackcount -P -p $(pidof parprimes) u:pthread:pthread_create Tracing 1 functions for "u:pthread:pthread_create"... Hit Ctrl-C to end. ^C path: bpfcc_0.35.0+ds-1.1/tools/lib/ugc_example.txt For example, to trace all garbage collection events in a specific Node process: # ugc $(pidof node) Tracing garbage collections in node process 30012... Ctrl-C to quit. START TIME (us) DESCRIPTION path: bpfcc_0.35.0+ds-1.1/tools/lib/ugc_example.txt switches can be useful for this: # ugc -F Tenured $(pidof java) Tracing garbage collections in java process 29907... Ctrl-C to quit. START TIME (us) DESCRIPTION path: bpfcc_0.35.0+ds-1.1/tools/lib/ugc_example.txt ^C # ugc -M 1 $(pidof java) Tracing garbage collections in java process 29907... Ctrl-C to quit. START TIME (us) DESCRIPTION path: bpfcc_0.35.0+ds-1.1/tools/syscount_example.txt the entire system, but we can point it to a specific process of interest: # syscount -p $(pidof dd) Tracing syscalls, printing top 10... Ctrl+C to quit. [09:40:21] path: bpfcc_0.35.0+ds-1.1/libbpf-tools/memleak.c "./memleak -p $(pidof allocs) -t\n" " Trace allocations and display each individual allocator function call\n" "./memleak -ap $(pidof allocs) 10\n" " Trace allocations and display allocated addresses, sizes, and stacks\n" " every 10 seconds for outstanding allocations\n" path: bpfcc_0.35.0+ds-1.1/libbpf-tools/memleak.c "./memleak -s 5\n" " Trace roughly every 5th allocation, to reduce overhead\n" "./memleak -p $(pidof allocs) -S je_\n" " Trace task who sue jemalloc\n" ""; path: bpfcc_0.35.0+ds-1.1/libbpf-tools/memleak.c " Trace allocations and display a summary of 'leaked' (outstanding)\n" " allocations every 5 seconds\n" "./memleak -p $(pidof allocs) -t\n" " Trace allocations and display each individual allocator function call\n" "./memleak -ap $(pidof allocs) 10\n" path: bpfcc_0.35.0+ds-1.1/libbpf-tools/memleak.c "\n" "EXAMPLES:\n" "./memleak -p $(pidof allocs)\n" " Trace allocations and display a summary of 'leaked' (outstanding)\n" " allocations every 5 seconds\n" path: bpfcc_0.35.0+ds-1.1/tools/funcinterval_example.txt ./funcinterval t:vmscan:mm_vmscan_direct_reclaim_begin # time the interval of c:malloc used by top every 3 seconds ./funcinterval -p `pidof -s top` -i 3 c:malloc # time /usr/local/bin/python main function ./funcinterval /usr/local/bin/python:main path: bpfcc_0.35.0+ds-1.1/tools/funcinterval_example.txt # ./funcinterval -p `pidof -s top` c:malloc -i 3 Tracing uprobe function for "malloc"... Hit Ctrl-C to end. path: bpfcc_0.35.0+ds-1.1/tools/lib/ucalls_example.txt For example, to trace method call latency in a Java application: # ucalls -L $(pidof java) Tracing calls in process 26877 (language: java)... Ctrl-C to quit. path: bpfcc_0.35.0+ds-1.1/tools/lib/ucalls_example.txt is microseconds): # ucalls -mT 5 $(pidof python) Tracing calls in process 26914 (language: python)... Ctrl-C to quit. path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt prevalent. Use the -a switch: # ./memleak -p $(pidof allocs) -a Attaching to pid 5193, Ctrl+C to quit. [11:16:33] Top 2 stacks with outstanding allocations: path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt For example: # ./memleak -p $(pidof allocs) Attaching to pid 5193, Ctrl+C to quit. [11:16:33] Top 2 stacks with outstanding allocations: path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt ./memleak -p $(pidof allocs) -t Trace allocations and display each individual allocator function call ./memleak -ap $(pidof allocs) 10 Trace allocations and display allocated addresses, sizes, and stacks every 10 seconds for outstanding allocations path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt seconds, 3 times before quitting: # ./memleak -p $(pidof allocs) -s 10 5 3 Attaching to pid 2614, Ctrl+C to quit. [11:16:33] Top 2 stacks with outstanding allocations: path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds ./memleak -p $(pidof allocs) -t Trace allocations and display each individual allocator function call ./memleak -ap $(pidof allocs) 10 path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt EXAMPLES: ./memleak -p $(pidof allocs) Trace allocations and display a summary of "leaked" (outstanding) allocations every 5 seconds path: bpfcc_0.35.0+ds-1.1/tools/memleak_example.txt sys_mmap [kernel] # ./redis_memleak -p $(pidof allocs) -O '/proc/$(pid)/exe' --symbols-prefix='je_' Attaching to pid 2623, Ctrl+C to quit. [13:30:16] Top 10 stacks with outstanding allocations: path: bpfcc_0.35.0+ds-1.1/tools/lib/uflow_example.txt classes or methods. For example, trace only methods from the Thread class: # ./uflow -C java/lang/Thread $(pidof java) Tracing method calls in java process 27722... Ctrl-C to quit. CPU PID TID TIME(us) METHOD path: bpfcc_0.35.0+ds-1.1/tests/python/test_tools_smoke.py # ctypes. Therefore, we use SIGKILL. # To reproduce the above issue, run killsnoop and in another shell run # `kill -s SIGINT $(pidof python)`. As a result, killsnoop will print # a traceback but will not exit. self.run_with_int("killsnoop.py", kill=True) path: bpfcc_0.35.0+ds-1.1/tools/dbstat_example.txt switch is also used to request histograms at 3 second intervals: # dbstat mysql -p $(pidof mysql) -i 3 Tracing database queries for pids 25776 slower than 0 ms... [06:14:36] path: bpfcc_0.35.0+ds-1.1/tools/ppchcalls_example.txt interest: # ./ppchcalls.py -p $(pidof vim) Tracing ppc hcalls, printing top 10... Ctrl+C to quit. ^C[06:23:12]