Minimal self-contained repro for microsoft/perfview#2385 — missing AllocationSampled (EventID 303) typed schema in Microsoft.Diagnostics.Tracing.TraceEvent 3.1.30.
- .NET 10+ SDK and runtime —
AllocationSampledis never emitted on .NET 9 or earlier, regardless of keywords. Check withdotnet --version. - No other dependencies; NuGet packages are restored automatically on first run.
cd AllocationSampledRepro
dotnet runThe program runs in three phases:
-
Capture — instruments itself via
DiagnosticsClientwithAllocationSamplingKeyword = 0x80000000000, allocates 200 000 strings to guarantee sampled events, and saves a temporary.nettracefile. -
Native TraceEvent API (broken) — opens the trace with
EventPipeEventSourceand reads EventID 303 viasource.Dynamic.All.PayloadNamesisnull,PayloadByNamereturnsnull, andsource.Clr.Allreceives zero events for EventID 303 — confirming the event is not routed throughClrTraceEventParserat all. -
Raw byte workaround (works) — re-opens the same trace and decodes each event's binary payload directly using
data.EventData()+data.PointerSize, recoveringTypeNameandObjectSizesuccessfully.
══ Native TraceEvent API (broken) ═════════════════════════════════════
PayloadNames: <empty array>
PayloadByName("TypeName"): <null>
PayloadByName("ObjectSize"): <null>
PayloadValue(0): <<<EXCEPTION_DURING_VALUE_LOOKUP IndexOutOfRangeException>>>
source.Clr.All hits for EventID 303: 0 (0 = not routed through ClrTraceEventParser)
source.Dynamic.All hits for EventID 303: 78
══ Raw EventData() workaround (works) ══════════════════════════════════
[1] TypeName=System.Reflection.RuntimeMethodInfo ObjectSize=104 bytes
...
Total events decoded via raw bytes: 100% (N / N)
CI: PASS
[1] Issue confirmed — PayloadNames empty, Clr.All: 0 hits for EventID 303
[2] Workaround confirmed — raw bytes decoded 100% of sampled events
(Event count and types vary per run; the CI workflow verifies both assertions on every push.)
Decoded from the dotnet/runtime reference consumer
(src/tests/tracing/eventpipe/randomizedallocationsampling/manual/AllocationProfiler/Program.cs):
AllocationKind win:UInt32 4 bytes
ClrInstanceID win:UInt16 2 bytes
TypeID win:Pointer 4 or 8 bytes (pointer-sized)
TypeName win:UnicodeString variable (null-terminated UTF-16LE)
Address win:Pointer 4 or 8 bytes (pointer-sized)
ObjectSize win:UInt64 8 bytes
SampledByteOffset win:UInt64 8 bytes
Pointer size is read from TraceEvent.PointerSize.
- dotnet/runtime#104955 — PR that introduced
AllocationSampledin .NET 10 ClrEtwAll.man— canonical ETW manifest defining EventID 303AllocationProfiler/Program.cs— dotnet/runtime reference consumer using raw byte parsingClrTraceEventParser.cs.base— file requiring the new typed event definition