Skip to content

Add --split-threads support to memray transform csv #996

Description

@mylee04

Is there an existing proposal for this?

  • I have searched the existing proposals

Is your feature request related to a problem?

memray transform csv includes tid and thread_name columns in its output schema, but the transform command currently retrieves allocation records with threads merged.

When allocations with the same stack occur on multiple threads, the exported record can therefore contain tid = -1 and thread_name = "merged thread" instead of preserving the original thread identities.

This makes the CSV output difficult to use for per-thread analysis of multi-threaded Python or C++ workloads. It also differs from reporters such as flamegraph and table, which expose a --split-threads option.

Describe the solution you'd like

Add a --split-threads option to memray transform, initially at least for the CSV format.

When enabled for CSV output, the command would retrieve allocation records with merge_threads=False and allow TransformReporter to process those records. The existing tid and thread_name columns would then preserve the original thread information.

The default behavior would remain unchanged.

Would you prefer --split-threads to be:

  1. supported for CSV only, since its schema already represents thread identity; or
  2. supported across transform formats, with Speedscope potentially emitting separate profiles for each thread?

I would be happy to implement the narrower CSV-only version first, including CLI integration tests and reporter tests, if that is the preferred scope.

Alternatives you considered

Users can inspect per-thread information through the HTML reporters, but those reports do not provide a convenient machine-readable export for downstream analysis.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions