gh-111968: Use per-thread slice_cache in free-threading (gh-113972)

This commit is contained in:
Donghee Na 2024-01-16 00:38:57 +09:00 committed by GitHub
parent 44e47dfba5
commit 3eae76554b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 18 deletions

View file

@ -59,10 +59,19 @@ struct _Py_float_state {
#endif
};
struct _Py_slice_state {
#ifdef WITH_FREELISTS
/* Using a cache is very effective since typically only a single slice is
created and then deleted again. */
PySliceObject *slice_cache;
#endif
};
typedef struct _Py_freelist_state {
struct _Py_float_state float_state;
struct _Py_tuple_state tuple_state;
struct _Py_list_state list_state;
struct _Py_slice_state slice_state;
} _PyFreeListState;
#ifdef __cplusplus

View file

@ -249,6 +249,7 @@ extern void _Py_ClearFreeLists(_PyFreeListState *state, int is_finalization);
extern void _PyTuple_ClearFreeList(_PyFreeListState *state, int is_finalization);
extern void _PyFloat_ClearFreeList(_PyFreeListState *state, int is_finalization);
extern void _PyList_ClearFreeList(_PyFreeListState *state, int is_finalization);
extern void _PySlice_ClearCache(_PyFreeListState *state);
extern void _PyDict_ClearFreeList(PyInterpreterState *interp);
extern void _PyAsyncGen_ClearFreeLists(PyInterpreterState *interp);
extern void _PyContext_ClearFreeList(PyInterpreterState *interp);

View file

@ -187,9 +187,6 @@ struct _is {
struct _Py_long_state long_state;
struct _dtoa_state dtoa;
struct _py_func_state func_state;
/* Using a cache is very effective since typically only a single slice is
created and then deleted again. */
PySliceObject *slice_cache;
struct _Py_tuple_state tuple;
struct _Py_dict_state dict_state;

View file

@ -11,7 +11,7 @@ extern "C" {
/* runtime lifecycle */
extern void _PySlice_Fini(PyInterpreterState *);
extern void _PySlice_Fini(_PyFreeListState *);
extern PyObject *
_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop);