G
Guest
During the investigation of some multithreading issues we have in our
software, I have been attempting to use the NT performance counter;
Performance Counter; .NET Locks & Threads - Current Queue Count.
I noticed that when I monitor my .NET service this value continues to rise
steadily. It is my understanding that this represents the length of the
current Wait Queue. Also monitoring the physical and logical queues shows
that these two counters stay pretty much the same. This lead me to believe
that there is a bug in the Current Queue Length counter as it is far higher
that the number of logical or physical threads.
I investigated this rising count to discover that it is a specific call to
an overloaded member Monitor.Wait(object, int), where the int is the timeout
for the wait to attempt to re-acquire a lock on the object, instead of
waiting to be pulsed indefinitely is the cause. When the timeout occurs, the
thread gets the lock again and continues, but the Current Queue Length does
not get decremented.
I wrote a small test harness to prove my theory, and when using the
Monitor.Wait(object) member, when the object is pulsed and execution
continues, the Current Queue Length is decremented.
Is this an issue with the .NET runtime Wait Queue implementation, or is it
simply a problem with the performance counter implementation?
software, I have been attempting to use the NT performance counter;
Performance Counter; .NET Locks & Threads - Current Queue Count.
I noticed that when I monitor my .NET service this value continues to rise
steadily. It is my understanding that this represents the length of the
current Wait Queue. Also monitoring the physical and logical queues shows
that these two counters stay pretty much the same. This lead me to believe
that there is a bug in the Current Queue Length counter as it is far higher
that the number of logical or physical threads.
I investigated this rising count to discover that it is a specific call to
an overloaded member Monitor.Wait(object, int), where the int is the timeout
for the wait to attempt to re-acquire a lock on the object, instead of
waiting to be pulsed indefinitely is the cause. When the timeout occurs, the
thread gets the lock again and continues, but the Current Queue Length does
not get decremented.
I wrote a small test harness to prove my theory, and when using the
Monitor.Wait(object) member, when the object is pulsed and execution
continues, the Current Queue Length is decremented.
Is this an issue with the .NET runtime Wait Queue implementation, or is it
simply a problem with the performance counter implementation?