From f131b039651823170f6e76ecb6e2f16de501ea71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire?= Date: Fri, 10 May 2024 23:06:42 -0400 Subject: [PATCH 1/5] dotnet-trace: document waithandle keyword This keyword was added for .NET 9+ --- docs/core/diagnostics/dotnet-trace.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/core/diagnostics/dotnet-trace.md b/docs/core/diagnostics/dotnet-trace.md index 6f9eb564ef20c..423f1190dba8d 100644 --- a/docs/core/diagnostics/dotnet-trace.md +++ b/docs/core/diagnostics/dotnet-trace.md @@ -153,6 +153,7 @@ dotnet-trace collect [--buffersize ] [--clreventlevel ] [-- | `compilationdiagnostic` | `0x2000000000` | | `methoddiagnostic` | `0x4000000000` | | `typediagnostic` | `0x8000000000` | + | `waithandle` | `0x40000000000` | You can read about the CLR provider more in detail on the [.NET runtime provider reference documentation](../../fundamentals/diagnostics/runtime-events.md). From 14544d7ce42a99994ad6fcf416ad89fb52681d77 Mon Sep 17 00:00:00 2001 From: verdie-g Date: Mon, 27 May 2024 20:58:19 -0400 Subject: [PATCH 2/5] Document events --- .../diagnostics/runtime-events.md | 3 ++ .../diagnostics/runtime-wait-handle-events.md | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 docs/fundamentals/diagnostics/runtime-wait-handle-events.md diff --git a/docs/fundamentals/diagnostics/runtime-events.md b/docs/fundamentals/diagnostics/runtime-events.md index f39bb6e4d65f6..4e049923e6f98 100644 --- a/docs/fundamentals/diagnostics/runtime-events.md +++ b/docs/fundamentals/diagnostics/runtime-events.md @@ -43,3 +43,6 @@ These events collect information about the type system. [Tiered compilation events](runtime-tiered-compilation-events.md)\ These events collect information about tiered compilation. + +[Wait handle events](runtine-wait-handle-events.md)\ +These events collect information about wait handles. They help to diagnostic thread pool starvations. \ No newline at end of file diff --git a/docs/fundamentals/diagnostics/runtime-wait-handle-events.md b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md new file mode 100644 index 0000000000000..1814582656b6d --- /dev/null +++ b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md @@ -0,0 +1,54 @@ +--- +title: "Wait handle runtime events" +description: See ETW events that collect information specific to the wait handles. +ms.date: "05/27/2024" +helpviewer_keywords: + - "wait handle events (CoreCLR)" + - "ETW, EventPipe, LTTng wait handle events (CoreCLR)" +--- + +# .NET runtime wait handle events + +These runtime events capture information about wait handles. They can be useful to investigate thread pool starvation issues. For more information about how to use these events for diagnostic purposes, see [logging and tracing .NET applications](../../core/diagnostics/logging-tracing.md) + +## WaitHandleWaitStart event + +This event is emitted at the start of a wait operation on a wait handle. Here is a non-exhaustive list of managed method that could emit this event: +- `Monitor.Wait` +- `Monitor.Enter` or the C# lock keyword +- `ManualResetEvent.WaitOne` +- `Task.Wait` + +|Keyword for raising the event|Level| +|-----------------------------------|-----------| +|`WaitHandleKeyword` (0x40000000000)|Verbose (5)| + +The following table shows event information. + +|Event|Event ID|Raised when| +|-----------|--------------|-----------------| +|`WaitHandleWaitStart`|301|A wait starts.| + +|Field name|Data type|Description| +|----------------|---------------|-----------------| +|`WaitSource`|`win:UInt8`|`0x0` - Other sources.

`0x1` - The wait originated from managed code through the `Monitor.Wait` method.| +|`AssociatedObjectID`|`win:Pointer`|Address of the associated object (e.g. address of `obj` in the code `lock(obj) {}`).| +|`ClrInstanceID`|`win:Pointer`|Unique ID for the instance of CoreCLR.| + +## WaitHandleWaitStop event + +This event is emitted at the end of a wait operation on a wait handle. + +|Keyword for raising the event|Level| +|-----------------------------------|-----------| +|`WaitHandleKeyword` (0x40000000000)|Verbose (5)| + +The following table shows event information. + +|Event|Event ID|Raised when| +|-----------|--------------|-----------------| +|`WaitHandleWaitStop`|302|A wait stops.| + +|Field name|Data type|Description| +|----------------|---------------|-----------------| +|`ClrInstanceID`|`win:Pointer`|Unique ID for the instance of CoreCLR.| \ No newline at end of file From 30cd953de8d3b8f1b6c2600e81f5b0a4be6c270a Mon Sep 17 00:00:00 2001 From: verdie-g Date: Mon, 27 May 2024 21:05:20 -0400 Subject: [PATCH 3/5] Fix ClrInstanceID type --- docs/fundamentals/diagnostics/runtime-wait-handle-events.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/diagnostics/runtime-wait-handle-events.md b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md index 1814582656b6d..1c30fd6f20981 100644 --- a/docs/fundamentals/diagnostics/runtime-wait-handle-events.md +++ b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md @@ -33,7 +33,7 @@ The following table shows event information. |----------------|---------------|-----------------| |`WaitSource`|`win:UInt8`|`0x0` - Other sources.

`0x1` - The wait originated from managed code through the `Monitor.Wait` method.| |`AssociatedObjectID`|`win:Pointer`|Address of the associated object (e.g. address of `obj` in the code `lock(obj) {}`).| -|`ClrInstanceID`|`win:Pointer`|Unique ID for the instance of CoreCLR.| +|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.| ## WaitHandleWaitStop event @@ -51,4 +51,4 @@ The following table shows event information. |Field name|Data type|Description| |----------------|---------------|-----------------| -|`ClrInstanceID`|`win:Pointer`|Unique ID for the instance of CoreCLR.| \ No newline at end of file +|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.| \ No newline at end of file From b760c1d58308ec887d1557a118d994709656d270 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 16 Oct 2024 14:42:05 -0400 Subject: [PATCH 4/5] Update docs/fundamentals/diagnostics/runtime-events.md --- docs/fundamentals/diagnostics/runtime-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/diagnostics/runtime-events.md b/docs/fundamentals/diagnostics/runtime-events.md index 4e049923e6f98..7d649a05422d4 100644 --- a/docs/fundamentals/diagnostics/runtime-events.md +++ b/docs/fundamentals/diagnostics/runtime-events.md @@ -44,5 +44,5 @@ These events collect information about the type system. [Tiered compilation events](runtime-tiered-compilation-events.md)\ These events collect information about tiered compilation. -[Wait handle events](runtine-wait-handle-events.md)\ +[Wait handle events](runtime-wait-handle-events.md)\ These events collect information about wait handles. They help to diagnostic thread pool starvations. \ No newline at end of file From ef43d939356f44c35ce0ca4a181d26844c49da3d Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 16 Oct 2024 14:50:49 -0400 Subject: [PATCH 5/5] Apply suggestions from code review --- docs/fundamentals/diagnostics/runtime-events.md | 2 +- docs/fundamentals/diagnostics/runtime-wait-handle-events.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/diagnostics/runtime-events.md b/docs/fundamentals/diagnostics/runtime-events.md index 7d649a05422d4..d086fc15d88ab 100644 --- a/docs/fundamentals/diagnostics/runtime-events.md +++ b/docs/fundamentals/diagnostics/runtime-events.md @@ -45,4 +45,4 @@ These events collect information about the type system. These events collect information about tiered compilation. [Wait handle events](runtime-wait-handle-events.md)\ -These events collect information about wait handles. They help to diagnostic thread pool starvations. \ No newline at end of file +These events collect information about wait handles. They help to diagnostic thread pool starvations. diff --git a/docs/fundamentals/diagnostics/runtime-wait-handle-events.md b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md index 1c30fd6f20981..2820c22fcbbed 100644 --- a/docs/fundamentals/diagnostics/runtime-wait-handle-events.md +++ b/docs/fundamentals/diagnostics/runtime-wait-handle-events.md @@ -14,6 +14,7 @@ These runtime events capture information about wait handles. They can be useful ## WaitHandleWaitStart event This event is emitted at the start of a wait operation on a wait handle. Here is a non-exhaustive list of managed method that could emit this event: + - `Monitor.Wait` - `Monitor.Enter` or the C# lock keyword - `ManualResetEvent.WaitOne` @@ -51,4 +52,4 @@ The following table shows event information. |Field name|Data type|Description| |----------------|---------------|-----------------| -|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.| \ No newline at end of file +|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.|