When I run my program “top” reports that I am spending 30+% in “sy” (kernel space).
How can I get more information about this? What system call is eating up all
this time, etc.
Thanks responders:
-
It sounds like Devel::NYTProf is good for profiling the entire program — but I had trouble installing it on Amazon Linux.
-
If I just want a snapshot of system calls strace seems to be great.
Updated: I did this and the time spent in system calls is actually negligible. My best guess is the threads are stuck waiting on some resource. The answers are still good below but any advice would help.
You could use
strace(1) - trace system calls and signals.-cflag will produce aggregate results grouped by syscall.-p NUMis a PID of running process to attach.Monitoring a crawler (for instance) looks like this: