Skip to content

perf output should include line numbers #134023

Not planned
Not planned
@carl-mastrangelo

Description

@carl-mastrangelo

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

picnixz commented on May 15, 2025

@picnixz
Member
pablogsal

pablogsal commented on May 15, 2025

@pablogsal
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      perf output should include line numbers · Issue #134023 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant