Skip to content

Commit 0a50860

Browse files
committed
Remove deferred RC stats
1 parent f748355 commit 0a50860

File tree

13 files changed

+12
-32
lines changed

13 files changed

+12
-32
lines changed

Include/cpython/pystate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ struct _ts {
191191
PyObject *previous_executor;
192192

193193
uint64_t dict_global_version;
194+
int sp_cached; /* Only used in debug builds */
194195

195196
};
196197

Include/cpython/pystats.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@ typedef struct _object_stats {
8787
uint64_t type_cache_dunder_hits;
8888
uint64_t type_cache_dunder_misses;
8989
uint64_t type_cache_collisions;
90-
uint64_t max_deferred_space;
91-
uint64_t max_deferred_objects;
9290
/* Temporary value used during GC */
9391
uint64_t object_visits;
94-
uint64_t deferred_space;
95-
uint64_t deferred_objects;
9692
} ObjectStats;
9793

9894
typedef struct _gc_stats {
@@ -171,18 +167,3 @@ PyAPI_DATA(PyStats*) _Py_stats;
171167
# define _Py_INCREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.increfs++; } while (0)
172168
# define _Py_DECREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.decrefs++; } while (0)
173169
#endif
174-
175-
176-
#define UPDATE_DEFERRED_STATS() \
177-
do { \
178-
if (_Py_stats) { \
179-
if (_Py_stats->object_stats.deferred_space > _Py_stats->object_stats.max_deferred_space) { \
180-
_Py_stats->object_stats.max_deferred_space = _Py_stats->object_stats.deferred_space; \
181-
} \
182-
if (_Py_stats->object_stats.deferred_objects > _Py_stats->object_stats.max_deferred_objects) { \
183-
_Py_stats->object_stats.max_deferred_objects = _Py_stats->object_stats.deferred_objects; \
184-
} \
185-
_Py_stats->object_stats.deferred_space = 0; \
186-
_Py_stats->object_stats.deferred_objects = 0; \
187-
} \
188-
} while (0)

Include/internal/pycore_code.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
356356
#define OPT_ERROR_IN_OPCODE(opname) ((void)0)
357357
#define OPT_HIST(length, name) ((void)0)
358358
#define RARE_EVENT_STAT_INC(name) ((void)0)
359-
#define UPDATE_DEFERRED_STATS() ((void)0)
360359
#endif // !Py_STATS
361360

362361
// Utility functions for reading/writing 32/64-bit values in the inline caches.

Include/internal/pycore_frame.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
165165
static inline PyObject**
166166
_PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
167167
{
168+
#ifndef Py_DEBUG
169+
PyThreadState_GET()->sp_cached++;
170+
#endif
168171
assert(frame->stackpointer != NULL);
169172
PyObject **sp = frame->stackpointer;
170173
frame->stackpointer = NULL;
@@ -174,6 +177,9 @@ _PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
174177
static inline void
175178
_PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer)
176179
{
180+
#ifndef Py_DEBUG
181+
PyThreadState_GET()->sp_cached--;
182+
#endif
177183
assert(frame->stackpointer == NULL);
178184
frame->stackpointer = stack_pointer;
179185
}

Include/pystats.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern "C" {
1818
#else
1919
# define _Py_INCREF_STAT_INC() ((void)0)
2020
# define _Py_DECREF_STAT_INC() ((void)0)
21-
# define UPDATE_DEFERRED_STATS() ((void)0)
2221
#endif // !Py_STATS
2322

2423
#ifdef __cplusplus

Lib/test/test_sys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ class C(object): pass
15611561
def func():
15621562
return sys._getframe()
15631563
x = func()
1564-
check(x, size('3Pi2cP7P2ic??2P'))
1564+
check(x, size('3Pi2cP9Phc2P'))
15651565
# function
15661566
def func(): pass
15671567
check(func, size('16Pi'))
@@ -1578,7 +1578,7 @@ def bar(cls):
15781578
check(bar, size('PP'))
15791579
# generator
15801580
def get_gen(): yield 1
1581-
check(get_gen(), size('PP4P4c7P2ic??2P'))
1581+
check(get_gen(), size('PP4P4cP9PhcP'))
15821582
# iterator
15831583
check(iter('abc'), size('lP'))
15841584
# callable-iterator

Objects/object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,7 @@ _Py_Dealloc(PyObject *op)
28292829
destructor dealloc = type->tp_dealloc;
28302830
#ifdef Py_DEBUG
28312831
PyThreadState *tstate = _PyThreadState_GET();
2832+
assert(tstate->sp_cached <= 1);
28322833
PyObject *old_exc = tstate != NULL ? tstate->current_exception : NULL;
28332834
// Keep the old exception type alive to prevent undefined behavior
28342835
// on (tstate->curexc_type != old_exc_type) below

Python/bytecodes.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ dummy_func(
184184
uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker);
185185
uintptr_t version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
186186
assert((version & _PY_EVAL_EVENTS_MASK) == 0);
187-
UPDATE_DEFERRED_STATS();
188187
DEOPT_IF(eval_breaker != version);
189188
}
190189

Python/ceval_macros.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ do { \
143143
if (err != 0) { \
144144
GOTO_ERROR(error); \
145145
} \
146-
} \
147-
UPDATE_DEFERRED_STATS();
146+
}
148147

149148

150149
/* Tuple access macros */

Python/executor_cases.c.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/pystate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ init_threadstate(_PyThreadStateImpl *_tstate,
14981498
tstate->what_event = -1;
14991499
tstate->previous_executor = NULL;
15001500
tstate->dict_global_version = 0;
1501+
tstate->sp_cached = 0;
15011502

15021503
tstate->delete_later = NULL;
15031504

Python/specialize.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ print_object_stats(FILE *out, ObjectStats *stats)
203203
fprintf(out, "Object method cache collisions: %" PRIu64 "\n", stats->type_cache_collisions);
204204
fprintf(out, "Object method cache dunder hits: %" PRIu64 "\n", stats->type_cache_dunder_hits);
205205
fprintf(out, "Object method cache dunder misses: %" PRIu64 "\n", stats->type_cache_dunder_misses);
206-
fprintf(out, "Object max deferred objects: %" PRIu64 "\n", stats->max_deferred_objects);
207-
fprintf(out, "Object max deferred space: %" PRIu64 "\n", stats->max_deferred_space);
208206
}
209207

210208
static void
@@ -321,8 +319,6 @@ void
321319
_Py_StatsOn(void)
322320
{
323321
_Py_stats = &_Py_stats_struct;
324-
_Py_stats->object_stats.deferred_objects = 0;
325-
_Py_stats->object_stats.deferred_space = 0;
326322
}
327323

328324
void

0 commit comments

Comments
 (0)