From 41d9c1cc0dca16743a54971930e81d60777af746 Mon Sep 17 00:00:00 2001 From: Eduardo Velarde <32459232+eduardo-vp@users.noreply.github.com> Date: Fri, 17 Jun 2022 10:56:23 -0700 Subject: [PATCH] Add event to capture min/max threads (#70063) Event ThreadPoolMinMaxThreads added. Parameters are: ushort MinWorkerThreads ushort MaxWorkerThreads ushort MinIOCompletionThreads ushort MaxIOCompletionThreads ushort ClrInstanceID It is fired in the ThreadPool constructor and in the SetMinThreads/SetMaxThreads functions. --- ...ource.PortableThreadPool.NativeSinks.CoreCLR.cs | 4 + src/coreclr/gc/env/etmdummy.h | 1 + src/coreclr/vm/ClrEtwAll.man | 35 +++++++- src/coreclr/vm/nativeeventsource.cpp | 10 +++ src/coreclr/vm/nativeeventsource.h | 1 + src/coreclr/vm/qcallentrypoints.cpp | 1 + ...meEventSource.PortableThreadPool.NativeSinks.cs | 17 ++++ .../NativeRuntimeEventSource.PortableThreadPool.cs | 39 +++++++++ .../src/System/Threading/PortableThreadPool.cs | 28 +++++++ .../tests/ThreadPoolTests.cs | 92 ++++++++++++++++++++++ ...ntSource.PortableThreadPool.NativeSinks.Mono.cs | 4 + src/mono/mono/component/event_pipe-stub.c | 20 +++++ src/mono/mono/component/event_pipe.c | 1 + src/mono/mono/component/event_pipe.h | 9 +++ src/mono/mono/eventpipe/ep-rt-mono.c | 18 +++++ src/mono/mono/eventpipe/ep-rt-mono.h | 8 ++ src/mono/mono/eventpipe/gen-eventing-event-inc.lst | 1 + src/mono/mono/metadata/icall-decl.h | 1 + src/mono/mono/metadata/icall-def.h | 1 + src/mono/mono/metadata/icall-eventpipe.c | 29 +++++++ 20 files changed, 319 insertions(+), 1 deletion(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs index f833134..cbf6e46 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs @@ -26,6 +26,10 @@ namespace System.Diagnostics.Tracing [NonEvent] [LibraryImport(RuntimeHelpers.QCall)] + internal static partial void LogThreadPoolMinMaxThreads(ushort MinWorkerThreads, ushort MaxWorkerThreads, ushort MinIOCompletionThreads, ushort MaxIOCompletionThreads, ushort ClrInstanceID); + + [NonEvent] + [LibraryImport(RuntimeHelpers.QCall)] internal static partial void LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, ushort ClrInstanceID); [NonEvent] diff --git a/src/coreclr/gc/env/etmdummy.h b/src/coreclr/gc/env/etmdummy.h index 5563721..575e306 100644 --- a/src/coreclr/gc/env/etmdummy.h +++ b/src/coreclr/gc/env/etmdummy.h @@ -78,6 +78,7 @@ #define FireEtwThreadPoolWorkerThreadAdjustmentAdjustment(AverageThroughput, NewWorkerThreadCount, Reason, ClrInstanceID) 0 #define FireEtwThreadPoolWorkerThreadAdjustmentStats(Duration, Throughput, ThreadWave, ThroughputWave, ThroughputErrorEstimate, AverageThroughputErrorEstimate, ThroughputRatio, Confidence, NewControlSetting, NewThreadWaveMagnitude, ClrInstanceID) 0 #define FireEtwThreadPoolWorkerThreadWait(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID) 0 +#define FireEtwThreadPoolMinMaxThreads (MinWorkerThreads, MaxWorkerThreads, MinIOCompletionThreads, MaxIOCompletionThreads, ClrInstanceID) 0 #define FireEtwThreadPoolWorkingThreadCount(Count, ClrInstanceID) 0 #define FireEtwThreadPoolEnqueue(WorkID, ClrInstanceID) 0 #define FireEtwThreadPoolDequeue(WorkID, ClrInstanceID) 0 diff --git a/src/coreclr/vm/ClrEtwAll.man b/src/coreclr/vm/ClrEtwAll.man index a55dec6..761d650 100644 --- a/src/coreclr/vm/ClrEtwAll.man +++ b/src/coreclr/vm/ClrEtwAll.man @@ -446,7 +446,13 @@ - + + + + + @@ -1579,6 +1585,24 @@ + +