docs/sources/shared/intro/what-is-profiling.md
Profiling is a technique used in software development to measure and analyze the runtime behavior of a program. By profiling a program, developers can identify which parts of the program consume the most resources, such as CPU time, memory, or I/O operations. You can use this information to optimize the program, making it run faster or use fewer resources.
Pyroscope can be used for both traditional and continuous profiling.
Traditional profiling, often referred to as sample-based or instrumentation-based profiling, has its roots in the early days of computing. Back then, the primary challenge was understanding how a program utilized the limited computational resources available.
With sample-based profiling, the profiler interrupts the program at regular intervals, capturing the program's state each time. By analyzing these snapshots, developers can deduce the frequency at which parts of the code execute.
With instrumentation-based profiling, developers insert additional code into the program that records information about its execution. This approach provides detailed insights but can alter the program's behavior due to the added code overhead.
Traditional profiling provides:
As software systems grew in complexity and scale, the limitations of traditional profiling became evident. Issues could arise in production that weren't apparent during limited profiling sessions in the development or staging environments.
This led to the development of continuous profiling, a method where the profiling data is continuously collected in the background with minimal overhead. By doing so, developers gain a more comprehensive view of a program's behavior over time, helping to identify sporadic or long-term performance issues.
Continuous profiling provides:
In many modern development workflows, both methods are useful.
| Traditional profiling | Continuous profiling | |
|---|---|---|
| When to use | During development or testing phases | In production environments or during extended performance tests. |
| Advantages | Offers detailed insights that can target specific parts of code. | Provides a continuous view of system performance, often with minimal overhead, making it suitable for live environments. |
| Disadvantages | Higher overhead provides only a snapshot in time. | It might be less detailed than traditional profiling due to the need to minimize impact on the running system. |