Diagnosing High CPU in Visual Studio
Diagnosing High CPU in Visual Studio
Ever had a high CPU?
In Visual Studio (VS), turn on symbols - Tools > Options > Debugging > Symbols, if you have some of the "hot path" being in external library calls:
In Visual Studio, turn on "Release Mode". I have had programs that show 9% CPU on local in Debug mode, while showing 50% when in Release mode.:
Debug > Performance Profiler > click the "CPU Usage" > "Start" button:
After starts and you press "Stop", then VS analyzes the results:
Then after further exploration, expand or show hot path:
To diagnosis the potential problem when you made new version of program:
1) Compare numbers of the old and new versions of the program on the same box.
To diagnosis the potential problem when a particular box has high CPU and the other does not:
1) Remember to compare the processors and their RAM using web sites such as https://www.cpu-monkey.com/ .
2) Look at Network and Disk use by the program. (You will need to probably use the Resource Monitor if the problem system is a server).
Potential fixes for high CPU are:
1) Caching things that rarely change such as closed stores. (See Caching blog entry elsewhere in this blog).
To reduce high CPU, remember that:
1) Parallel programming is great for CPU-bound tasks by leveraging multiple cores
2) Asynchronous programming shines in I/O-bound operations, optimizing resource utilization.
So do more Parallel programming.
Comments
Post a Comment