Description
Feature or enhancement
Proposal:
When running Python 3.12 or later on Linux, it's possible to get profiling information on the process by running perf
. This is helpful, but the output only includes the function names on the stack. It would be useful if the line numbers were included, to see what part of the function is causing the majority of the CPU usage.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Activity
picnixz commentedon May 15, 2025
cc @pablogsal
pablogsal commentedon May 15, 2025
Unfortunately this is not possible. The way the Perf integration works is by jit compiling a piece of code and assigning that to a function. We then create a mapping between that jit compiled function and a string representing the name. This happens when the function is first entered. We cannot update this mapping once created so we cannot tell Perf of the line number that the function is in. Even if we could that would be very expensive unfortunately because we would need to update the file with the relationship mapping every time something changes line number. It also wouldn't work with threads.