microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.28k stars 1.17k forks source link

Add Profiling (code performance analysis) capability #10645

Open ErwanDL opened 4 years ago

ErwanDL commented 4 years ago

It could be helpful to add profiling capabilities to the VSCode extension, similar to what is possible in PyCharm. The standard library module cProfile already provides a back-end for profiling a Python script, but it could benefit from having a more user-friendly front-end.

A possible first step to integrate this feature would be to add a "Profiling" tab, in which the user could see a table that summarizes the profiling results, and that he could sort and search in, to see what functions incur the most performance overhead. This could be similar to the "Statistics" tab in PyCharm's profiler (see previous link).

Do you think it would be reasonable and would add value to implement such a feature in the Python extension ?

NOTE : I saw that a similar request was made 2 years ago (https://github.com/microsoft/vscode-python/issues/733), but I was wondering if your position on this had changed since then, especially as the border between VSCode and IDEs is getting blurrier and blurrier (which is definitely a good thing IMO).

karthiknadig commented 4 years ago

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

ebardie commented 4 years ago

I've come to this page searching for how to profile Python from VSCode. I can debug Python code within VSCode, so profiling is a very obvious next step.

kleinicke commented 4 years ago

I was also looking everywhere for this (and am here since I also wanted to write a feature request). The complete field of profiling for python is somehow not enhancing. Most tools to use are older than 10 years. Maybe it's time for vs code to revolutionize this topic (or at least catch up to PyCharm).

rickstaa commented 3 years ago

This would be an amazing feature to have! It would allow me to do everything in vscode instead of switching between spyder and vscode!

malekcellier commented 3 years ago

Hi!

I have also been looking around and found that the browser devtools pack really nice features, many of which are relevant to the Python ecosystem.

There is this blog post describing a very interesting project (based on Firefox, no Windows support..) called FunctionTrace

Here is another one for C++: Tracy C++

Here is a list of the typical web devtools:

Hopefully this will get some traction.

Cheers!

rickstaa commented 3 years ago

@malekcellier Wow FunctionTrace indeed looks amazing. Exactly what I need. Thanks a lot for bringing it to my attention.

rickstaa commented 3 years ago

@malekcellier I noticed the current version contained one small bug I created a pull request to fix this https://gitlab.com/mbryant/functiontrace/-/merge_requests/7.

joshwaoti commented 3 years ago

Thank you so much @malekcellier

malekcellier commented 3 years ago

You are welcome!

In the same vein, I stumbled about this project: viztracer

Maybe that's useful too

pietrodantuono commented 3 years ago

Hi all, No updates on this regard?

CarlosEduR commented 3 years ago

Hello guys, any updates?

Looking for something like this, 'cause I have no money to upgrade my pycharm version to professional lol.

PeterQiu0516 commented 3 years ago

Hi all,

Do we get any updates on this?

luabud commented 3 years ago

Hey folks, no updates so far. We'd love to get to it at some point but no ETA yet, sorry!

ErwanDL commented 3 years ago

@luabud Would you guys be interested in a Proof-of-concept work/PR ? I can't guarantee that I can do it in the very near future, but if that is something that would help the team refine the scope or have an idea of what the feature could look like, it's something I would consider !

MarcSkovMadsen commented 3 years ago

Came looking for this after having a colleague show me what was possible in PyCharm.

P403n1x87 commented 2 years ago

@ErwanDL Would something like Austin VS Code be suitable to your needs?

ErwanDL commented 2 years ago

@P403n1x87 This does indeed look pretty good!

iDave2 commented 2 years ago

don't forget javascript profiling. maybe someone will go generic for us. ;)

iDave2 commented 2 years ago

(@iDave2, i think nodejs already has great profiling. spoke too soon! :)

brettcannon commented 2 years ago

What exactly are people looking for in terms of profile support? I think most profilers have their own file format (although I could be wrong), and so we would have to add custom support for one or more specific profilers. In which case what profiler do we target?

And even knowing what profiler people prefer, what are you looking for from a profiler? Table view of the profiler data? Embedded flamegraph view? Something else?

And what kind of profiling? CPU profiling? Memory profiling?

So even if we decide to try and tackle this (which is not at all what I'm saying; the question came up in a team meeting today about what "profiling" means to users), I am not even sure where we would start in order to get people what they are after.

P403n1x87 commented 2 years ago

I think this should be addressed at the editor level rather than at the extension one. What I would find beneficial is something like debugging support in VS Code, but for profilers. Extensions could then implement profiler adapters to bridge between the UI and the actual profiler data model.

What is VS Code support for profilers? Like the debugger views, profiler views could include "traditional" views, like a flame graph, a top table, a heat map/gutter API, a trace visualisation etc. I would expect many different profiling tools to need the same widgets or code annotation capabilities, so implementing those APIs would save extension developers time and perhaps provide a unified UX across runtimes.

brettcannon commented 2 years ago

I think this should be addressed at the editor level rather than at the extension one.

That's the ultimate solution, but this can be experimented with and developed in an extension before trying to push it into VS Code itself.

malekcellier commented 2 years ago

I stumbled upon this software: https://www.pyvmmonitor.com/ which has some neat features which could serve as inspiration..

Tim-Chard commented 1 year ago

Apparently, VS Code has a built-in profile viewer that uses a format that seem to be common for javascript. Are there any python profilers that use the same format?

P403n1x87 commented 1 year ago

Are there any python profilers that use the same format?

I think it's unlikely but it should be possible to convert e.g. Austin's output to it. I wonder what the UX would be though, given that that viewer is designed for javascript.

UP929312 commented 10 months ago

Been almost another year, and this is still open!

brettcannon commented 10 months ago

@UP929312 yes it is as we are still busy with fundamentals which impact most of the user base. On top of that, there isn't anything fundamental to profiling that requires it be embedded in this extension, thus we are not a hold-up beyond providing the time and effort to make it happen.

There is https://marketplace.visualstudio.com/items?itemName=p403n1x87.austin-vscode if you need a solution now.

I will also say that comments like this are a bit of a distraction that notify at least 17 people who are following this issue. Plus the tone isn't motivating to prioritize the work, so I do ask that people keep the issue comments on-topic and know that we are aware this is the most upvoted issue.