python / python/cpython

API for outputting different formats from CPython sampling profiler

未关闭
#138,383 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

performance stdlib topic-profiling type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Feature or enhancement

Proposal:

CPython 3.15 has statistical sampling profiler which currently only supports outputting

  1. pstats https://docs.python.org/3.15/library/profile.html#pstats.Stats
  2. collapsed format for flamegraphs https://github.com/python/cpython/blob/8d5c3341c538cd1a4192ca8a1536b2eed4b98c69/Lib/profiling/sampling/stack_collector.py#L24

Since it's still an early stage for the sampling profiler, I thought it would be nice to initiate discussion around how to support multiple different formats from the profiler.

  1. pprof
  2. OTel

are the formats that could potentially be added, but supporting those from CPython would introduce dependencies that might complicate building/testing and distributing CPython.

I'd like to suggest that CPython has an interface to support 3rd party collectors. What do you think?

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/pre-pep-api-for-outputting-different-formats-from-cpython-sampling-profiler/103490

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读 Lib/profiling/sampling/stack_collector.py,以及 issue 中引用的现有 pstats 和 collapsed-format 处理逻辑。在为第三方 collector 提出接口之前,请先查看链接的 Discourse 讨论;要视为完成,必须具备一致同意的 API、受支持格式的边界,以及针对 CPython 构建、测试和分发限制的计划。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
performance
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。