Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Failed to write flamegraph: I/O error: No stack counts found #321

Open
zmitchell opened this issue Nov 22, 2020 · 2 comments
Open

Comments

@zmitchell
Copy link

I'm running a program that has a concurrent.futures.ProcessPoolExecutor and I'm trying to diagnose what I think is a deadlock. I ran my program and then used ps -x to find the processes that belong to this process pool. I let it run and then hit Ctrl-C once I felt like it had run long enough (a few seconds), and it generated the same error regardless of whether I pointed it at the main process or one of the subprocesses.

❯ sudo py-spy record -o profile.svg --pid 52864
Password:
py-spy> Sampling process 100 times a second. Press Control-C to exit.

^C
py-spy> Stopped sampling because Control-C pressed
[2020-11-22T20:27:40.116852000Z ERROR inferno::flamegraph] No stack counts found
Error: Failed to write flamegraph: I/O error: No stack counts found

If I just write the raw profile data there's no error:

❯ sudo py-spy record -o procs_profile -f raw --pid 52864
Password:
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 'procs_profile'. Samples: 1999 Errors: 0
py-spy> You can use the flamegraph.pl script from https://github.com/brendangregg/flamegraph to generate a SVG

I went and downloaded Brendan Gregg's flamegraph program to see if there was an issue with inferno or with the profile data, and it also finds no stack counts:

❯ ./flamegraph.pl procs_profile >procs_profile.svg
ERROR: No stack counts found

System:

  • macOS 10.15.6
  • Python 3.8.5 installed via pyenv
  • py-spy 0.3.3 installed via pip

Any idea what's going on here? Is there something weird with my Python program, or is something preventing py-spy from reading the program's stack?

@benfred
Copy link
Owner

benfred commented Nov 22, 2020

That error usually means all the stack traces are filtered out - py-spy ignores stack traces that it thinks are idle , and if your program is deadlocked all the threads are probably idle.

Can you try with the 'py-spy dump' command instead ? That's probably the most useful way of diagnosing deadlocks. Alternatively you can pass the --idle flag to include idle traces with the record command

@zmitchell
Copy link
Author

Sure enough, py-spy dump shows a bunch of idle threads. Thanks! Would a different error message make sense in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants