Skip to content

[IPC Protocol][dotnet-gcdump] Add non-lossy dotnet-gcdump mode#5886

Open
mdh1418 wants to merge 5 commits into
dotnet:mainfrom
mdh1418:add_non_lossy_dotnet_gcdump_mode
Open

[IPC Protocol][dotnet-gcdump] Add non-lossy dotnet-gcdump mode#5886
mdh1418 wants to merge 5 commits into
dotnet:mainfrom
mdh1418:add_non_lossy_dotnet_gcdump_mode

Conversation

@mdh1418

@mdh1418 mdh1418 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Diagnostics counterpart to dotnet/runtime#129457 for fixing #2404

This PR proposes a new CollectTracing command CollectTracing6 that exposes a new sessionBufferMode configuration option to specify how an IPC Streaming EventPipe Session using buffers should handle events when buffers are full.

0 - Drop (default, pre-existing behavior)
1 - Block (non-lossy, parks producer threads until buffer space is available)

Additionally, this PR introduces serializing for CollectTracing5 (non-UserEvents) and CollectTracing6, and adds a new --non-lossy option to dotnet-gcdump collect to leverage the new non-lossy mode.

CollectTracing6 (0x0207) extends CollectTracing5 with a trailing sessionBufferMode field on the streaming-session payload: 0 = Drop (lossy circular buffer), 1 = Block (non-lossy; producers block until the reader drains). The user_events payload is unchanged. Available in .NET 11.0 and later.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new non-lossy (Block) buffering mode for IPC streaming EventPipe sessions (CollectTracing6) and wires it into dotnet-gcdump collect via a new --non-lossy flag to improve reliability when collecting heap snapshots under high event volume.

Changes:

  • Extend Microsoft.Diagnostics.NETCore.Client to support CollectTracing5/6 payload serialization (event filters + buffering mode) and command selection.
  • Add a --non-lossy option to dotnet-gcdump collect and plumb it through to StartEventPipeSession buffering configuration.
  • Update IPC protocol documentation to describe CollectTracing6 and its sessionBufferMode field.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Tools/dotnet-gcdump/DotNetHeapDump/EventPipeDotNetHeapDumper.cs Adds a nonLossy path and uses EventPipeSessionConfiguration with EventPipeBufferingMode.Block.
src/Tools/dotnet-gcdump/CommandLine/ReportCommandHandler.cs Updates call into TryCollectMemoryGraph for the new signature.
src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs Adds --non-lossy, propagates it to collection, and prints a helpful error on unsupported runtimes.
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcCommands.cs Adds CollectTracing5/6 command IDs.
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSessionConfiguration.cs Introduces buffering mode + V5/V6 serialization (including event filters).
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs Selects CollectTracing5/6 based on filters/buffering mode and adds filter detection.
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeProvider.cs Adds per-provider Event ID filtering support via EventPipeProviderEventFilter.
documentation/design-docs/ipc-protocol.md Documents CollectTracing6 and the new sessionBufferMode field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeProvider.cs Outdated
Comment thread documentation/design-docs/ipc-protocol.md
mdh1418 and others added 4 commits June 17, 2026 17:49
EventPipeProviderEventFilter exposes the per-provider Event ID allow/deny list that CollectTracing5 introduced (available on .NET 10+). It is opted into via a new EventPipeProvider constructor overload, leaving the original constructor signature intact for binary compatibility. A session whose providers carry a filter is started with CollectTracing5 via SerializeV5, which adds the session-type wire prefix. enable+ids is an allow-list, !enable+ids a deny-list, and !enable+empty (the default for a null filter) allows all events.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EventPipeBufferingMode {Default, Block} selects the session buffering mode, exposed through a new EventPipeSessionConfiguration constructor overload (the original constructor signatures are left intact for binary compatibility). It is serialized by SerializeV6 (the CollectTracing5 streaming payload plus a trailing sessionBufferMode). A session with a non-default buffering mode is started with CollectTracing6 (.NET 11+); Block requests non-lossy collection in which the runtime blocks producers rather than dropping events when the buffer fills.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
collect gains --non-lossy, which starts the GCHeapSnapshot session in Block buffering mode so the runtime blocks producers instead of dropping events when the buffer fills. This produces a complete gcdump on large heaps, at the cost of slower collection, and requires a target runtime that supports CollectTracing6. When the target is too old, collect catches UnsupportedCommandException and reports that non-lossy requires .NET 11+, suggesting a plain (lossy) collection instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Covers which CollectTracing command (2 through 6) is chosen for a given EventPipeSessionConfiguration, and the CollectTracing5/6 payload layout: the IpcStream session-type prefix, the per-provider event filter (allow-list, deny-list, and the null = allow-all encoding), and the trailing buffering mode that distinguishes V6 from V5. EventPipeSession.CreateStartMessage is made internal so the selection logic is testable via InternalsVisibleTo.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mdh1418 mdh1418 force-pushed the add_non_lossy_dotnet_gcdump_mode branch from fd1f00f to 40be140 Compare June 17, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants