benfred / py-spy

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

when disable gil the result is not accuracy #610

Open zdyj3170101136 opened 10 months ago

zdyj3170101136 commented 10 months ago

even the process not running. the py-spy result would cost show too much samples:

[root@plat-sh-data-testing-common-pic-infer-demo001 test]# time py-spy record --format=raw --full-filenames  --nonblocking --threads --subprocesses --pid 18018
py-spy> Sampling process 100 times a second. Press Control-C to exit.

^C
py-spy> Stopped sampling because Control-C pressed
py-spy> Wrote raw flamegraph data to '18018-2023-09-05T17:29:05+08:00.txt'. Samples: 1092 Errors: 0
py-spy> You can use the flamegraph.pl script from https://github.com/brendangregg/flamegraph to generate a SVG

real    0m3.493s
user    0m0.603s
sys     0m0.843s
[root@plat-sh-data-testing-common-pic-infer-demo001 test]# time py-spy record --format=raw --full-filenames  --nonblocking --threads --subprocesses --pid 18018  --gil
py-spy> Sampling process 100 times a second. Press Control-C to exit.

^C
py-spy> Stopped sampling because Control-C pressed
py-spy> Wrote raw flamegraph data to '18018-2023-09-05T17:29:12+08:00.txt'. Samples: 0 Errors: 0
py-spy> You can use the flamegraph.pl script from https://github.com/brendangregg/flamegraph to generate a SVG

real    0m5.304s
user    0m0.095s
sys     0m0.139s