Skip to content

Instantly share code, notes, and snippets.

@tazarov
Created December 14, 2024 07:48
Show Gist options
  • Save tazarov/78439acd5af15b42e2b080098c7b8676 to your computer and use it in GitHub Desktop.
Save tazarov/78439acd5af15b42e2b080098c7b8676 to your computer and use it in GitHub Desktop.

Generate flamegraphs for python processes. This is great for performance profiling.

Note: You need root privs for this to work. In docker you need the container to run with privileged=true

Live view:

py-spy top --pid 1

Create a flamegraph:

py-spy record -o profile.svg --pid 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment