Summarize syscall counts

Count syscalls and their time across all forks, sorted by time, to find the most expensive call

strace -c -f -S time -p <pid>

tool
strace13 commands
tags
straceperformancedebugtroubleshooting

More strace commands

  • strace -yy -T -tt -e trace=%file -p <pid>

    Show the paths and sockets behind fds, plus the duration and timestamp of each file operation

  • strace -k -e trace=openat -f -p <pid>

    Print the user stack on each openat to see which code opens the file; needs debug symbols

  • strace -f -e inject=openat:error=ENOENT:when=3 -p <pid>

    Make the 3rd openat fail with ENOENT to test error handling; chaos testing without changing code

  • strace -f -e signal=all -e trace=none -p <pid>

    Show only signals like SIGTERM and SIGCHLD and skip syscalls, to find out who killed the process; for library calls use ltrace

  • strace -o trace.log ls /tmp

    Run a command under strace and save the output to a file

all 13 strace commands