Ask a Developer: Do I Need a Profiling Tool?

Have a development question and can’t find the answer? In our Ask a Dev column, a developer from Sentry will answer your questions about languages, frameworks, testing, performance monitoring or whatever topic is on your mind. To submit a question, email: askadeveloper@sentry.io.
Question:
I’m already familiar with writing performance tests as part of the development cycle and am unsure whether Profiling will provide further benefit. What are the reasons to profile in production rather than just writing performance tests?
Answer:
Performance tests are great for validating potential performance problems before you ship code, but they have some downsides:
- Writing performance tests that run in CI and deliver consistent, reliable results is challenging as performance depends on many factors such as network, thermal throttling, etc., that are difficult to control.
- Performance tests need to exercise many possible code paths in your application, and reproducing all possible code paths can be impractical.
- Performance tests often only run in a single environment, whereas your users will be running your application in many different environments where factors like latency and computing power are not the same.
In contrast, continuous profiling or production profiling runs in production (as its name suggests) rather than in an artificial testing environment. This means that it can analyze the performance of all possible code paths and real environments that your application may run in. This provides extensive coverage without investment in writing and maintaining performance tests.
That all sounds great, but what’s the catch? Profiling introduces some runtime overhead to your application; typically, the overhead is small, as the profiler is designed to run in production with minimal user-perceptible impact.