Finding bottlenecks
Finding bottlenecks is done by:
- Profiling CPU usage
- Profiling memory usage
- Profiling network usage
Profiling CPU usage
The first source of bottlenecks is your code. The standard library provides all the tools needed to perform code profiling. They are based on a deterministic approach.
A deterministic profiler measures the time spent in each function by adding a timer at the lowest level. This introduces a bit of overhead but provides a good idea on where the time is consumed. A statistical profiler, on the other hand, samples the instruction pointer usage and does not instrument the code. The latter is less accurate but allows running the target program at full speed.
There are two ways to profile the code:
- Macro-profiling: This profiles the whole program while it is being used and generates statistics
- Micro-profiling: This measures a precise part of the program by instrumenting it manually
Macro-profiling
Macro-profiling is done by running the application in a special mode where...