diff options
author | jaykrell <jay.krell@cornell.edu> | 2018-01-04 12:17:30 +0300 |
---|---|---|
committer | Ludovic Henry <luhenry@microsoft.com> | 2018-01-04 12:17:30 +0300 |
commit | dc312c772f2a892b8eecea9e8d14a91e4b0fc9bf (patch) | |
tree | 08e653d91276f1c155a87822cbe168886a4962ac /mcs/class/referencesource | |
parent | e0e185d70abd73e82bbde7520edcb3bb0c68f1c8 (diff) |
Fix some ThreadPool performance counters. (#6118)
* Fix some ThreadPool performance counters.
https://bugzilla.xamarin.com/show_bug.cgi?id=41294
The bug is that some performance counters are always zero.
Because we do not update them.
This addresses two of them: Work items added and thread count.
There is PerformanceCounter class and you can Increment instances,
however its metadata and some of the implementation is in System.dll.
Most of the code is in native.
ThreadPool is in mscorlib.dll, so can't use System.dll.
A few options exist to address this.
We could move and forward the type. We could duplicate and rename
and possibly subset the type.
Here we add a new icall very specifically for the scenario.
There is slight cost for the icall, and for the atomic increment.
There is an attempt to measure but the results were unclear.
Note that the count of work items is not specifically for QueueUserWorkItem
as one might expect, but also for any async calls.
Fix a little bit of typos.
* Take command lines from command line per PR feedback.
* newline at end of file
Diffstat (limited to 'mcs/class/referencesource')
-rw-r--r-- | mcs/class/referencesource/mscorlib/system/threading/threadpool.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs b/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs index 6def21787d6..f6561124ce3 100644 --- a/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs +++ b/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs @@ -675,7 +675,9 @@ namespace System.Threading } } } - +#if MONO + ThreadPool.NotifyWorkItemQueued(); +#endif EnsureThreadRequested(); } @@ -1897,6 +1899,11 @@ namespace System.Threading [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void NotifyWorkItemProgressNative(); + [System.Security.SecurityCritical] + [ResourceExposure(ResourceScope.None)] + [MethodImplAttribute(MethodImplOptions.InternalCall)] + internal static extern void NotifyWorkItemQueued(); + [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] |