Company
Date Published
Author
Tony Xiao
Word count
1034
Language
English
Hacker News points
None

Summary

The Sentry team has announced the alpha release of Python profiling for WSGI applications, which provides code-level insights into application performance in production. The profiling tool is free to use while in alpha and allows developers to set a sampling rate on the SDK. To get started with Python profiling, simply set the `profiles_sample_rate` parameter when initializing the Sentry SDK. The profiling tool captures samples at a frequency of ~100Hz and sends them to Sentry for visualization as flame graphs. Flame graphs enable users to quickly spot hot code paths and optimize resource consumption. The Sentry team has also optimized their own application using Python profiling, identifying performance bottlenecks such as parsing dates in the `zerofill` function, which was improved by switching to a faster date parsing method. Additionally, the team identified an issue with Django's prefetch_related technique causing slow queries, which they were able to optimize by manually fetching related objects and constructing the response. The Sentry team emphasizes that profiling complements performance by providing detailed line-level information to fix performance issues.