Skip to content

dotnet-pgo: SPGO fails with perfcollect LTTng traces — missing MethodDetails CTF mapping in TraceEvent #125883

@benaadams

Description

@benaadams

Description

dotnet-pgo create-mibc --spgo fails when processing perfcollect .trace.zip files on Linux due to multiple missing CTF event mappings and a serialization issue in TraceEvent.

Issues Found

1. Missing MethodDetails CTF mapping

ClrTraceEventParser.EnumerateCtfEventMappings() doesn't include DotNETRuntime:MethodDetails (opcode 43, event ID 72). dotnet-pgo fails with "No MethodDetails".

2. Missing MethodILToNativeMap_V1 CTF mapping

The runtime fires MethodILToNativeMap_V1 but only MethodILToNativeMap (v0) has a CTF mapping. SPGO reports "Samples in managed code without native<->IL mappings" for all managed samples.

3. TraceLog drops ThreadID=0 events

CreateFromLinuxEventSources passes default TraceLogOptions where KeepAllEvents=false. CopyRawEvents drops events with ThreadID=0 when KeepAllEvents is false. LTTng CLR events from perfcollect have ThreadID=0, so MethodILToNativeMap events are silently dropped during .etlx serialization.

4. perfcollect missing tracepoints

perfcollect's default event set doesn't include TypeKeyword (BulkType), JittedMethodILToNativeMapKeyword (MethodILToNativeMap), and the LoaderKeyword array has a duplicate declaration that loses AssemblyLoad.

Fix

PerfView PR: microsoft/perfview#2392

Adds missing CTF mappings:

yield return new CtfEventMapping("DotNETRuntime:MethodDetails", 
    Parsers.ClrTraceEventParser.ProviderGuid, 43, 72, 0);
yield return new CtfEventMapping("DotNETRuntime:MethodILToNativeMap_V1",
    Parsers.ClrTraceEventParser.ProviderGuid, 87, 190, 0);

Note: MethodILToNativeMap_V1 uses version: 0 in the CTF mapping because TraceLog's template lookup is version-sensitive and only version 0 templates are registered.

The KeepAllEvents and perfcollect issues are separate fixes needed in TraceLog and perfcollect respectively.

After the PerfView fix ships as a new TraceEvent NuGet, dotnet-pgo should bump its TraceEventVersion.

Impact

This blocks SPGO on Linux when using perfcollect. The EventPipe .nettrace path works fine.

Workaround

Build TraceEvent from PerfView source with the fix applied. Use KeepAllEvents=true when calling CreateFromLinuxEventSources. Patch perfcollect to add missing tracepoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions