profiling icon indicating copy to clipboard operation
profiling copied to clipboard

Does profiling work well with asyncio?

Open nchammas opened this issue 9 years ago • 15 comments

I noticed that the README mentions support for greenlets. How about Python 3.4+'s asyncio?

Should we just use --timer=greenlet for all the varieties of asynchronous programming that Python supports (greenlets, threading, multiprocessing, asyncio, etc.)?

nchammas avatar Jun 17 '15 22:06 nchammas

No, you shouldn't use --timer=greenlet. I didn't care about asyncio application but I should have done it. For now, probably we can't profile asyncio application with profiling. I'll try to find a solution.

Thanks to report.

sublee avatar Jul 20 '15 16:07 sublee

I'm working on this issue.

Checkout https://github.com/sublee/profiling/tree/eventloop-aware and try like:

$ profiling yourapp.py --eventloop-aware=asyncio

I need to hear some feedback.

sublee avatar Oct 21 '15 03:10 sublee

Hi @sublee! Thanks for revisiting this issue.

I won't be able to test this anytime soon, but I'll try to test it out at some point.

nchammas avatar Oct 23 '15 20:10 nchammas

@sublee awesome! Exactly what I was looking for. Seems to work! Thanks!

As a tip for others. Syntax is: $ profiling live-profile --eventloop-aware=asyncio ~/dev/weather/services/arrayds/app/web/app.py -- YOUR_SCRIPT_ARGS

thehesiod avatar Feb 04 '16 23:02 thehesiod

@sublee I can't clone your version of the code doing pip install git+https://github.com/sublee/profiling/tree/eventloop-aware doesn't clone the code.

Collecting git+https://github.com/sublee/profiling/tree/eventloop-aware
  Cloning https://github.com/sublee/profiling/tree/eventloop-aware to    /var/folders/rs/75jmmsys1dl016fnw1gsq0r00000gn/T/pip-89loyzv3-build
fatal: repository 'https://github.com/sublee/profiling/tree/eventloop-aware/' not found
  Complete output from command git clone -q https://github.com/sublee/profiling/tree/eventloop-aware /var/folders/rs/75jmmsys1dl016fnw1gsq0r00000gn/T/pip-89loyzv3-build:

Alexis-benoist avatar May 11 '16 13:05 Alexis-benoist

@Alexis-benoist Your URL is not correct. Try to install with $ pip install git+https://github.com/what-studio/profiling.git@eventloop-aware.

sublee avatar Jul 21 '16 12:07 sublee

Any update on this? Could really use a profiling tool for asyncio.

zet4 avatar Oct 17 '16 08:10 zet4

I've been using http://www.pyvmmonitor.com/ with pretty good success

thehesiod avatar Oct 17 '16 18:10 thehesiod

@thehesiod thanks for suggestion but I just tried it in my application and without any success.

zet4 avatar Oct 17 '16 19:10 zet4

+1 for this.

advance512 avatar Dec 11 '16 13:12 advance512

Brilliant! Note that I needed to comment out asyncio.Task._wakeup and asyncio.Task._step in https://github.com/what-studio/profiling/blob/eventloop-aware/profiling/adapting.py#L30 to ignore method_descriptor object has no attribute '__code__' exception in Python 3.6

lambdalisue avatar Jun 21 '17 09:06 lambdalisue

Hello, I ran into the same issue as above in Python 3.6. It would be nice to have this pulled into the code...

Edit: I'm not sure if i should report this as another bug, but if you use uvloop with profiling, you run into this error:

File ".../profiling/viewer.py", line 685, in keypress
    if not parent_node.is_root():
AttributeError: 'NoneType' object has no attribute 'is_root'

xNinjaKittyx avatar Apr 04 '18 17:04 xNinjaKittyx

@sublee https://github.com/sublee/profiling/tree/eventloop-aware this asyncio feature is merged to this repo master branch, right? I'm confused cause I think it's working well now with asyncio.

MJ111 avatar Oct 08 '18 07:10 MJ111

@MJ111 No, the branch has not been merged into master yet. Does master work well with asyncio now?

sublee avatar Oct 08 '18 10:10 sublee

@sublee I think so. I thought it’s merged already because there’s ‘asyncio.py’ in ‘profiling/remote’ folder. I might be wrong.

MJ111 avatar Oct 08 '18 10:10 MJ111