You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CreateFromLinuxEventSources should produce SampledProfileTraceData from perf.data #2393
TraceLog.CreateFromLinuxEventSources converts perfcollect .trace.zip bundles (LTTng CLR events + perf CPU samples) to .etlx. The resulting .etlx contains the CLR events (MethodLoad, MethodDetails, etc.) but does not produce SampledProfileTraceData events from the perf CPU samples in perf.data.
This means consumers like dotnet-pgo create-mibc cannot build:
Call graph data (caller-callee edge weights from callstacks) needed for Pettis-Hansen method layout
Exclusive sample counts per method needed for ExclusiveWeight
Both are built by iterating SampledProfileTraceData events in Program.cs, which finds zero events from perfcollect traces.
Expected behavior
CreateFromLinuxEventSources should parse perf.data.txt (the text-format perf sample dump included in perfcollect's .trace.zip), resolve sample IPs against the CLR method load events to build managed symbol mappings, and emit SampledProfileTraceData events with resolved CallStack chains in the .etlx.
Current behavior
The perf CPU samples remain only in perf.data / perf.data.txt inside the zip. The .etlx contains only LTTng-originated CLR events. p.EventsInProcess.ByEventType<SampledProfileTraceData>() returns zero events.
Impact
dotnet-pgo create-mibc --method-layout pettishansen silently falls back to default ordering because CallWeights is empty. SPGO block attribution also misses the perf samples (only ETW-originated samples are attributed). See dotnet/runtime#125932 for the workaround we currently use (supplementary sample files).
Context
We're collecting PGO profiles for Nethermind using perfcollect on Linux. perfcollect captures ~9.6M CPU samples over 10 minutes alongside LTTng CLR events. The CLR events convert fine, but the CPU samples are lost in the .etlx conversion.
Thanks for opening this Ben {chmark} Adams (@benaadams). This is an interesting idea. I'm inclined though to say that we should look at what it would take to do this dotnet-trace collect-linux instead of using perfcollect. While perfcollect is far from dead, dotnet-trace collect-linux uses much more robust technology that allows us to do the kinds of things that you're talking about here. Instead of having to execute the perf tool and get it to emit the data in a way we can understand, dotnet-trace collect-linux uses a collection mechanism under the hood that calls directly into the perf_events subsystem and can gather both CPU/context-switch events from the kernel, as well as .NET events from the runtime, also through the perf_events subsystem, by way of user_events.
Bonus: dotnet-trace collect-linux still emits a nettrace file, so it should be relatively easy to get dotnet-pgo to consume it. We'd just need to teach dotnet-pgo to look for the CPU events in this trace (they use a different name since they get interpreted differently.)
My not-so-long-term hope is that tools like dotnet-trace collect-linux can take over much of the work from perfcollect, since it's much more capable and much less subject to distro variation issues.
I did have to build a custom libcoreclr.so built with LTTng tracepoint support to get the events to work (Runtime SDK ships dummy provider since dotnet/runtime#113876); so the route was a pita. However I also tried collect-linux and couldn't get it to do what I wanted; though might have been some rough edges that I could have fixed along lines of Lttng.
Longer term collect-linux I think is the right approach; shorter term is a fairly small patch to get the LTTng data to work with CreateFromLinuxEventSources and I could make a PR for that? (monkey patched it in our repo)
Activity
brianrob commentedon Mar 24, 2026
Thanks for opening this Ben {chmark} Adams (@benaadams). This is an interesting idea. I'm inclined though to say that we should look at what it would take to do this
dotnet-trace collect-linuxinstead of usingperfcollect. Whileperfcollectis far from dead,dotnet-trace collect-linuxuses much more robust technology that allows us to do the kinds of things that you're talking about here. Instead of having to execute theperftool and get it to emit the data in a way we can understand,dotnet-trace collect-linuxuses a collection mechanism under the hood that calls directly into theperf_eventssubsystem and can gather both CPU/context-switch events from the kernel, as well as .NET events from the runtime, also through theperf_eventssubsystem, by way ofuser_events.Bonus:
dotnet-trace collect-linuxstill emits a nettrace file, so it should be relatively easy to getdotnet-pgoto consume it. We'd just need to teachdotnet-pgoto look for the CPU events in this trace (they use a different name since they get interpreted differently.)My not-so-long-term hope is that tools like
dotnet-trace collect-linuxcan take over much of the work fromperfcollect, since it's much more capable and much less subject to distro variation issues.What do you think?
benaadams commentedon Mar 24, 2026
I did have to build a custom
libcoreclr.sobuilt with LTTng tracepoint support to get the events to work (Runtime SDK ships dummy provider since dotnet/runtime#113876); so the route was a pita. However I also triedcollect-linuxand couldn't get it to do what I wanted; though might have been some rough edges that I could have fixed along lines of Lttng.Longer term
collect-linuxI think is the right approach; shorter term is a fairly small patch to get the LTTng data to work with CreateFromLinuxEventSources and I could make a PR for that? (monkey patched it in our repo)brianrob commentedon Mar 27, 2026
Two parallel thoughts: