pablogsal · GitHub

Bug report

Bug description:

The thread filter removes nodes from other threads, but keeps aggregate value, self, and differential values on the remaining tree.

import threading
import time
def worker_a():
    time.sleep(1)
def worker_b():
    time.sleep(1)
threads = [threading.Thread(target=worker_a), threading.Thread(target=worker_b)]
for thread in threads:
    thread.start()
for thread in threads:
    thread.join()
python -m profiling.sampling run --flamegraph --all-threads -o profile.html demo.py

Select one worker in Thread Filter. The other branch disappears, but total samples and frame widths still include samples from all threads. Shared nodes cannot be filtered correctly because the report only stores thread membership, not per-thread counts.

CPython versions tested on:

3.16

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