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?
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.
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.
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.
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.
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.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With