Domanda

VS Concurrency Profiling can detect resource-contention for Critical Section, memory allocations, handles etc. But I am not sure if it detects contention for Slim Reader-Rriter (SRW) locks.

Does VS2012 concurrency profiler detects contention for SRW?

EDIT: Sample code and more details.

EnterCriticalSection(&cs);
// Use
LeaveCriticalSection(&cs);

Now, if the said code is executed by more than one thread at the same time, second thread would not be able to acquire the lock, and hence the contention. VS Concurrency Profiler will report (count+1) the same. It will be added to CS named cs (as in code). Similarly, lock on mutex, wait on handle (event, timer etc) will be reported, if thread cannot hold it immediately.

The question is regarding SRW - does VS reports the same?

È stato utile?

Soluzione

Are you asking about 'Concurrency Visualizer' under 'Analyze' menu in VS 2012? The tool will detect contention as long as there is blocking happening (that is, thread being blocked waiting for lock, etc), because it's based on kernel scheduler ETW events, which will occur whenever an thread blocks. Blocking shows up as red in the UI.

Now, a lot of these locks including SRW will often spin for a while before waiting, in case of contention; and often times the lock can be acquired after spinning without need to block (exactly the intention of spinning). In this case, since there is no block, the tool then cannot know that spinning (very short contention) occurred.

Hope this answers your question.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top