[Profiler] Add contention profiler based on Clr Events#3115
Merged
Conversation
gleocadie
force-pushed
the
gleocadie/contention-profiler-from-events
branch
5 times, most recently
from
August 23, 2022 14:17
2df3650 to
343b76f
Compare
gleocadie
marked this pull request as ready for review
August 24, 2022 15:14
chrisnas
requested changes
Aug 25, 2022
chrisnas
left a comment
Contributor
There was a problem hiding this comment.
Don't forget to:
- update EnabledProfilers.cpp
if (pConfiguration->IsAllocationProfilingEnabled())
{
_enabledProfilers |= RuntimeProfiler::Allocations;
}
**if (pConfiguration->IsContentionProfilingEnabled())
{
_enabledProfilers |= RuntimeProfiler::Contention;
}**
- uncomment Contention enum value in IEnabledProfilers.h
- add tag in libddprofexporter.cpp
if (enabledProfilers->IsEnabled(RuntimeProfiler::Allocations))
{
if (!emptyList)
{
buffer << separator;
}
buffer << "allocations";
emptyList = false;
}
**if (enabledProfilers->IsEnabled(RuntimeProfiler::Contention))
{
if (!emptyList)
{
buffer << separator;
}
buffer << "contention";
emptyList = false;
}**
| const auto result = pStackFramesCollector->CollectStackSample(threadInfo, &hrCollectStack); | ||
| if (result->GetFramesCount() == 0) | ||
| { | ||
| Log::Warn("Failed to walk stack for sampled contention: ", HResultConverter::ToStringWithCode(hrCollectStack)); |
Contributor
There was a problem hiding this comment.
Since there is no sampling, we might send too many logs in this case
Collaborator
Author
There was a problem hiding this comment.
Same, besides, if we fail how will we know ?
Collaborator
Author
There was a problem hiding this comment.
(also done in the exception profiler)
Contributor
There was a problem hiding this comment.
Could log once and then every 10 or 50
gleocadie
force-pushed
the
gleocadie/contention-profiler-from-events
branch
from
August 25, 2022 07:54
4d1e0bf to
e77566f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Add contention profiler.
Reason for change
This is a new feature.
Implementation details
This implementation relies on the CLR Events infrastructure put in place by @chrisnas. Once a
ContentionStopevent is received, we stackwalk the current thread, extract from the event the lock duration and create the sample.Test coverage
Add a new test scenario in Computer01 to generate contention and ensure it works accordingly.
Other details