Sampling profiler fails to display user-defined function in IDLE when started with the run command
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
This is my simple test running IDLE at profiler startup (sudo as I'm running on a Mac, YMMV):
sudo -E ./python.exe -m profiling.sampling run -a --realtime-stats -d 99999 --live -m idlelib
As expected, I can also attach to a running IDLE session:
sudo -E ./python.exe -m profiling.sampling attach -a --realtime-stats -d 99999 --live <PID>
The two versions display things differently. If I attach to a running IDLE, define fib(), then call it with a large n (say, 200), it will run for a while before returning a result. I can see the recursive calls to fib in the display.
If I use the run command instead, I never see fib show in the display. Instead, I see something like this:
It appears all the samples in fib are credited to Misc.mainloop. I know the function is executing, given that small-n calls return quickly with the correct result, but shouldn't fib show up in the display when called with a large value for n if I use the run command to start IDLE?
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
按照描述使用递归的 fib() 调用,复现针对 idlelib 的 profiling.sampling run 命令与 attach 命令之间的差异。首先跟踪 profiling.sampling 如何处理 run 路径,并将其显示的样本与 attach 进行比较;当 fib 等用户定义的函数出现在 run 显示中,而不是被归因于 Misc.mainloop 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools, performance
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100