plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
11.57k stars 388 forks source link

Can I use scalene and debugpy together? #463

Open balazser opened 1 year ago

balazser commented 1 year ago

I'm wondering if I can add scalene to a project that also runs debugpy?

I'm running my python module with debugpy listening from the source code:

import debugpy
debugpy.listen((DEBUG_LISTEN_HOST, port))

Starting the project with the command below makes scalene fail with the message below: scalene --cli ./myproject/debug.py

Error message could not find input file /home/myproject/.venv/lib/python3.8/site-packages/debugpy/adapter

Although python3.8/site-packages/debugpy/adapter path exists and can be imported by Python.

emeryberger commented 1 year ago

I'm not sure what mangling debugpy is doing, but Scalene is not seeing the targeted file but instead interpreting that path as the file to profile. Not sure how to proceed. We'd welcome a PR that addresses it. That said, debugpy seems like it might seriously disrupt the performance of the program being profiled (it certainly leads to a severe slowdown; I saw a 3X slowdown for one test), so I'm not sure it's a great idea to mix this with Scalene or any profiler, for that matter.