Skip to content

Tachyon thread filtering keeps aggregate sample counts #154086

Description

@pablogsal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions