I am attempting to profile my code, and I'm unable to interpret the results. So first, the meta-question is, what's the best forum to use to request help with such things?
The code I'm profiling is the server side of a moderately complex webapp. For simplicity, I've wrapped it with net/http/cgi and am calling it from the command line as a CGI "script". As such, it is handling a single request with no actual network traffic. Also, I've disabled the garbage collector. I'm calling pprof.StartCPUProfile at the top of ServeHTTP. The pprof output is at
It shows three different call chains. The one that actually includes my code, starting at runtime.main, is only 6% of the total CPU samples. There are two other call chains that are entirely within the runtime package, one of them taking 17% of the time and the other taking a whopping 70% of the time, and I can't figure out what they're doing. I would appreciate any guidance.
The chain that is taking 70% of the time is
gcBgMarkWorker
systemstack
gcBgMarkWorker.func2
gcDrain
markroot
markroot.func1
suspendG
Underneath suspendG it splits into nanotime, osyield, procyield, and preemptM, the latter of which has signalM, tgkill, and getpid children. getpid alone is shown as taking 4% of the CPU of the entire program! What the heck is this call chain doing, with nearly three quarters of my time?
The chain that is taking 17% of the time is
mcall
park_m
schedule
findrunnable
stopm
mPark
notesleep
futexsleep
futex
Again I have no clue what this is doing. Any guidance is welcome, including pointers to other forums better suited for such questions.
Regards,
Steve