dotnet-pgo: SPGO fails with perfcollect LTTng traces — missing MethodDetails CTF mapping in TraceEvent
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
## 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: https://github.com/microsoft/perfview/pull/2392
Adds missing CTF mappings:
```csharp
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.
Contributor guide
Assessment
This issue has not been assessed yet.