Tachyon’s `--diff-flamegraph` scales times in baseline run to duration of current run
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
As discussed with @pablogsal during EuroPython sprints:
Using this simple example script (flamegraph_demo.py):
import time
def main():
f_1()
f_2()
def f_1():
time.sleep(0.5) # change this to 1.5 in the second run
def f_2():
time.sleep(1)
main()
python -m profiling.sampling run --binary -o baseline.bin flamegraph_demo.py
vim flamegraph_demo.py # edit f_1 to sleep for 1.5 s
python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html flamegraph_demo.py
generates this diff flamegraph:
f_2 is unchanged between both runs, so the “Baseline Self” time should be equal to the “Current Self” and equal to 1 s (that it displays “1 ms” is covered in #154059); however, the baseline for all functions gets scaled with the ratio of total time in this run over total time of the previous run (in this case: 2.5 s / 1.5 s = 1.667).
I can imagine scenarios where this scaling is useful (e.g. when the baseline is generated on a different machine). However, in the common case of running baseline and diff on the same machine, this scaling means that a lot of unchanged functions get colour-coded, which distracts from the few functions that experienced a meaningful change.
CPython versions tested on:
3.15
Operating systems tested on:
macOS
Linked PRs
- gh-154082
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 profiling.sampling 入口开始,使用 flamegraph_demo.py 重现这些命令,并将 baseline.bin 与 diff.html 进行比较。跟踪 --diff-flamegraph 如何缩放 baseline 时间,并验证未发生变化的 f_2 的 baseline 和当前 self time 均为相等的 1 s,且没有不必要的颜色变化。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- performance
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100