Skip to content

Profiling native threads? #332

@SimonSapin

Description

@SimonSapin

Does py-spy record ignore threads that don’t contain any Python stack frame by default?

I have a Python program with a native extension (that happens to be written in Rust). That extension starts a thread (with Rust’s std::thread::spawn) to do some CPU-intensive work in parallel with other work. The child thread never runs a Python interpreter. The SVG output of the profiler is missing everything in the second thread. --native does show Rust stack frames, but only in the parent thread. Adding --threads adds the ID of the parent thread to the output but nothing else. Adding --idle doesn’t seem to change anything for this program.

When using py-spy dump --pid (at the right time) however, the stack of both threads is printed correctly.

Can I use py-spy to profile both threads?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions