Skip to content

Conversation

d4l3k
Copy link

@d4l3k d4l3k commented Sep 13, 2024

This modifies py-spy to use a sequential thread ID counter for each event and instead log a thread_name metadata field that includes the full thread ID as well as the thread name.

Perfetto doesn't support u64 thread ids so we lose thread information and the py-spy chrometrace format doesn't include thread names.

See google/perfetto#886 for more details

Test plan:

Run on a program that launches multiple processes and threads

py-spy record  --format chrometrace --nonblocking --output ~/test-pyspy.json.gz --subprocesses -- torchx run -s local_cwd dist.ddp -j2x2 -m hi

Test in both Perfetto and Chrome trace viewer

20240913_15h03m51s_grim
20240913_15h01m52s_grim

andrewjcg added a commit to andrewjcg/py-spy that referenced this pull request Nov 1, 2024
Summary:
This modifies py-spy to use a sequential thread ID counter for each
event and instead log a thread_name metadata field that includes the
full thread ID as well as the thread name.

Perfetto doesn't support u64 thread ids so we lose thread information
and the py-spy chrometrace format doesn't include thread names.

Upstream PR: benfred#681

Test Plan:
Launch a process that uses subprocesses and threads

```
buck2 run fbsource//third-party/py-spy:py-spy -- record  --format chrometrace --nonblocking --output ~/test-pyspy.json.gz --subprocesses -- torchx run -s local_cwd dist.ddp -j2x2 -m hi
```

 {F1866175191}

Perfetto:

{F1866171613}

Chrome Tracing:

 {F1866174988}

Reviewers: agallagher, kunalb, egl

Reviewed By: kunalb, egl

Differential Revision: https://phabricator.intern.facebook.com/D62666434
andrewjcg added a commit to andrewjcg/py-spy that referenced this pull request Nov 1, 2024
Summary:
This modifies py-spy to use a sequential thread ID counter for each
event and instead log a thread_name metadata field that includes the
full thread ID as well as the thread name.

Perfetto doesn't support u64 thread ids so we lose thread information
and the py-spy chrometrace format doesn't include thread names.

Upstream PR: benfred#681

Test Plan:
Launch a process that uses subprocesses and threads

```
buck2 run fbsource//third-party/py-spy:py-spy -- record  --format chrometrace --nonblocking --output ~/test-pyspy.json.gz --subprocesses -- torchx run -s local_cwd dist.ddp -j2x2 -m hi
```

 {F1866175191}

Perfetto:

{F1866171613}

Chrome Tracing:

 {F1866174988}

Reviewers: agallagher, kunalb, egl

Reviewed By: kunalb, egl

Differential Revision: https://phabricator.intern.facebook.com/D62666434
andrewjcg added a commit to andrewjcg/py-spy that referenced this pull request Mar 24, 2025
Summary:
This modifies py-spy to use a sequential thread ID counter for each
event and instead log a thread_name metadata field that includes the
full thread ID as well as the thread name.

Perfetto doesn't support u64 thread ids so we lose thread information
and the py-spy chrometrace format doesn't include thread names.

Upstream PR: benfred#681

Test Plan:
Launch a process that uses subprocesses and threads

```
buck2 run fbsource//third-party/py-spy:py-spy -- record  --format chrometrace --nonblocking --output ~/test-pyspy.json.gz --subprocesses -- torchx run -s local_cwd dist.ddp -j2x2 -m hi
```

 {F1866175191}

Perfetto:

{F1866171613}

Chrome Tracing:

 {F1866174988}

Reviewers: agallagher, kunalb, egl

Reviewed By: kunalb, egl

Differential Revision: https://phabricator.intern.facebook.com/D62666434
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

Successfully merging this pull request may close these issues.

1 participant