nylas-perftools icon indicating copy to clipboard operation
nylas-perftools copied to clipboard

[Question] Sampling inside gunicorn gevent worker.

Open psihonavt opened this issue 10 years ago • 2 comments

Hello,

Is this sampling strategy supposed to work in "gevent-driven" environment, like gunicorn gevent worker? I've tried it in our system, and looks like that after several minutes of sampling it just hangs somewhere in _sample, probably in while loop (other application code is working as expected).

Thanks.

psihonavt avatar Dec 28 '15 17:12 psihonavt

Aw that's no good! We run the sampler in heavily gevent-dependent applications without any issues; I'm not sure offhand what the issue might be. What versions of gunicorn and gevent are you using? Do you have any other OS-signal-handling code in your application (in particular for SIGVTALRM)?

emfree avatar Dec 29 '15 18:12 emfree

+1 can someone talk about how to integrate this in a gunicorn based deployment ? currently we use cprofile and use it like this

  def post_fork(server, worker):
      # Patch psycopg for gevent after we fork.
      psycogreen.gevent.patch_psycopg()
      worker.log.info('Made psycopg green: psycogreen.gevent.patch_psycopg')
      orig_init_process_ = worker.init_process
      def profiling_init_process(self):
            orig_init_process = orig_init_process_
            ofile = '%s%s' % (profiling_prefix, getpid())
            print 'Profiling worker %s, output file: %s' % (worker, ofile)
            cProfile.runctx('orig_init_process()', globals(), locals(), ofile)
      worker.init_process = profiling_init_process.__get__(worker)

we then use runsnakerun to view it. would love to use nylas

sandys avatar Dec 30 '15 10:12 sandys