-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/pprof: macOS 10.12 profile overcounts system calls #17406
Comments
Would it be possible for you to try a similar C program with the C compiler's |
I'm not sure whether I'm not sure how to put this, but as a pprof user I would be quite unhappy if the solution was "there's simply a difference in reporting". In that case, we should definitely find out in what cases exactly pprof is unreliable, and document this somewhere or/and alert users on Darwin about these issues. A profiler that is sometimes wrong can cause quite a lot of lost time ;) |
gperftools and Go's pprof command are based on the same code, but I doubt that is in the issue. If the same thing happens with C and Go, then the issue is almost certainly that the Darwin kernel If there is a bug here, it's likely to be in the kernel implementation of |
Thanks for the program. I ran it on my OS X 10.11.6 laptop and I get a profile that matches dtrace:
@quentinmit tried it on an OS X 10.12.1 beta laptop and got a similar profile (actually an even higher percentage of doSomething). So neither of us can reproduce this. Prior to OS X 10.11, there were problems with profiling signals being sent to the wrong thread, and the only workaround was to apply a binary patch to the kernel (see #6047). It is possible that the bug was reintroduced in OS X 10.12 and fixed in 10.12.1 beta, of course, but that seems unlikely. @lucas-clemente, two more pieces of data that would be useful from your machine that exhibits the problem:
Thanks. |
I have since upgraded to 10.12.1 (16B2555), and can still reproduce the problem. I also got @marten-seemann to try it on his machine, and he's seeing the same issue, so we're 2:2 ;) The output of The output of the C file from the commit message (compiled with I'd be really happy to help in any way, but I'm not sure what to do next :/ |
@lucas-clemente, is this a work machine that might have some kind of antivirus software on it watching the network I/O? Would the same be true of @marten-seemann's machine? Failing that, I'm trying to figure out what's different between your machines and ours. The two I tried are laptops (MacBook Pros). What hardware are you using? It's possible that dtrace is simply not reporting stacks at all for user code in a system call, so if the problem here is that the kernel is spending a lot more time in syscall.Syscall on your machine than it does on mine, that might not show up in dtrace. Even on our machines I see 5-15% of time in the system calls, and that's just not on your flame graph at all. Surely the program does spend some time in the writes, which makes me wonder if they are missing entirely from the dtrace. |
Both private retina MacBooks Pros, mine is from late 2013 (2.3 GHz i7). I'm not aware of anything I have running that should interfere with the network. I also checked that I'm not running any strange kexts, and only found VirtualBox (which I assume @marten-seemann has installed too). I tried uninstalling it and testing again, but that didn't change anything. I'm also using Docker's Mac app (which uses Hypervisor.framework), so I tried shutting that down too. Nothing changed.
|
Today I am getting 30-50% in syscall, both from master and from Go 1.7, so I guess I've reproduced the problem? Not sure what has changed. |
Even so I don't think we're going to get to this for Go 1.8. |
I've also found that CPU profiling on macOS is pretty much useless lately. @rsc, do you want to take a look for Go 1.9 or should we move to Go 1.10? |
Not going to happen for Go 1.9, sorry. |
I can also confirm profiling is broken (again) on 10.12.6 from what appears to be a kernel bug. I am running High Sierra 10.13 Beta 2 on a second laptop (identical hardware) and everything works as expected.
|
Happy to hear this is fixed in High Sierra. Closing. |
I'm seemingly having this issue on http pprof (running a light benchmark with 10 simultaneous connections). The trace clearly shows running the following path (overshadowing anything else, even tho some heavier tasks were performed): Running: |
@Allendar This issue is closed because we think it is fixed. Please open a new issue with full details. Thanks. |
I've encountered a strong discrepancy between pprof and dtrace while profiling quic-go. I've managed to reduce it to a somewhat simple test case (link), where (in a loop) data is sent via UDP to localhost and some CPU intensive computation that takes a few ms runs.
Profiling this via dtrace gives the expected result, with the CPU intensive part taking the majority of the time. dtrace (imo correctly) shows
doSomething
taking almost all of the runtime, whereas pprof says 62% is spent insyscall.Syscall6
, called by thenetFD.Write
method.The dtrace profile is generated using flamegraph with
The pprof profile is generated using
### All files - [The dtrace flamegraph SVG](https://dl.dropboxusercontent.com/u/1428776/pprof-report/dtrace.svg) - [The dtrace output](https://dl.dropboxusercontent.com/u/1428776/pprof-report/out.dtrace) - [The pprof SVG](https://dl.dropboxusercontent.com/u/1428776/pprof-report/pprof.svg) - [The pprof profile](https://dl.dropboxusercontent.com/u/1428776/pprof-report/pprof.pprof-test.localhost%3A8080.samples.cpu.002.pb.gz) - [The compiled binary from which the profile was generated](https://dl.dropboxusercontent.com/u/1428776/pprof-report/pprof-test) ### What version of Go are you using (`go version`)?
go version go1.7.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?macOS 10.12 (16A323)
The text was updated successfully, but these errors were encountered: