Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining thread performance

On some machines, my .Net application is idling at ~10% CPU usage. My first inclination is that one of my background worker threads is executing some instructions that I'm not aware of, but I don't know how to isolate CPU usage by thread (Task Manager simply tells me that my process uses x number of threads [usually around 30], not which threads are hogging CPU).

I know that programmatically I can iterate through the threads as mentioned in this post but I don't know if that will give me the information I need. Is there a profiler (commercial or otherwise) that will allow me analyze CPU usage per thread?

like image 591
Devin Avatar asked Jul 24 '12 15:07

Devin


People also ask

What determines single thread performance?

What all this leads to is this: Single thread performance depends on the application and the data set - there is no "one size fits all" result. This should not be a surprise, it's essentially very much the same in any other benchmarking exercise.

How do you determine optimal number of threads?

Ideally the total thread count for all the jobs should be the number of cores of the system, except on systems that support hyper-threading, in which it should be twice the number of cores. So if the system doesn't have hyper-threading, there are 8 calculations running, each should run in one thread.

How many threads can run on a single core?

A single CPU core can have up-to 2 threads per core. For example, if a CPU is dual core (i.e., 2 cores) it will have 4 threads.

Does more threads mean faster?

A larger number of threads or cores means that more tasks can be completed at the same time, but this does not mean that those tasks will complete faster. The more threads and cores, the better! The more you have, the faster your computer will be. This is because tasks can be split up and processed in parallel.


2 Answers

I would recommend JetTrace dotTrace Performance. It will tell you where your code is spending most of its time, as well as the thread. (It is commercial but comes with a free 10 day trial.)

like image 83
NominSim Avatar answered Sep 19 '22 23:09

NominSim


Try Perfview from Microsoft: http://www.microsoft.com/en-us/download/details.aspx?id=28567

You can use system ETW events to figure out lots of low CPU utilization issues.

like image 33
Feng Yuan Avatar answered Sep 20 '22 23:09

Feng Yuan