-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add new version of the ContentionStart event #72627
Changes from 2 commits
1988694
5fb79fd
d6d6398
d214618
4550dc5
1559e3d
ba3cca1
292656e
4d529a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1742,6 +1742,21 @@ | |
</UserData> | ||
</template> | ||
|
||
<template tid="ContentionStart_V2"> | ||
<data name="ContentionFlags" inType="win:UInt8" map="ContentionFlagsMap" /> | ||
<data name="ClrInstanceID" inType="win:UInt16" /> | ||
<data name="LockObjectID" inType="win:Pointer" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend calling this |
||
<data name="LockOwnerThreadID" inType="win:Pointer" /> | ||
<UserData> | ||
<Contention xmlns="myNs"> | ||
<ContentionFlags> %1 </ContentionFlags> | ||
<ClrInstanceID> %2 </ClrInstanceID> | ||
<LockObjectID> %3 </LockObjectID> | ||
<LockOwnerThreadID> %4 </LockOwnerThreadID> | ||
</Contention> | ||
</UserData> | ||
</template> | ||
|
||
<template tid="ContentionStop_V1"> | ||
<data name="ContentionFlags" inType="win:UInt8" map="ContentionFlagsMap" /> | ||
<data name="ClrInstanceID" inType="win:UInt16" /> | ||
|
@@ -3642,6 +3657,11 @@ | |
task="Contention" | ||
symbol="ContentionStart_V1" message="$(string.RuntimePublisher.ContentionStart_V1EventMessage)"/> | ||
|
||
<event value="81" version="2" level="win:Informational" template="ContentionStart_V2" | ||
keywords ="ContentionKeyword" opcode="win:Start" | ||
task="Contention" | ||
symbol="ContentionStart_V2" message="$(string.RuntimePublisher.ContentionStart_V2EventMessage)"/> | ||
|
||
<event value="91" version="0" level="win:Informational" template="Contention" | ||
keywords ="ContentionKeyword" opcode="win:Stop" | ||
task="Contention" | ||
|
@@ -8432,6 +8452,7 @@ | |
<string id="RuntimePublisher.ExceptionExceptionHandlingNoneEventMessage" value="NONE" /> | ||
<string id="RuntimePublisher.ContentionStartEventMessage" value="NONE" /> | ||
<string id="RuntimePublisher.ContentionStart_V1EventMessage" value="ContentionFlags=%1;%nClrInstanceID=%2"/> | ||
<string id="RuntimePublisher.ContentionStart_V2EventMessage" value="ContentionFlags=%1;%nClrInstanceID=%2;%LockObjectID=%3;%LockOwnerThreadID=%4"/> | ||
<string id="RuntimePublisher.ContentionStopEventMessage" value="ContentionFlags=%1;%nClrInstanceID=%2"/> | ||
<string id="RuntimePublisher.ContentionStop_V1EventMessage" value="ContentionFlags=%1;%nClrInstanceID=%2;DurationNs=%3"/> | ||
<string id="RuntimePublisher.DCStartCompleteEventMessage" value="NONE" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2541,6 +2541,11 @@ BOOL AwareLock::EnterEpilogHelper(Thread* pCurThread, INT32 timeOut) | |
// the object associated with this lock. | ||
_ASSERTE(pCurThread->PreemptiveGCDisabled()); | ||
|
||
LogContention(); | ||
Thread::IncrementMonitorLockContentionCount(pCurThread); | ||
|
||
OBJECTREF obj = GetOwningObject(); | ||
|
||
BOOLEAN IsContentionKeywordEnabled = ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context, TRACE_LEVEL_INFORMATION, CLR_CONTENTION_KEYWORD); | ||
LARGE_INTEGER startTicks = { {0} }; | ||
|
||
|
@@ -2549,14 +2554,9 @@ BOOL AwareLock::EnterEpilogHelper(Thread* pCurThread, INT32 timeOut) | |
QueryPerformanceCounter(&startTicks); | ||
|
||
// Fire a contention start event for a managed contention | ||
FireEtwContentionStart_V1(ETW::ContentionLog::ContentionStructs::ManagedContention, GetClrInstanceId()); | ||
FireEtwContentionStart_V2(ETW::ContentionLog::ContentionStructs::ManagedContention, GetClrInstanceId(), OBJECTREFToObject(obj), m_HoldingThread); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than writing out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another potential issue here is that the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brianrob good point. I'll make the change to replace the pointer by the OS Thread id.
Does it mean that the address is changed also ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes the object address also changes when it's moved. Could pass in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the info. I'll do the change taking into account your comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid emitting too many events, I think you can safely emit just the creation event. If you see two creation events at the same address, you know that it's a new lock. |
||
} | ||
|
||
LogContention(); | ||
Thread::IncrementMonitorLockContentionCount(pCurThread); | ||
|
||
OBJECTREF obj = GetOwningObject(); | ||
|
||
// We cannot allow the AwareLock to be cleaned up underneath us by the GC. | ||
IncrementTransientPrecious(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if putting the LockId and OwnerId wouldn't be better on the Stop event, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense on the start event, since you want to know what was holding it that triggered the contention