getsentry / getsentry/sentry-python

Investigate profiling with sys.monitoring/PEP 669

Open
#2,683 3 comments 3 reactions 0 assignees View on GitHub
Feature Profiles Python
Dominant language
Python
Stars
2.2k
Forks
669
Avg merge
1d 1h
Merged PRs (30d)
213

Description

### 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](https://peps.python.org/pep-0669/) and [sys.monitoring](https://docs.python.org/3/library/sys.monitoring.html), 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.