Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETW Event for InitializeYieldProcessorNormalized #52177

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/coreclr/vm/ClrEtwAll.man
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
message="$(string.RuntimePublisher.TypeDiagnosticKeywordMessage)" symbol="CLR_TYPEDIAGNOSTIC_KEYWORD" />
<keyword name="JitInstrumentationDataKeyword" mask="0x10000000000"
message="$(string.RuntimePublisher.JitInstrumentationDataKeywordMessage)" symbol="CLR_JITINSTRUMENTEDDATA_KEYWORD" />
<keyword name="YieldProcessorNormalizedKeyword" mask="0x20000000000"
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem worth using a different keyword for this, can it go into the Threading keyword? The event may or may not be sent after relevant fixes are made.

message="$(string.RuntimePublisher.YieldProcessorNormalizedKeywordMessage)" symbol="CLR_YIELDPROCESSORNORMALIZED_KEYWORD" />
</keywords>
<!--Tasks-->
<tasks>
Expand Down Expand Up @@ -422,7 +424,13 @@
<opcode name="InstrumentationDataVerbose" message="$(string.RuntimePublisher.InstrumentationDataOpcodeMessage)" symbol="CLR_INSTRUMENTATION_DATA_VERBOSE_OPCODE" value="12"/>
</opcodes>
</task>
<!--Next available ID is 35-->
<task name="InitializeYieldProcessorNormalized" symbol="CLR_INITIALIZEYIELDPROCESSORNORMALIZED_TASK"
value="35" eventGUID="{7F644185-FD46-4ACC-A4B2-3812646054BD}"
message="$(string.RuntimePublisher.InitializeYieldProcessorNormalizedTaskMessage)">
<opcodes>
</opcodes>
</task>
<!--Next available ID is 36-->
</tasks>
<!--Maps-->
<maps>
Expand Down Expand Up @@ -1430,6 +1438,20 @@
</UserData>
</template>

<template tid="InitializeYieldProcessorNormalized">
<data name="YieldsPerNormalizedYield" inType="win:UInt32" />
<data name="OptimalMaxNormalizedYieldsPerSpinIteration" inType="win:UInt32" />
Copy link
Member

Choose a reason for hiding this comment

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

The values computed in .NET Framework are different. I suggest sending just the nsPerYield value as an 8-byte float, that is commonly measured in .NET Framework and .NET Core, and the rest of the values can be calculated from it.

<data name="ClrInstanceID" inType="win:UInt16" />

<UserData>
<InitializeYieldProcessorNormalized xmlns="myNs">
<YieldsPerNormalizedYield> %1 </YieldsPerNormalizedYield>
<OptimalMaxNormalizedYieldsPerSpinIteration> %2 </OptimalMaxNormalizedYieldsPerSpinIteration>
<ClrInstanceID> %3 </ClrInstanceID>
</InitializeYieldProcessorNormalized>
</UserData>
</template>

<template tid="ThreadPoolWorkerThread">
<data name="ActiveWorkerThreadCount" inType="win:UInt32" />
<data name="RetiredWorkerThreadCount" inType="win:UInt32" />
Expand Down Expand Up @@ -3274,6 +3296,11 @@
task="ThreadPoolWorkerThread"
symbol="ThreadPoolWorkerThreadWait" message="$(string.RuntimePublisher.ThreadPoolWorkerThreadEventMessage)"/>

<event value="58" version="0" level="win:LogAlways" template="InitializeYieldProcessorNormalized"
keywords ="YieldProcessorNormalizedKeyword" opcode="win:Info"
task="InitializeYieldProcessorNormalized"
symbol="InitializeYieldProcessorNormalizedInfo" message="$(string.RuntimePublisher.InitializeYieldProcessorNormalizedEventMessage)"/>

