1. 39
  1.  

    1. 5

      GOPPROF=http

      https://github.com/anacrolix/envpprof

      Program gets stuck, just read the goroutine stacks.

      In really difficult cases, I have a sync replacement package that tracks stack traces when locks are taken and released. Enable that with an env var and you just open up the profile for locks and you will see it immediately. A bunch of stacks stuck trying to take a lock and the one routine that holds it.

      PPROF_SYNC=contention

      https://github.com/anacrolix/sync

      1. 2

        how very timely, I’ve just encountered a odd hang in a small personal project. thanks!

        1. 2

          I always enable net/http/pprof in my servers.

          1. 2

            Not all Go program is a server though.

            1. 1

              True, but in the context of the article if your program is hanging and it isn’t the pprof http handler that’s hanging then it may still be useful.