mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
GH-90081: Run python tracers at full speed (GH-95328) (#95363)
(cherry picked from commit b8b2990fb3
)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
f06f3656c5
commit
00566a8124
3 changed files with 12 additions and 6 deletions
|
@ -131,8 +131,9 @@ PyAPI_FUNC(void) _PyThreadState_DeleteExcept(
|
||||||
static inline void
|
static inline void
|
||||||
_PyThreadState_UpdateTracingState(PyThreadState *tstate)
|
_PyThreadState_UpdateTracingState(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
int use_tracing = (tstate->c_tracefunc != NULL
|
bool use_tracing =
|
||||||
|| tstate->c_profilefunc != NULL);
|
(tstate->tracing == 0) &&
|
||||||
|
(tstate->c_tracefunc != NULL || tstate->c_profilefunc != NULL);
|
||||||
tstate->cframe->use_tracing = (use_tracing ? 255 : 0);
|
tstate->cframe->use_tracing = (use_tracing ? 255 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Run Python code in tracer/profiler function at full speed. Fixes slowdown in
|
||||||
|
earlier versions of 3.11.
|
|
@ -5620,9 +5620,9 @@ handle_eval_breaker:
|
||||||
case DO_TRACING:
|
case DO_TRACING:
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (tstate->tracing == 0 &&
|
assert(cframe.use_tracing);
|
||||||
INSTR_OFFSET() >= frame->f_code->_co_firsttraceable
|
assert(tstate->tracing == 0);
|
||||||
) {
|
if (INSTR_OFFSET() >= frame->f_code->_co_firsttraceable) {
|
||||||
int instr_prev = _PyInterpreterFrame_LASTI(frame);
|
int instr_prev = _PyInterpreterFrame_LASTI(frame);
|
||||||
frame->prev_instr = next_instr;
|
frame->prev_instr = next_instr;
|
||||||
TRACING_NEXTOPARG();
|
TRACING_NEXTOPARG();
|
||||||
|
@ -6832,12 +6832,15 @@ void
|
||||||
PyThreadState_EnterTracing(PyThreadState *tstate)
|
PyThreadState_EnterTracing(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
tstate->tracing++;
|
tstate->tracing++;
|
||||||
|
tstate->cframe->use_tracing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyThreadState_LeaveTracing(PyThreadState *tstate)
|
PyThreadState_LeaveTracing(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
|
assert(tstate->tracing > 0 && tstate->cframe->use_tracing == 0);
|
||||||
tstate->tracing--;
|
tstate->tracing--;
|
||||||
|
_PyThreadState_UpdateTracingState(tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue