Skip sending ETW trace event for nested lock which is always granted automatically #1301
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.
Asking nested lock was not considered to be costly, but sending extra ETW event makes them to pop in performance traces. Since they don't provide much value to understand those traces, we should suppress them.
(Note: we don't send ETW when lock is released, so there is no work there.)
The reason behind this change is that this specific ETW event sometime is the primary delay of certain code path, and sometime could cause incorrect interpreting the trace.
During around 7s solution loading trace, the total thread delay from ETW events is about 1.8s, and this event contributed 0.8s, 2x more than any other events. Because capturing stack of ordinal nested lock does not provide lots of value, i think we should suppress it. It would still send event for all top level locks and when an upgradable lock becomes a write lock.
Note: the real CPU usage in VS is much lower, the overhead is mostly when the system collects stacks during capturing the event. It adds extra time to the code path, instead of direct CPU usage.