-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Milestone
Description
Multithreaded CPU profiles do not work on OS X, but worse they give little indication that they are broken. Single-threaded profiles kind of work, but only because we play games changing the signal mask every time we start executing Go code, so we incur overhead on every thread switch, and that in turn is suspected of causing deadlocks (see issue #5519). Also, many times you can't quite be sure you hit the single-threaded case, so the profiles are not truly believable. For years I have pulled out my Linux laptop when I want to do real performance work with profiles. The fundamental problem is that OS X delivers the profiling signals to the wrong thread (golang.org/change/35b716c94225). The signal mask trick is an attempt to work around this, but it's incomplete and misleading. I intend to remove the workarounds from package runtime, so that CPU profiles on OS X will typically be empty, because the wrong thread will receive the signals. That will avoid giving out inaccurate information. It should also fix issue #5519 and simplify the scheduler. The correct place to fix this bug is in the OS X kernel. I filed an Apple Bug Report in 2011 (again see golang.org/change/35b716c94225) but the problem remains. For people who insist on accurate profiling on OS X and are a bit adventurous, it may be possible to modify the kernel to deliver the profiling signal correctly. See http://godoc.org/code.google.com/p/rsc/cmd/pprof_mac_fix for details, and heed the warnings in its documentation.