<!-- CLR private ThreadPool events -->
<event value="60" version="0" level="win:Verbose" template="ThreadPoolWorkingThreadCount"
keywords="ThreadingKeyword"
Expand Down Expand Up @@ -7048,6 +7075,7 @@
<string id="RuntimePublisher.WorkerThreadTerminateEventMessage" value="WorkerThreadCount=%1;%nRetiredWorkerThreads=%2" />
<string id="RuntimePublisher.WorkerThreadRetirementRetireThreadEventMessage" value="WorkerThreadCount=%1;%nRetiredWorkerThreads=%2" />
<string id="RuntimePublisher.WorkerThreadRetirementUnretireThreadEventMessage" value="WorkerThreadCount=%1;%nRetiredWorkerThreads=%2" />
<string id="RuntimePublisher.InitializeYieldProcessorNormalizedEventMessage" value="YieldsPerNormalizedYield=%1;%nOptimalMaxNormalizedYieldsPerSpinIteration=%2;%nClrInstanceID=%3" />
<string id="RuntimePublisher.ThreadPoolWorkerThreadEventMessage" value="WorkerThreadCount=%1;%nRetiredWorkerThreadCount=%2;%nClrInstanceID=%3" />
<string id="RuntimePublisher.ThreadPoolWorkerThreadAdjustmentSampleEventMessage" value="Throughput=%1;%nClrInstanceID=%2" />
<string id="RuntimePublisher.ThreadPoolWorkerThreadAdjustmentAdjustmentEventMessage" value="AverageThroughput=%1;%nNewWorkerThreadCount=%2;%nReason=%3;%nClrInstanceID=%4" />
Expand Down Expand Up @@ -7329,6 +7357,7 @@
<string id="RuntimePublisher.AssemblyLoaderTaskMessage" value="AssemblyLoader" />
<string id="RuntimePublisher.TypeLoadTaskMessage" value="TypeLoad" />
<string id="RuntimePublisher.JitInstrumentationDataTaskMessage" value="JitInstrumentationData" />
<string id="RuntimePublisher.InitializeYieldProcessorNormalizedTaskMessage" value="InitializeYieldProcessorNormalized" />

<string id="RundownPublisher.EEStartupTaskMessage" value="Runtime" />
<string id="RundownPublisher.MethodTaskMessage" value="Method" />
Expand Down Expand Up @@ -7657,6 +7686,7 @@
<string id="RuntimePublisher.MethodDiagnosticKeywordMessage" value="MethodDiagnostic" />
<string id="RuntimePublisher.TypeDiagnosticKeywordMessage" value="TypeDiagnostic" />
<string id="RuntimePublisher.JitInstrumentationDataKeywordMessage" value="JitInstrumentationData" />
<string id="RuntimePublisher.YieldProcessorNormalizedKeywordMessage" value="YieldProcessorNormalized" />
<string id="RuntimePublisher.GenAwareBeginEventMessage" value="NONE" />
<string id="RuntimePublisher.GenAwareEndEventMessage" value="NONE" />
<string id="RundownPublisher.LoaderKeywordMessage" value="Loader" />
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4680,6 +4680,12 @@ extern "C"
{
ETW::EnumerationLog::EnumerateForCaptureState();
}

if (g_fEEStarted && !g_fEEShutDown)
{
// Emit the YieldProcessorNormalized calculated values at the beginning of the trace.
FireEtwInitializeYieldProcessorNormalizedInfo(g_yieldsPerNormalizedYield, g_optimalMaxNormalizedYieldsPerSpinIteration, GetClrInstanceId());
}
}
#ifdef FEATURE_COMINTEROP
if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context, CCWRefCountChange))
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/yieldprocessornormalized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ static void InitializeYieldProcessorNormalized()
s_isYieldProcessorNormalizedInitialized = true;

GCHeapUtilities::GetGCHeap()->SetYieldProcessorScalingFactor((float)yieldsPerNormalizedYield);

FireEtwInitializeYieldProcessorNormalizedInfo(g_yieldsPerNormalizedYield, g_optimalMaxNormalizedYieldsPerSpinIteration, GetClrInstanceId());
}

void EnsureYieldProcessorNormalizedInitialized()
Expand Down