sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Investigate profiling with sys.monitoring/PEP 669

Open DragoonAethis opened this issue 1 year ago • 3 comments

Problem Statement

Sentry's built-in profiling is reasonably low-overhead, but it takes a snapshot of the app's stack every ~10ms. This can miss quite a lot of events. Before Python 3.12, implementing a more comprehensive profiler would tank performance and was absolutely cost-prohibitive in production.

Solution Brainstorm

But since 3.12 we have PEP 669 and sys.monitoring, a low(er)-overhead method of getting access to interpreter events. These allow informing a profiler whenever a new interpreter event happens in process. It'd be nice to investigate if this could be used for more granular Python profiling.

DragoonAethis avatar Jan 27 '24 12:01 DragoonAethis

Hey @DragoonAethis, thanks for the suggestion. sys.monitoring does indeed look interesting for 3.12+.

cc @Zylphrex

sentrivana avatar Jan 29 '24 09:01 sentrivana

Thanks for the suggestion. This is something on our radar but there are no definite timelines yet. 👍

Zylphrex avatar Jan 29 '24 15:01 Zylphrex

Sure! I don't expect anything about this, consider this ticket just as a tracker for interested people :)

DragoonAethis avatar Jan 29 '24 17:01 DragoonAethis