New Python Recommendations: Debug and PGO Builds
New recommendations for Python, regarding debug and PGO builds
Blackfire Recommendations give you instant insights and suggestions from the profiles of your application. These suggestions may be performance, quality, or security advice, and we constantly add more of them for all supported languages, including Python.
Lately, we added 2 important recommendations for Python:
- When a debug build of Python is used in production;
- Suggestion to use a PGO build.
Debug Build of Python
A debug build of Python may be substantially slower due to various hooks added to the memory allocator and the disablement of compiler optimizations.
Therefore, it is not recommended to use such a build in production.
You can check if your Python interpreter was compiled in debug mode using the following command:
python -c "import sysconfig; print(bool(sysconfig.get_config_var('Py_DEBUG')))"
Profile Guided Optimization (PGO) build of Python
PGO builds are known to be faster than regular ones (~10 to 20% faster). As such, it is always recommended to use such builds in production.
Most Operating Systems come with PGO enabled binaries, but there might be some exceptions (e.g., Ubuntu as of 2021, macOS…).
You can check if your Python interpreter is compiled with PGO using the following command:
python -c "import sysconfig; print('-fprofile-use' in (sysconfig.get_config_var('PY_CFLAGS') + sysconfig.get_config_var('PY_CFLAGS_NODIST')))"
Profiles and Recommendations Triggered Automatically
Recommendations are extracted from the profiles of your application, which you may trigger on-demand using our browser extension (for Chrome or Firefox), or the CLI command. But what if they could be triggered automatically?
Blackfire Monitoring makes it a reality, as it automatically triggers profiles on the most impactful transactions every day! As such, with Blackfire Monitoring enabled on your production servers, you don’t even need to think about triggering a profile, as Blackfire does it for you. As for recommendations, if any are detected, they would appear on your Health Report dashboard.
Give Blackfire a Try
Recommendations are available for all paid plans (Profiler, Premium, and Enterprise plans).
Play with the demo or subscribe now!
Happy Performance Optimization 🐍!