Skip to content

Commit e12729e

Browse files
committed
Strip out instrumentation
1 parent bd94999 commit e12729e

File tree

7 files changed

+1
-45
lines changed

7 files changed

+1
-45
lines changed

Include/cpython/pystate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ struct _ts {
192192

193193
uint64_t dict_global_version;
194194

195-
int sp_cached;
196-
int in_gc;
197195
};
198196

199197
#ifdef Py_DEBUG

Include/internal/pycore_frame.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static inline PyObject**
164164
_PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
165165
{
166166
assert(frame->stacktop >= 0);
167-
PyThreadState_GET()->sp_cached++;
168167
PyObject **sp = frame->localsplus + frame->stacktop;
169168
frame->stacktop = -1;
170169
return sp;
@@ -174,7 +173,6 @@ static inline void
174173
_PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer)
175174
{
176175
assert(frame->stacktop == -1);
177-
PyThreadState_GET()->sp_cached--;
178176
frame->stacktop = (int)(stack_pointer - frame->localsplus);
179177
}
180178

Include/object.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,6 @@ PyAPI_FUNC(void) Py_DecRef(PyObject *);
789789
PyAPI_FUNC(void) _Py_IncRef(PyObject *);
790790
PyAPI_FUNC(void) _Py_DecRef(PyObject *);
791791

792-
PyAPI_FUNC(int) PyThreadState_GetSpCached(void);
793-
794792
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
795793
{
796794
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
@@ -925,9 +923,6 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
925923
if (op->ob_refcnt <= 0) {
926924
_Py_NegativeRefcount(filename, lineno, op);
927925
}
928-
if (PyThreadState_GetSpCached() == 0) {
929-
UPDATE_DEFERRED_STATS();
930-
}
931926
if (_Py_IsImmortal(op)) {
932927
return;
933928
}
@@ -944,9 +939,6 @@ static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
944939
{
945940
// Non-limited C API and limited C API for Python 3.9 and older access
946941
// directly PyObject.ob_refcnt.
947-
if (PyThreadState_GetSpCached() == 0) {
948-
UPDATE_DEFERRED_STATS();
949-
}
950942
if (_Py_IsImmortal(op)) {
951943
return;
952944
}

Objects/object.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,31 +2822,13 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
28222822

28232823
Py_FatalError("_PyObject_AssertFailed");
28242824
}
2825-
2826-
size_t size_guess(PyObject *op)
2827-
{
2828-
size_t res = Py_TYPE(op)->tp_basicsize;
2829-
size_t isize = Py_TYPE(op)->tp_itemsize;
2830-
2831-
if (isize > 0) {
2832-
size_t count = _PyVarObject_CAST(op)->ob_size;
2833-
if (Py_TYPE(op) == &PyLong_Type) {
2834-
count >>= 3;
2835-
}
2836-
if (count < 100000000) {
2837-
res += count * isize;
2838-
}
2839-
}
2840-
return res;
2841-
}
2842-
28432825
void
28442826
_Py_Dealloc(PyObject *op)
28452827
{
28462828
PyTypeObject *type = Py_TYPE(op);
28472829
destructor dealloc = type->tp_dealloc;
2848-
PyThreadState *tstate = _PyThreadState_GET();
28492830
#ifdef Py_DEBUG
2831+
PyThreadState *tstate = _PyThreadState_GET();
28502832
PyObject *old_exc = tstate != NULL ? tstate->current_exception : NULL;
28512833
// Keep the old exception type alive to prevent undefined behavior
28522834
// on (tstate->curexc_type != old_exc_type) below
@@ -2865,13 +2847,7 @@ _Py_Dealloc(PyObject *op)
28652847
_Py_ForgetReference(op);
28662848
#endif
28672849

2868-
if (tstate->sp_cached && tstate->in_gc == 0) {
2869-
OBJECT_STAT_ADD(deferred_space, size_guess(op));
2870-
OBJECT_STAT_INC(deferred_objects);
2871-
}
2872-
tstate->in_gc++;
28732850
(*dealloc)(op);
2874-
tstate->in_gc--;
28752851

28762852
#ifdef Py_DEBUG
28772853
// gh-89373: The tp_dealloc function must leave the current exception

Python/ceval.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
765765

766766
next_instr = frame->instr_ptr;
767767
resume_frame:
768-
// assert(tstate->sp_cached == 0 || tstate->in_gc);
769768
stack_pointer = _PyFrame_GetStackPointer(frame);
770769

771770
#ifdef LLTRACE

Python/pystate.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,6 @@ init_threadstate(_PyThreadStateImpl *_tstate,
15081508
tstate->state = _Py_THREAD_SUSPENDED;
15091509
}
15101510

1511-
tstate->sp_cached = 0;
1512-
tstate->in_gc = 0;
15131511
tstate->_status.initialized = 1;
15141512
}
15151513

@@ -3091,7 +3089,3 @@ _PyThreadState_ClearMimallocHeaps(PyThreadState *tstate)
30913089
}
30923090
#endif
30933091
}
3094-
3095-
int PyThreadState_GetSpCached(void) {
3096-
return _PyThreadState_GET()->sp_cached;
3097-
}

Python/specialize.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ print_stats(FILE *out, PyStats *stats)
315315
print_optimization_stats(out, &stats->optimization_stats);
316316
#endif
317317
print_rare_event_stats(out, &stats->rare_event_stats);
318-
fprintf(out, "sp cached: %d", PyThreadState_GET()->sp_cached);
319318
}
320319

321320
void

0 commit comments

Comments
 (0)