Skip to content

Instantly share code, notes, and snippets.

@brendangregg
Created February 15, 2017 19:41
Show Gist options
  • Save brendangregg/3cfc2b40f0f76a76f461753d9d3a0ed4 to your computer and use it in GitHub Desktop.
Save brendangregg/3cfc2b40f0f76a76f461753d9d3a0ed4 to your computer and use it in GitHub Desktop.
function profiling
~# cd /sys/kernel/debug/tracing/
/sys/kernel/debug/tracing# echo 'SyS_*' > set_ftrace_filter
/sys/kernel/debug/tracing# echo 'sys_*' >> set_ftrace_filter
/sys/kernel/debug/tracing# echo 1 > function_profile_enabled
/sys/kernel/debug/tracing# cat trace_stat/function*
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_epoll_wait 248 84493639 us 340700.1 us 144715854 us
SyS_select 66 55851063 us 846228.2 us 2541716507 us
SyS_nanosleep 7 30001020 us 4285860 us 46343405773 us
SyS_poll 11 24500963 us 2227360 us 130849812996 us
SyS_read 276 1756.699 us 6.364 us 14.368 us
SyS_open 254 1250.911 us 4.924 us 2.330 us
SyS_write 11 122.455 us 11.132 us 34.746 us
SyS_close 255 121.079 us 0.474 us 0.004 us
SyS_newstat 15 60.516 us 4.034 us 2.883 us
SyS_getdents 10 45.142 us 4.514 us 17.111 us
SyS_inotify_add_watch 21 41.656 us 1.983 us 2.261 us
SyS_connect 1 16.150 us 16.150 us 0.000 us
SyS_rt_sigprocmask 36 12.493 us 0.347 us 0.042 us
SyS_clock_gettime 36 9.579 us 0.266 us 0.005 us
SyS_socket 1 8.297 us 8.297 us 0.000 us
SyS_newfstat 9 8.109 us 0.901 us 0.150 us
SyS_wait4 5 7.378 us 1.475 us 0.015 us
SyS_ioctl 4 6.404 us 1.601 us 0.168 us
SyS_epoll_ctl 2 5.598 us 2.799 us 2.020 us
SyS_alarm 3 5.107 us 1.702 us 1.201 us
SyS_fcntl 6 2.239 us 0.373 us 0.005 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_read 253 124007375 us 490147.7 us 94076996 us
SyS_select 72 69074422 us 959366.9 us 886660545 us
SyS_epoll_wait 245 24439463 us 99752.91 us 40948500 us
SyS_nanosleep 25 24003354 us 960134.1 us 9266607407 us
SyS_poll 96 23779574 us 247703.9 us 652665488 us
SyS_write 1010 3246.953 us 3.214 us 2.198 us
SyS_open 245 1188.307 us 4.850 us 0.309 us
SyS_close 245 121.940 us 0.497 us 0.000 us
SyS_wait4 24 22.341 us 0.930 us 0.073 us
SyS_ioctl 10 11.077 us 1.107 us 0.414 us
SyS_rt_sigaction 21 6.809 us 0.324 us 0.023 us
SyS_newstat 1 3.600 us 3.600 us 0.000 us
SyS_rt_sigprocmask 4 1.385 us 0.346 us 0.028 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_select 49 47025493 us 959703.9 us 794615550 us
SyS_read 120 1971.044 us 16.425 us 210.888 us
SyS_open 48 373.724 us 7.785 us 4.237 us
SyS_newfstat 48 30.678 us 0.639 us 0.012 us
SyS_close 48 28.050 us 0.584 us 0.001 us
SyS_lseek 48 20.848 us 0.434 us 0.004 us
sys_rt_sigreturn 25 18.932 us 0.757 us 0.046 us
SyS_ioctl 48 17.076 us 0.355 us 0.010 us
SyS_fcntl 48 13.659 us 0.284 us 0.002 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_select 24 23024613 us 959358.8 us 8337878124 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_read 58 24480147 us 422071.5 us 2132686426 us
SyS_clone 5 3131.839 us 626.367 us 3512.461 us
SyS_write 48 296.165 us 6.170 us 11.541 us
SyS_open 18 175.048 us 9.724 us 94.062 us
SyS_brk 10 120.925 us 12.092 us 91.059 us
SyS_pipe 9 40.003 us 4.444 us 3.230 us
SyS_newstat 17 39.741 us 2.337 us 1.253 us
SyS_getdents 12 36.052 us 3.004 us 9.882 us
SyS_close 51 24.595 us 0.482 us 0.037 us
SyS_wait4 9 24.494 us 2.721 us 9.378 us
SyS_ioctl 28 23.324 us 0.833 us 0.364 us
SyS_unlink 3 22.788 us 7.596 us 1.428 us
SyS_rt_sigprocmask 69 19.155 us 0.277 us 0.014 us
SyS_fcntl 64 18.766 us 0.293 us 0.011 us
SyS_dup2 27 13.907 us 0.515 us 0.046 us
SyS_accept 1 9.469 us 9.469 us 0.000 us
SyS_rt_sigaction 25 8.261 us 0.330 us 0.016 us
SyS_access 4 7.247 us 1.811 us 0.190 us
SyS_lseek 20 5.991 us 0.299 us 0.013 us
SyS_setpgid 5 4.906 us 0.981 us 0.303 us
SyS_newfstat 6 4.820 us 0.803 us 0.026 us
sys_rt_sigreturn 4 3.154 us 0.788 us 0.064 us
SyS_newlstat 1 2.231 us 2.231 us 0.000 us
SyS_alarm 1 1.365 us 1.365 us 0.000 us
SyS_poll 1 1.268 us 1.268 us 0.000 us
sys_getegid 4 0.371 us 0.092 us 0.000 us
sys_getgid 4 0.369 us 0.092 us 0.000 us
sys_geteuid 4 0.366 us 0.091 us 0.000 us
sys_getuid 4 0.359 us 0.089 us 0.000 us
SyS_epoll_wait 1 0.000 us 0.000 us 0.000 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_brk 8 76.915 us 9.614 us 61.324 us
SyS_read 1 75.717 us 75.717 us 0.000 us
SyS_newstat 19 47.122 us 2.480 us 0.596 us
SyS_write 10 33.585 us 3.358 us 12.393 us
SyS_open 4 21.814 us 5.453 us 0.302 us
SyS_rt_sigaction 58 15.867 us 0.273 us 0.005 us
SyS_getdents 8 15.660 us 1.957 us 1.809 us
SyS_close 22 12.936 us 0.588 us 0.049 us
SyS_rt_sigprocmask 11 5.259 us 0.478 us 0.099 us
SyS_setpgid 5 3.054 us 0.610 us 0.003 us
SyS_dup2 4 2.684 us 0.671 us 0.004 us
SyS_newfstat 4 2.578 us 0.644 us 0.023 us
SyS_ioctl 1 1.302 us 1.302 us 0.000 us
SyS_execve 1 0.000 us 0.000 us 0.000 us
SyS_exit_group 4 0.000 us 0.000 us 0.000 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_open 10 477.406 us 47.740 us 972.724 us
SyS_read 14 192.468 us 13.747 us 366.246 us
SyS_write 6 120.187 us 20.031 us 166.179 us
SyS_mmap 10 29.010 us 2.901 us 1.724 us
SyS_munmap 2 27.313 us 13.656 us 12.847 us
SyS_mmap_pgoff 10 27.210 us 2.721 us 1.740 us
SyS_mprotect 4 21.366 us 5.341 us 2.730 us
SyS_access 3 7.550 us 2.516 us 1.005 us
SyS_newfstat 11 7.236 us 0.657 us 0.011 us
SyS_close 9 5.286 us 0.587 us 0.012 us
SyS_brk 4 4.643 us 1.160 us 1.096 us
SyS_fadvise64 7 1.949 us 0.278 us 0.006 us
sys_arch_prctl 1 0.345 us 0.345 us 0.000 us
Function Hit Time Avg s^2
-------- --- ---- --- ---
SyS_select 491 41504512 us 84530.57 us 39051402 us
SyS_read 527 1542.688 us 2.927 us 38.526 us
SyS_write 387 1206.365 us 3.117 us 8.690 us
SyS_open 118 902.092 us 7.644 us 18.464 us
SyS_socket 121 367.902 us 3.040 us 0.920 us
SyS_rt_sigprocmask 946 309.864 us 0.327 us 0.017 us
SyS_clock_gettime 946 256.602 us 0.271 us 0.001 us
SyS_sendto 54 254.532 us 4.713 us 3.218 us
SyS_ioctl 254 231.875 us 0.912 us 0.212 us
SyS_recvfrom 54 149.138 us 2.761 us 0.707 us
SyS_close 223 94.607 us 0.424 us 0.001 us
SyS_newfstat 92 57.830 us 0.628 us 0.005 us
SyS_wait4 10 7.403 us 0.740 us 0.085 us
SyS_getdents 2 2.453 us 1.226 us 0.270 us
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment