scalene icon indicating copy to clipboard operation
scalene copied to clipboard

Support for celery

Open ehiggs opened this issue 3 years ago • 5 comments

As a developer working with distributed systems, I use a task queue to make some work asynchronous so that long running tasks do not block the web server threads. To profile the workers, we run the worker system using

celery worker -Q queuename

I would like to run

scalene --reduced-profile --html --outfile celery-profile.html celery worker -Q queuename

This 'works', but the result is a html file that has the celery main function highlighted and listed as using all the memory and cpu.

Celery has a few ways of managing workers.

  1. prefork. This uses multiprocessing to spawn processes to do the work.
  2. gevent. This converts workers to use gevent green threads.
  3. eventlet. Similar to gevent.

I tested scalene with prefork.

ehiggs avatar Jun 08 '21 14:06 ehiggs

Can you share the celery-profile.html file? If not, a small example that reproduces the problem would be immensely helpful - thanks!

emeryberger avatar Jun 09 '21 15:06 emeryberger

I've made a small example project:

https://github.com/ehiggs/scalene-celery-demo

ehiggs avatar Jun 13 '21 22:06 ehiggs

Hi, is there anything I can do to unblock investigation here? Thanks!

ehiggs avatar Nov 12 '21 16:11 ehiggs

Did you find a solution for this issue, @ehiggs?

I try to run scalene with celery but /tmp/out.json content is {}, @emeryberger.

python -m scalene --cli --profile-interval 1.0 --json --outfile /tmp/out.json /usr/local/bin/celery -A director._auto:cel worker --concurrency=1 --pool=prefork --prefetch-multiplier=1 --loglevel=INFO --queues="abc"

ducminhle avatar Oct 29 '23 11:10 ducminhle

No the closest solution I found here was to write some tests for the application level code and use scalene on that. But I never got it working with celery itself.

ehiggs avatar Oct 29 '23 14:10 ehiggs