11/* Python's malloc wrappers (see pymem.h) */
22
33#include "Python.h"
4+ #include "pycore_ceval.h"
45#include "pycore_interp.h" // _PyInterpreterState_HasFeature
56#include "pycore_object.h" // _PyDebugAllocatorStats() definition
67#include "pycore_obmalloc.h"
@@ -1218,7 +1219,7 @@ should_advance_qsbr_for_free(struct _qsbr_thread_state *qsbr, size_t size)
12181219 if (size > QSBR_FREE_MEM_LIMIT ) {
12191220 qsbr -> deferred_count = 0 ;
12201221 qsbr -> deferred_memory = 0 ;
1221- qsbr -> should_process = true ;
1222+ _Py_set_eval_breaker_bit ( qsbr -> tstate , _PY_EVAL_PROCESS_DELAYED_BIT ) ;
12221223 return true;
12231224 }
12241225 qsbr -> deferred_count ++ ;
@@ -1227,7 +1228,7 @@ should_advance_qsbr_for_free(struct _qsbr_thread_state *qsbr, size_t size)
12271228 qsbr -> deferred_memory > QSBR_FREE_MEM_LIMIT ) {
12281229 qsbr -> deferred_count = 0 ;
12291230 qsbr -> deferred_memory = 0 ;
1230- qsbr -> should_process = true ;
1231+ _Py_set_eval_breaker_bit ( qsbr -> tstate , _PY_EVAL_PROCESS_DELAYED_BIT ) ;
12311232 return true;
12321233 }
12331234 return false;
@@ -1305,13 +1306,6 @@ free_delayed(uintptr_t ptr, size_t size)
13051306 buf -> array [buf -> wr_idx ].ptr = ptr ;
13061307 buf -> array [buf -> wr_idx ].qsbr_goal = seq ;
13071308 buf -> wr_idx ++ ;
1308-
1309- if (buf -> wr_idx == WORK_ITEMS_PER_CHUNK ) {
1310- // Normally the processing of delayed items is done from the eval
1311- // breaker. Processing here is a safety measure to ensure too much
1312- // work does not accumulate.
1313- _PyMem_ProcessDelayed ((PyThreadState * )tstate );
1314- }
13151309#endif
13161310}
13171311
@@ -1419,7 +1413,7 @@ _PyMem_ProcessDelayed(PyThreadState *tstate)
14191413 PyInterpreterState * interp = tstate -> interp ;
14201414 _PyThreadStateImpl * tstate_impl = (_PyThreadStateImpl * )tstate ;
14211415
1422- tstate_impl -> qsbr -> should_process = false ;
1416+ _Py_unset_eval_breaker_bit ( tstate , _PY_EVAL_PROCESS_DELAYED_BIT ) ;
14231417
14241418 // Process thread-local work
14251419 process_queue (& tstate_impl -> mem_free_queue , tstate_impl , true, NULL , NULL );
0 commit comments