From 49c270aa2fda65f4504a799c899300ee808ef82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Verdier?= Date: Thu, 30 Nov 2023 10:21:42 -0500 Subject: [PATCH] Only emit event in native code --- ...entSource.Threading.NativeSinks.CoreCLR.cs | 11 ----- .../Runtime/disabledruntimeeventinternal.cpp | 8 ---- .../Runtime/runtimeeventinternal.cpp | 10 ----- ...tSource.Threading.NativeSinks.NativeAot.cs | 16 ------- .../src/System/Runtime/RuntimeImports.cs | 11 ----- .../src/System/Threading/Condition.cs | 21 +-------- .../src/System/Threading/Monitor.NativeAot.cs | 2 +- src/coreclr/scripts/genRuntimeEventSources.py | 6 ++- src/coreclr/vm/nativeeventsource.cpp | 20 --------- src/coreclr/vm/nativeeventsource.h | 2 - src/coreclr/vm/qcallentrypoints.cpp | 2 - .../TestsManifestNegative.cs | 4 +- .../src/Resources/Strings.resx | 2 +- .../System/Diagnostics/Tracing/EventSource.cs | 8 +--- ...untimeEventSource.Threading.NativeSinks.cs | 26 ----------- .../NativeRuntimeEventSource.Threading.cs | 45 ------------------- .../src/System/Threading/WaitHandle.cs | 16 ------- ...eEventSource.Threading.NativeSinks.Mono.cs | 11 ----- src/mono/mono/component/event_pipe-stub.c | 28 ------------ src/mono/mono/component/event_pipe.c | 4 +- src/mono/mono/component/event_pipe.h | 12 ----- .../eventpipe/ep-rt-mono-runtime-provider.c | 24 ---------- src/mono/mono/eventpipe/ep-rt-mono.h | 10 ----- .../mono/eventpipe/gen-eventing-event-inc.lst | 2 - src/mono/mono/metadata/icall-decl.h | 2 - src/mono/mono/metadata/icall-def.h | 2 - src/mono/mono/metadata/icall-eventpipe.c | 40 ----------------- 27 files changed, 13 insertions(+), 332 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.CoreCLR.cs index 4ff69053c0a413..511476e789fe2a 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.CoreCLR.cs @@ -97,16 +97,5 @@ private static partial void LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, ushort ClrInstanceID); - - [NonEvent] - [LibraryImport(RuntimeHelpers.QCall)] - private static partial void LogWaitHandleWaitStart( - WaitHandleWaitSourceMap WaitSource, - IntPtr AssociatedObjectID, - ushort ClrInstanceID); - - [NonEvent] - [LibraryImport(RuntimeHelpers.QCall)] - private static partial void LogWaitHandleWaitStop(ushort ClrInstanceID); } } diff --git a/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp b/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp index 17a8010ec1cde8..6b3e76f6dde1c6 100644 --- a/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp +++ b/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp @@ -84,12 +84,4 @@ EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown( { } -EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogWaitHandleWaitStart(uint8_t WaitSource, intptr_t AssociatedObjectID, uint16_t ClrInstanceID) -{ -} - -EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogWaitHandleWaitStop(uint16_t ClrInstanceID) -{ -} - #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp b/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp index 7b4afafd8671f3..b346ef52d3351c 100644 --- a/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp +++ b/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp @@ -100,14 +100,4 @@ EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown( GetClrInstanceId()); } -EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogWaitHandleWaitStart(uint8_t WaitSource, intptr_t AssociatedObjectID, uint16_t ClrInstanceID) -{ - FireEtwWaitHandleWaitStart(WaitSource, reinterpret_cast(AssociatedObjectID), ClrInstanceID); -} - -EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogWaitHandleWaitStop(uint16_t ClrInstanceID) -{ - FireEtwWaitHandleWaitStop(ClrInstanceID); -} - #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs index 7f214ab0b2bb65..69e0dbadf06f37 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs @@ -22,7 +22,6 @@ public static partial class Keywords public const EventKeywords ContentionKeyword = (EventKeywords)0x4000; public const EventKeywords ThreadingKeyword = (EventKeywords)0x10000; public const EventKeywords ThreadTransferKeyword = (EventKeywords)0x80000000; - public const EventKeywords WaitHandleKeyword = (EventKeywords)0x40000000000; } [NonEvent] @@ -133,20 +132,5 @@ internal static void LogThreadPoolIOPack( { RuntimeImports.NativeRuntimeEventSource_LogThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID); } - - [NonEvent] - internal static void LogWaitHandleWaitStart( - WaitHandleWaitSourceMap WaitSource, - IntPtr AssociatedObjectID, - ushort ClrInstanceID) - { - RuntimeImports.NativeRuntimeEventSource_LogWaitHandleWaitStart((byte)WaitSource, AssociatedObjectID, ClrInstanceID); - } - - [NonEvent] - internal static void LogWaitHandleWaitStop(ushort ClrInstanceID) - { - RuntimeImports.NativeRuntimeEventSource_LogWaitHandleWaitStop(ClrInstanceID); - } } } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index 33dbf18e3d8d93..733fdece37f1ce 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -826,17 +826,6 @@ internal static partial void NativeRuntimeEventSource_LogThreadPoolIOPack( [LibraryImport(RuntimeLibrary)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] internal static unsafe partial void NativeRuntimeEventSource_LogExceptionThrown(char* exceptionTypeName, char* exceptionMessage, IntPtr faultingIP, long hresult); - - [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( - byte WaitSource, - IntPtr AssociatedObjectID, - ushort ClrInstanceID); - - [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStop(ushort ClrInstanceID); #endif // FEATURE_PERFTRACING // diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs index 4d40832ea14734..66636d7f782608 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs @@ -3,9 +3,8 @@ #pragma warning disable 0420 //passing volatile fields by ref + using System.Diagnostics; -using System.Diagnostics.Tracing; -using System.Runtime.CompilerServices; namespace System.Threading { @@ -98,7 +97,7 @@ public Condition(Lock @lock) public bool Wait(TimeSpan timeout) => Wait(WaitHandle.ToTimeoutMilliseconds(timeout)); - public unsafe bool Wait(int millisecondsTimeout, object? associatedObject = null) + public unsafe bool Wait(int millisecondsTimeout) { ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeout, -1); @@ -108,17 +107,6 @@ public unsafe bool Wait(int millisecondsTimeout, object? associatedObject = null Waiter waiter = GetWaiterForCurrentThread(); AddWaiter(waiter); - bool isWaitHandleKeywordEnabled = NativeRuntimeEventSource.Log.IsEnabled( - EventLevel.Verbose, - NativeRuntimeEventSource.Keywords.WaitHandleKeyword); - if (isWaitHandleKeywordEnabled) - { - associatedObject ??= this; - NativeRuntimeEventSource.Log.WaitHandleWaitStart( - NativeRuntimeEventSource.WaitHandleWaitSourceMap.MonitorWait, - *(nint*)Unsafe.AsPointer(ref associatedObject)); - } - uint recursionCount = _lock.ExitAll(); bool success = false; try @@ -144,11 +132,6 @@ public unsafe bool Wait(int millisecondsTimeout, object? associatedObject = null waiter.ev.Reset(); } - if (isWaitHandleKeywordEnabled) - { - NativeRuntimeEventSource.Log.WaitHandleWaitStop(); - } - AssertIsNotInList(waiter); } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs index c9b270b716dd47..66016246231fe6 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs @@ -146,7 +146,7 @@ public static bool IsEntered(object obj) [UnsupportedOSPlatform("browser")] public static bool Wait(object obj, int millisecondsTimeout) { - return GetCondition(obj).Wait(millisecondsTimeout, obj); + return GetCondition(obj).Wait(millisecondsTimeout); } public static void Pulse(object obj) diff --git a/src/coreclr/scripts/genRuntimeEventSources.py b/src/coreclr/scripts/genRuntimeEventSources.py index 6cae5765b2df83..f47a30f284519f 100644 --- a/src/coreclr/scripts/genRuntimeEventSources.py +++ b/src/coreclr/scripts/genRuntimeEventSources.py @@ -85,9 +85,11 @@ def getManifestsToGenerate(runtimeFlavor): def generateEvent(eventNode, providerNode, outputFile, stringTable): - # ThreadPool, Contention and WaitHandle events are defined manually in NativeRuntimeEventSource.Threading.cs + # ThreadPool and Contention events are defined manually in NativeRuntimeEventSource.Threading.cs symbol = eventNode.getAttribute("symbol") - if any(s in symbol for s in ["ThreadPool", "Contention", "WaitHandle"]): + if "ThreadPool" in symbol: + return + if "Contention" in symbol: return evtLevel = eventNode.getAttribute("level")[4:] diff --git a/src/coreclr/vm/nativeeventsource.cpp b/src/coreclr/vm/nativeeventsource.cpp index 995bc63e745977..b4bca0355e6c7a 100644 --- a/src/coreclr/vm/nativeeventsource.cpp +++ b/src/coreclr/vm/nativeeventsource.cpp @@ -189,24 +189,4 @@ extern "C" void QCALLTYPE LogContentionStop(uint8_t ContentionFlags, uint16_t Cl END_QCALL; } -extern "C" void QCALLTYPE LogWaitHandleWaitStart(uint8_t WaitSource, void* AssociatedObjectID, uint16_t ClrInstanceID) -{ - QCALL_CONTRACT; - BEGIN_QCALL; - - FireEtwWaitHandleWaitStart(WaitSource, AssociatedObjectID, ClrInstanceID); - - END_QCALL; -} - -extern "C" void QCALLTYPE LogWaitHandleWaitStop(uint16_t ClrInstanceID) -{ - QCALL_CONTRACT; - BEGIN_QCALL; - - FireEtwWaitHandleWaitStop(ClrInstanceID); - - END_QCALL; -} - #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/vm/nativeeventsource.h b/src/coreclr/vm/nativeeventsource.h index 95e3c7c8db67ba..a407c4b5ebb10b 100644 --- a/src/coreclr/vm/nativeeventsource.h +++ b/src/coreclr/vm/nativeeventsource.h @@ -31,8 +31,6 @@ extern "C" void QCALLTYPE LogThreadPoolIOPack(_In_z_ void* nativeOverlapped, _In extern "C" void QCALLTYPE LogContentionLockCreated(void* LockID, void* AssociatedObjectID, uint16_t ClrInstanceID); extern "C" void QCALLTYPE LogContentionStart(uint8_t ContentionFlags, uint16_t ClrInstanceID, void* LockID, void* AssociatedObjectID, uint64_t LockOwnerThreadID); extern "C" void QCALLTYPE LogContentionStop(uint8_t ContentionFlags, uint16_t ClrInstanceID, double DurationNs); -extern "C" void QCALLTYPE LogWaitHandleWaitStart(uint8_t WaitSource, void* AssociatedObjectID, uint16_t ClrInstanceID); -extern "C" void QCALLTYPE LogWaitHandleWaitStop(uint16_t ClrInstanceID); #endif // defined(FEATURE_PERFTRACING) #endif //_NATIVEEVENTSOURCE_H_ diff --git a/src/coreclr/vm/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp index 8d7b9e0e8e3e78..03fd3a850723dd 100644 --- a/src/coreclr/vm/qcallentrypoints.cpp +++ b/src/coreclr/vm/qcallentrypoints.cpp @@ -310,8 +310,6 @@ static const Entry s_QCall[] = DllImportEntry(LogContentionLockCreated) DllImportEntry(LogContentionStart) DllImportEntry(LogContentionStop) - DllImportEntry(LogWaitHandleWaitStart) - DllImportEntry(LogWaitHandleWaitStop) DllImportEntry(EventPipeInternal_Enable) DllImportEntry(EventPipeInternal_Disable) DllImportEntry(EventPipeInternal_GetSessionInfo) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs index 2a00dfa39885a4..edd638b679dac8 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestNegative.cs @@ -137,14 +137,14 @@ public void Test_GenerateManifest_InvalidEventSources() e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.EventIdReusedEventSource), string.Empty, strictOptions)); AssertExceptionStringsEqual(() => string.Join(Environment.NewLine, - GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1, "WriteInteger1"), + GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1), GetResourceString("EventSource_TaskOpcodePairReused", "WriteInteger2", 1, "WriteInteger1", 1)), e); e = AssertExtensions.Throws(null, () => EventSource.GenerateManifest(typeof(Sdt.EventIdReusedEventSource), string.Empty, strictOptions)); AssertExceptionStringsEqual(() => string.Join(Environment.NewLine, - GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1, "WriteInteger1"), + GetResourceString("EventSource_EventIdReused", "WriteInteger2", 1), GetResourceString("EventSource_TaskOpcodePairReused", "WriteInteger2", 1, "WriteInteger1", 1)), e); diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 4772b7851d7753..b7a2c2aa9d8667 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -2091,7 +2091,7 @@ Channel {0} has a value of {1} which is outside the legal range (16-254). - Event {0} has ID {1} which is already in use by event {2}. + Event {0} has ID {1} which is already in use. Event {0} (with ID {1}) has a non-default opcode but not a task. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 4fed6f226322f0..430bab166562fa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -3530,13 +3530,9 @@ private static void DebugCheckEvent(ref Dictionary? eventsByName manifest.ManifestError(SR.Format(SR.EventSource_MismatchIdToWriteEvent, evtName, evtId, eventArg), true); } - if (evtId < eventData.Length) + if (evtId < eventData.Length && eventData[evtId].Descriptor.EventId != 0) { - var existingEventMetadata = eventData[evtId]; - if (existingEventMetadata.Descriptor.EventId != 0) - { - manifest.ManifestError(SR.Format(SR.EventSource_EventIdReused, evtName, evtId, existingEventMetadata.Name), true); - } + manifest.ManifestError(SR.Format(SR.EventSource_EventIdReused, evtName, evtId), true); } // We give a task to things if they don't have one. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs index b0b60bceab13eb..a97f2ef62c9fe5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs @@ -32,8 +32,6 @@ private static partial class Messages public const string IOEnqueue = "NativeOverlapped={0};\nOverlapped={1};\nMultiDequeues={2};\nClrInstanceID={3}"; public const string IO = "NativeOverlapped={0};\nOverlapped={1};\nClrInstanceID={2}"; public const string WorkingThreadCount = "Count={0};\nClrInstanceID={1}"; - public const string WaitHandleWaitStart = "WaitSource={0};\nAssociatedObjectID={1};\nClrInstanceID={2}"; - public const string WaitHandleWaitStop = "ClrInstanceID={0}"; } // The task definitions for the ETW manifest @@ -45,7 +43,6 @@ private static partial class Messages public const EventTask ThreadPool = (EventTask)23; public const EventTask ThreadPoolWorkingThreadCount = (EventTask)22; public const EventTask ThreadPoolMinMaxThreads = (EventTask)38; - public const EventTask WaitHandleWait = (EventTask)39; } public static partial class Opcodes // this name and visibility is important for EventSource @@ -79,12 +76,6 @@ public enum ThreadAdjustmentReasonMap : uint CooperativeBlocking, } - public enum WaitHandleWaitSourceMap : byte - { - Unknown, - MonitorWait, - } - [Event(90, Level = EventLevel.Informational, Message = Messages.ContentionLockCreated, Task = Tasks.Contention, Opcode = EventOpcode.Info, Version = 0, Keywords = Keywords.ContentionKeyword)] private void ContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID = DefaultClrInstanceId) { @@ -329,22 +320,5 @@ public unsafe void ThreadPoolMinMaxThreads( LogThreadPoolMinMaxThreads(MinWorkerThreads, MaxWorkerThreads, MinIOCompletionThreads, MaxIOCompletionThreads, ClrInstanceID); } } - - [Event(301, Level = EventLevel.Verbose, Message = Messages.WaitHandleWaitStart, Task = Tasks.WaitHandleWait, Opcode = EventOpcode.Start, Version = 0, Keywords = Keywords.WaitHandleKeyword)] - public void WaitHandleWaitStart( - WaitHandleWaitSourceMap WaitSource, - nint AssociatedObjectID, - ushort ClrInstanceID = DefaultClrInstanceId) - { - Debug.Assert(IsEnabled(EventLevel.Verbose, Keywords.WaitHandleKeyword)); - LogWaitHandleWaitStart(WaitSource, AssociatedObjectID, ClrInstanceID); - } - - [Event(302, Level = EventLevel.Verbose, Message = Messages.WaitHandleWaitStop, Task = Tasks.WaitHandleWait, Opcode = EventOpcode.Stop, Version = 0, Keywords = Keywords.WaitHandleKeyword)] - public void WaitHandleWaitStop(ushort ClrInstanceID = DefaultClrInstanceId) - { - Debug.Assert(IsEnabled(EventLevel.Verbose, Keywords.WaitHandleKeyword)); - LogWaitHandleWaitStop(ClrInstanceID); - } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs index a1b65bd5ad832a..59d49bf7892ade 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.cs @@ -17,7 +17,6 @@ public static partial class Keywords public const EventKeywords ContentionKeyword = (EventKeywords)0x4000; public const EventKeywords ThreadingKeyword = (EventKeywords)0x10000; public const EventKeywords ThreadTransferKeyword = (EventKeywords)0x80000000; - public const EventKeywords WaitHandleKeyword = (EventKeywords)0x40000000000; } private static partial class Messages @@ -33,8 +32,6 @@ private static partial class Messages public const string IOEnqueue = "NativeOverlapped={0};\nOverlapped={1};\nMultiDequeues={2};\nClrInstanceID={3}"; public const string IO = "NativeOverlapped={0};\nOverlapped={1};\nClrInstanceID={2}"; public const string WorkingThreadCount = "Count={0};\nClrInstanceID={1}"; - public const string WaitHandleWaitStart = "WaitSource={0};\nAssociatedObjectID={1};\nClrInstanceID={2}"; - public const string WaitHandleWaitStop = "ClrInstanceID={0}"; } // The task definitions for the ETW manifest @@ -46,7 +43,6 @@ private static partial class Messages public const EventTask ThreadPool = (EventTask)23; public const EventTask ThreadPoolWorkingThreadCount = (EventTask)22; public const EventTask ThreadPoolMinMaxThreads = (EventTask)38; - public const EventTask WaitHandleWait = (EventTask)39; } public static partial class Opcodes // this name and visibility is important for EventSource @@ -80,12 +76,6 @@ public enum ThreadAdjustmentReasonMap : uint CooperativeBlocking, } - public enum WaitHandleWaitSourceMap : byte - { - Unknown, - MonitorWait, - } - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")] [Event(90, Level = EventLevel.Informational, Message = Messages.ContentionLockCreated, Task = Tasks.Contention, Opcode = EventOpcode.Info, Version = 0, Keywords = Keywords.ContentionKeyword)] private unsafe void ContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID = DefaultClrInstanceId) @@ -514,40 +504,5 @@ public unsafe void ThreadPoolMinMaxThreads( data[4].Reserved = 0; WriteEventCore(59, 5, data); } - - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")] - [Event(301, Level = EventLevel.Verbose, Message = Messages.WaitHandleWaitStart, Task = Tasks.WaitHandleWait, Opcode = EventOpcode.Start, Version = 0, Keywords = Keywords.WaitHandleKeyword)] - public unsafe void WaitHandleWaitStart( - WaitHandleWaitSourceMap WaitSource, - nint AssociatedObjectID, - ushort ClrInstanceID = DefaultClrInstanceId) - { - Debug.Assert(IsEnabled(EventLevel.Verbose, Keywords.WaitHandleKeyword)); - - EventData* data = stackalloc EventData[3]; - data[0].DataPointer = (nint)(&WaitSource); - data[0].Size = sizeof(WaitHandleWaitSourceMap); - data[0].Reserved = 0; - data[1].DataPointer = (nint)(&AssociatedObjectID); - data[1].Size = nint.Size; - data[1].Reserved = 0; - data[2].DataPointer = (nint)(&ClrInstanceID); - data[2].Size = sizeof(ushort); - data[2].Reserved = 0; - WriteEventCore(301, 3, data); - } - - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")] - [Event(302, Level = EventLevel.Verbose, Message = Messages.WaitHandleWaitStop, Task = Tasks.WaitHandleWait, Opcode = EventOpcode.Stop, Version = 0, Keywords = Keywords.WaitHandleKeyword)] - public unsafe void WaitHandleWaitStop(ushort ClrInstanceID = DefaultClrInstanceId) - { - Debug.Assert(IsEnabled(EventLevel.Verbose, Keywords.WaitHandleKeyword)); - - EventData* data = stackalloc EventData[1]; - data[0].DataPointer = (nint)(&ClrInstanceID); - data[0].Size = sizeof(ushort); - data[0].Reserved = 0; - WriteEventCore(302, 1, data); - } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs index ce33c716ecd51a..85a236cdcc1960 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Diagnostics.Tracing; using Microsoft.Win32.SafeHandles; namespace System.Threading @@ -112,16 +111,6 @@ private bool WaitOneNoCheck(int millisecondsTimeout) SafeWaitHandle? waitHandle = _waitHandle; ObjectDisposedException.ThrowIf(waitHandle is null, this); - bool isWaitHandleKeywordEnabled = NativeRuntimeEventSource.Log.IsEnabled( - EventLevel.Informational, - NativeRuntimeEventSource.Keywords.WaitHandleKeyword); - if (isWaitHandleKeywordEnabled) - { - NativeRuntimeEventSource.Log.WaitHandleWaitStart( - NativeRuntimeEventSource.WaitHandleWaitSourceMap.Unknown, - 0); - } - bool success = false; try { @@ -150,11 +139,6 @@ private bool WaitOneNoCheck(int millisecondsTimeout) { if (success) waitHandle.DangerousRelease(); - - if (isWaitHandleKeywordEnabled) - { - NativeRuntimeEventSource.Log.WaitHandleWaitStop(); - } } } diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Mono.cs index 1ef6372b257c8d..20fc2b2c72da88 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Mono.cs @@ -97,16 +97,5 @@ private static extern void LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, ushort ClrInstanceID); - - [NonEvent] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void LogWaitHandleWaitStart( - WaitHandleWaitSourceMap WaitSource, - IntPtr AssociatedObjectID, - ushort ClrInstanceID); - - [NonEvent] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void LogWaitHandleWaitStop(ushort ClrInstanceID); } } diff --git a/src/mono/mono/component/event_pipe-stub.c b/src/mono/mono/component/event_pipe-stub.c index a9484c12b336b3..a1769b9454af51 100644 --- a/src/mono/mono/component/event_pipe-stub.c +++ b/src/mono/mono/component/event_pipe-stub.c @@ -213,16 +213,6 @@ event_pipe_stub_wait_for_session_signal ( EventPipeSessionID session_id, uint32_t timeout); -static bool -event_pipe_stub_write_event_wait_handle_wait_start ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id); - -static bool -event_pipe_stub_write_event_wait_handle_wait_stop ( - uint16_t clr_instance_id); - MonoComponentEventPipe * component_event_pipe_stub_init (void); @@ -261,8 +251,6 @@ static MonoComponentEventPipe fn_table = { &event_pipe_stub_write_event_contention_lock_created, &event_pipe_stub_write_event_contention_start, &event_pipe_stub_write_event_contention_stop, - &event_pipe_stub_write_event_wait_handle_wait_start, - &event_pipe_stub_write_event_wait_handle_wait_stop, &event_pipe_stub_signal_session, &event_pipe_stub_wait_for_session_signal }; @@ -566,22 +554,6 @@ event_pipe_stub_wait_for_session_signal ( return true; } -static bool -event_pipe_stub_write_event_wait_handle_wait_start ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id) -{ - return true; -} - -static bool -event_pipe_stub_write_event_wait_handle_wait_stop ( - uint16_t clr_instance_id) -{ - return true; -} - MonoComponentEventPipe * component_event_pipe_stub_init (void) { diff --git a/src/mono/mono/component/event_pipe.c b/src/mono/mono/component/event_pipe.c index 097abde8c2ae22..1ea641bd378915 100644 --- a/src/mono/mono/component/event_pipe.c +++ b/src/mono/mono/component/event_pipe.c @@ -141,10 +141,8 @@ static MonoComponentEventPipe fn_table = { &ep_rt_write_event_contention_lock_created, &ep_rt_write_event_contention_start, &ep_rt_write_event_contention_stop, - &ep_rt_write_event_wait_handle_wait_start, - &ep_rt_write_event_wait_handle_wait_stop, &event_pipe_signal_session, - &event_pipe_wait_for_session_signal, + &event_pipe_wait_for_session_signal }; static bool diff --git a/src/mono/mono/component/event_pipe.h b/src/mono/mono/component/event_pipe.h index 5e359aacd8651b..bc1fe532dbd25c 100644 --- a/src/mono/mono/component/event_pipe.h +++ b/src/mono/mono/component/event_pipe.h @@ -242,16 +242,6 @@ typedef bool uint16_t clr_instance_id, double duration_ns); -typedef bool -(*event_pipe_component_write_event_wait_handle_wait_start_func)( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id); - -typedef bool -(*event_pipe_component_write_event_wait_handle_wait_stop_func)( - uint16_t clr_instance_id); - /* * MonoComponentEventPipe function table. */ @@ -291,8 +281,6 @@ typedef struct _MonoComponentEventPipe { event_pipe_component_write_event_contention_lock_created_func write_event_contention_lock_created; event_pipe_component_write_event_contention_start_func write_event_contention_start; event_pipe_component_write_event_contention_stop_func write_event_contention_stop; - event_pipe_component_write_event_wait_handle_wait_start_func write_event_wait_handle_wait_start; - event_pipe_component_write_event_wait_handle_wait_stop_func write_event_wait_handle_wait_stop; event_pipe_component_signal_session signal_session; event_pipe_component_wait_for_session_signal wait_for_session_signal; } MonoComponentEventPipe; diff --git a/src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c b/src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c index 0b31632fd53b17..fd02bd7dbeab5f 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c +++ b/src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c @@ -2785,30 +2785,6 @@ ep_rt_write_event_contention_stop ( NULL) == 0 ? true : false; } -bool -ep_rt_write_event_wait_handle_wait_start ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id) -{ - return FireEtwWaitHandleWaitStart ( - wait_source, - (const void *)associated_object_id, - clr_instance_id, - NULL, - NULL) == 0 ? true : false; -} - -bool -ep_rt_write_event_wait_handle_wait_stop ( - uint16_t clr_instance_id) -{ - return FireEtwWaitHandleWaitStop ( - clr_instance_id, - NULL, - NULL) == 0 ? true : false; -} - static void jit_begin_callback ( diff --git a/src/mono/mono/eventpipe/ep-rt-mono.h b/src/mono/mono/eventpipe/ep-rt-mono.h index 35a7607681366a..6b741d4390bb96 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.h +++ b/src/mono/mono/eventpipe/ep-rt-mono.h @@ -1884,16 +1884,6 @@ ep_rt_write_event_contention_stop ( uint16_t clr_instance_id, double duration_ns); -bool -ep_rt_write_event_wait_handle_wait_start ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id); - -bool -ep_rt_write_event_wait_handle_wait_stop ( - uint16_t clr_instance_id); - /* * EventPipe provider callbacks. */ diff --git a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst index de5d7e96f6323c..8a9f572a1d5c4b 100644 --- a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst +++ b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst @@ -59,6 +59,4 @@ ThreadPoolIOPack ThreadTerminated TypeLoadStart TypeLoadStop -WaitHandleWaitStart -WaitHandleWaitStop Microsoft-DotNETRuntimeMonoProfiler:* diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h index 1f4ad944a32691..704092c5a47c17 100644 --- a/src/mono/mono/metadata/icall-decl.h +++ b/src/mono/mono/metadata/icall-decl.h @@ -176,8 +176,6 @@ ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_ ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogContentionLockCreated (intptr_t lock_id, intptr_t associated_object_id, uint16_t clr_instance_id); ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogContentionStart (uint8_t contention_flags, uint16_t clr_instance_id, intptr_t lock_id, intptr_t associated_object_id, uint64_t lock_owner_thread_id); ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogContentionStop (uint8_t contention_flags, uint16_t clr_instance_id, double duration_ns); -ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStart (uint8_t wait_source, intptr_t associated_object_id, uint16_t clr_instance_id); -ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStop (uint16_t clr_instance_id); ICALL_EXPORT void ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array); ICALL_EXPORT void ves_icall_Mono_SafeStringMarshal_GFree (void *c_str); diff --git a/src/mono/mono/metadata/icall-def.h b/src/mono/mono/metadata/icall-def.h index e9b42f9470f270..556eb8708c4399 100644 --- a/src/mono/mono/metadata/icall-def.h +++ b/src/mono/mono/metadata/icall-def.h @@ -189,8 +189,6 @@ NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_11, "LogThreadPoolWorkerThreadStart" NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_12, "LogThreadPoolWorkerThreadStop", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_13, "LogThreadPoolWorkerThreadWait", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait)) NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_14, "LogThreadPoolWorkingThreadCount", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount)) -NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_15, "LogWaitHandleWaitStart", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStart)) -NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_16, "LogWaitHandleWaitStop", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStop)) ICALL_TYPE(ENUM, "System.Enum", ENUM_1) HANDLES(ENUM_1, "GetEnumValuesAndNames", ves_icall_System_Enum_GetEnumValuesAndNames, void, 3, (MonoQCallTypeHandle, MonoArrayOut, MonoArrayOut)) diff --git a/src/mono/mono/metadata/icall-eventpipe.c b/src/mono/mono/metadata/icall-eventpipe.c index 9dea29b3f83416..46314b32a43f0f 100644 --- a/src/mono/mono/metadata/icall-eventpipe.c +++ b/src/mono/mono/metadata/icall-eventpipe.c @@ -469,26 +469,6 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogContentionStop duration_ns); } -void -ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStart ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id) -{ - mono_component_event_pipe ()->write_event_wait_handle_wait_start ( - wait_source, - associated_object_id, - clr_instance_id); -} - -void -ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStop ( - uint16_t clr_instance_id) -{ - mono_component_event_pipe ()->write_event_wait_handle_wait_stop ( - clr_instance_id); -} - #else /* ENABLE_PERFTRACING */ gconstpointer @@ -798,24 +778,4 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogContentionStop mono_error_set_pending_exception (error); } -void -ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStart ( - uint8_t wait_source, - intptr_t associated_object_id, - uint16_t clr_instance_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.NativeRuntimeEventSource.WaitHandleWaitStart"); - mono_error_set_pending_exception (error); -} - -void -ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogWaitHandleWaitStop ( - uint16_t clr_instance_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.NativeRuntimeEventSource.WaitHandleWaitStop"); - mono_error_set_pending_exception (error); -} - #endif /* ENABLE_PERFTRACING */