Title: Allow the linux perf profiler to see Python calls · Issue #96143 · python/cpython · GitHub
Open Graph Title: Allow the linux perf profiler to see Python calls · Issue #96143 · python/cpython
X Title: Allow the linux perf profiler to see Python calls · Issue #96143 · python/cpython
Description: The linux perf profiler is a very powerful tool but unfortunately is not able to see Python calls (only the C stack) and therefore it cannot be used (neither its very complete ecosystem) to profile Python applications and extensions. Tur...
Open Graph Description: The linux perf profiler is a very powerful tool but unfortunately is not able to see Python calls (only the C stack) and therefore it cannot be used (neither its very complete ecosystem) to profile...
X Description: The linux perf profiler is a very powerful tool but unfortunately is not able to see Python calls (only the C stack) and therefore it cannot be used (neither its very complete ecosystem) to profile...
Opengraph URL: https://github.com/python/cpython/issues/96143
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow the linux perf profiler to see Python calls","articleBody":"The linux `perf` profiler is a very powerful tool but unfortunately is not able to see Python calls (only the C stack) and therefore it cannot be used (neither its very complete ecosystem) to profile Python applications and extensions. \r\n\r\nTurns out that node and the [JVM](https://github.com/jvm-profiling-tools/perf-map-agent/blob/master/README.md) have developed a way to leverage the `perf` profiler for the Java and javascript frames. They use their JIT compilers to generate a unique area in memory where they place assembly code that in turn calls the frame evaluator function. This JIT compiled areas are unique per function/code object. They use the perf maps (perf allows to place a map in `/temp/perf-PID.map` with information mapping the JIT-ed areas to a string that identifies them and this allows perf to map java/javascript names to the JIT-ed areas, basically showing the non-native function names on the stack.\r\n\r\nWe can do a simple version of this idea in Python by using a very simple JIT compiler that compiles a assembly template that is the used to jump to `PyEval_EvalFrameDefault` and we can place the code names and filenames in the special `perf` file. This allows perf to see Python calls as well:\r\n\r\n\r\n\r\nAnd this works with all the tools in the perf ecosystem, like flamegraphs:\r\n\r\n\r\n\r\n\r\nSee also:\r\nhttps://www.brendangregg.com/Slides/KernelRecipes_Perf_Events.pdf\r\n","author":{"url":"https://github.com/pablogsal","@type":"Person","name":"pablogsal"},"datePublished":"2022-08-20T17:32:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/96143/cpython/issues/96143"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d3c72e7d-4000-e58c-5625-87fc64b74ccd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE90:B07CA:229186:30BC74:696A0659 |
| html-safe-nonce | 295931b670a5a9a198ba7f157d1432158d8c5586b8c34bd84b0fa4766ebf98f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTkwOkIwN0NBOjIyOTE4NjozMEJDNzQ6Njk2QTA2NTkiLCJ2aXNpdG9yX2lkIjoiNjM5NzI4MDQ5MTI0ODY4MjU4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8e173ed3ea9ba60f58a121c0308b46f713fe953c489e1039b64f29fb0b36e68a |
| hovercard-subject-tag | issue:1345237861 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/96143/issue_layout |
| twitter:image | https://opengraph.githubassets.com/03f2e63a058eb9962ea67ffafea4654e91845402c5dd55b3a19341547e6f96d1/python/cpython/issues/96143 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/03f2e63a058eb9962ea67ffafea4654e91845402c5dd55b3a19341547e6f96d1/python/cpython/issues/96143 |
| og:image:alt | The linux perf profiler is a very powerful tool but unfortunately is not able to see Python calls (only the C stack) and therefore it cannot be used (neither its very complete ecosystem) to profile... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pablogsal |
| hostname | github.com |
| expected-hostname | github.com |
| None | 578c119ff0247c8b2f2491fbf4fc0395cdf909d4df66598cebdc96ddfc4418dc |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 671c2f67171dbced24284331f3133a613d08c366 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width