New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-96143: Allow Linux perf profiler to see Python calls #96123
Conversation
9b009f2
to
439ef28
Compare
You can use preprocesor macros if you name the file |
Hummm, not sure I follow, could you maybe show me an example of what we can achieve with this? |
You can have multiple implementations in the same file:
|
df2a40d
to
dda9e04
Compare
f38dfc2
to
22fc892
Compare
a2f4182
to
1b35ed3
Compare
Why did you add a Windows build file? How about we do not define |
Then we need to add more ifdef every place is used but that works as well for sure |
I have added some user-facing docs. Feel free to push to my PR if you want to add something |
they now match the current code.
Two thoughts have been running around in my mind:
(1) We've got the command line flag and sys API, but what about just enabling this system wide or at least task/job wide within a container? An environment variable that turns it on would make that easy without plumbing options through. PYTHONPERFSUPPORT=1
as another equivalent to -Xperf
? That's usually done in initconfig.c alongside the -X processing I believe.
Second: multiprocessing spawn start method. If the -Xperf
flag was passed to the parent process I assume the "spawn" method should also pass that to its children.
I think (1) makes sense and is indeed coherent with how we handle some of the other options like Regarding (2) I am not that sure. We don't do this for the rest of the flags that we pass around and you can achieve the same with the environment variable if you want. In any case, as that would require some tests I would prefer to do that in a separate PR as this is already gigantic |
I implemented the environment variable and solved a bunch of conflicts. Please check it out when you have time. I also had to solve a bunch of conflicts. @gpshead if you are ok with the current status I would like us to land if everything looks good as the size of the PR is already attracting a bunch of merge conflicts in the build system, clinic and other files. |
Ah wait, I need to document the environment variable. Will push a commit for that soon. |
Done |
@erlend-aasland has mentioned that he was a bunch of docs improvements that he will do in a separate PR. |
My comments are easy to address things that don't need further review - minor edits or added note/todo comments to our future selves.
Agreed that the docs can use some polishing up but all the important bits are there to seed that future work, thanks for writing them!
Thanks for taking on adding this feature! I expect we'll see how a backport fares internally.
Damn, @miss-islington has landed the PR without waiting for the CI to build the last commit I pushed so I created #96433. |
Thanks, everyone for the fantastic reviews and for helping to get this feature ready You all rock |
@erlend-aasland You can make the doc improvement PR after #96433 lands. |
Thanks for all for pushing for better interoperability with |
Nice feature! There is a typo in sys.deactivate_stack_trampoline() docstring: "Dectivate the perf profiler trampoline": Deactivate. In the doc,
The second command can be replaced with |
See #96445 :) |
Automerge-Triggered-By: GH:pablogsal