benfred / py-spy

Sampling profiler for Python programs
MIT License
12.14k stars 400 forks source link

py-spy cost too much cpu when enable --gil #609

Open zdyj3170101136 opened 10 months ago

zdyj3170101136 commented 10 months ago

when i use py-spy, i find it cost too much cpu. the process only cost cpu less than 1%, but py-spy cost cpu more than 20%.

 py-spy  record --nonblocking  --format raw --threads --pid 18024

python version:

[root@plat-sh-data-testing-common-pic-infer-demo001 test]# /proc/18024/exe -V
Python 3.7.7

截屏2023-09-05 下午4 00 35

zdyj3170101136 commented 10 months ago

@benfred

zdyj3170101136 commented 10 months ago

here is flamegraph of perf record -g py-spy:

a

zdyj3170101136 commented 10 months ago

when i use --gil, the issue disapppear.