Don't capture AsyncLocals into EventCounter timer#26075
Don't capture AsyncLocals into EventCounter timer#26075stephentoub merged 3 commits intodotnet:masterfrom
Conversation
| restoreFlow = true; | ||
| } | ||
|
|
||
| _pollingTimer = new Timer(OnTimer, null, _pollingIntervalInMilliseconds, _pollingIntervalInMilliseconds); |
There was a problem hiding this comment.
new Timer(s => ((EventCounter)s).OnTimer(null), this, _pollingIntervalInMilliseconds, _pollingIntervalInMilliseconds);|
The OnTimer that's being invoked makes calls to _eventSource.Write. That Write call will in turn invoke user code from any registered EventListener. Previously that would have been done in the context of the captured ExecutionContext; now it won't. |
|
To address Stephen's concern. It is true that this changes the executioncontext that EventListeners will see when EventCounter events are fired. However, and EventCounter event represents an aggregation of many things and thus its context is not really valuable (at it only represents the current thread). In addition the timer is started by the thread that turns on the eventCounter. For ETW this is an INJECTED thread (not likely to be useful), and for EventListeners, it is the thread that called the 'Enable' API (that is a thread that logically belongs to the monitoring infrastructure). This makes it even less likely to be useful. Thus I am OK with the semantics of this change. |
|
RedHat.73.Amd64.Open-Release-x64 / System.Reflection.Metadata.Tests.MetadataReaderTests |
|
test Linux x64 Release Build |
|
@dotnet-bot test NETFX x86 Release Build |
* Don't capture AsyncLocals into EventCounter timer * Harden Flow suppression * Feedback Commit migrated from dotnet/corefx@bcc2940
Resolves: https://github.com/dotnet/corefx/issues/26074