Skip to content

How to open a PerfCollect trace file using TraceEvent #1103

@adamsitnik

Description

@adamsitnik

I want to extend the dotnet trace tool with the possibility to convert trace files captured with PerfCollect to Speedscope file format. Just to be able to run perf investigation on Linux machine without copying the trace file to Windows and converting it to SpeedScope using PerfView.

I was hoping that it's going to be a matter of replacing this line of code with:

// before
var etlxFilePath = TraceLog.CreateFromEventPipeDataFile(fileToConvert, null, new TraceLogOptions() { ContinueOnError = continueOnError } );
// after
var etlxFilePath =
    fileToConvert.EndsWith(".trace.zip")
        ? TraceLog.CreateFromLttngTextDataFile(fileToConvert, null, new TraceLogOptions() { ContinueOnError = continueOnError })
        : TraceLog.CreateFromEventPipeDataFile(fileToConvert, null, new TraceLogOptions() { ContinueOnError = continueOnError });

However, for all the trace files I have I am getting following exception:

System.IO.EndOfStreamException: No CTF Information found in ZIP file.
   at Microsoft.Diagnostics.Tracing.CtfTraceEventSource..ctor(String fileName)
   at Microsoft.Diagnostics.Tracing.Etlx.TraceLog.CreateFromLttngTextDataFile(String filePath, String etlxFilePath, TraceLogOptions options)

The exception is thrown here:

if (firstChannel == null)
{
throw new EndOfStreamException("No CTF Information found in ZIP file.");
}

Since PerfView was able to open this trace file I've debugged it and it turned out that the exception is handled by the GetTraceLog method:

if (e is EndOfStreamException)
{
log.WriteLine("Warning: Trying to open CTF stream failed, no CTF (lttng) information");
}

and later ParallelLinuxPerfScriptStackSource is used to create a StackSource from the trace file. The problem is that ParallelLinuxPerfScriptStackSource is not part of the TraceEvent library so I can't use it outside of PerfView.

Have the LTTng trace file format changed and the throwing code should be updated?
Would it be OK to move ParallelLinuxPerfScriptStackSource to TraceEvent library? (I could send a PR ofc)

/cc @brianrob

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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