mirror of
https://github.com/python/cpython.git
synced 2025-09-23 00:43:12 +00:00
gh-111968: Use per-thread freelists for generator in free-threading (gh-114189)
This commit is contained in:
parent
2d3f6b56c5
commit
7fa511ba57
9 changed files with 48 additions and 74 deletions
|
@ -8,6 +8,8 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
#include "pycore_freelist.h"
|
||||
|
||||
extern PyObject *_PyGen_yf(PyGenObject *);
|
||||
extern void _PyGen_Finalize(PyObject *self);
|
||||
|
||||
|
@ -26,34 +28,7 @@ extern PyTypeObject _PyAsyncGenAThrow_Type;
|
|||
|
||||
/* runtime lifecycle */
|
||||
|
||||
extern void _PyAsyncGen_Fini(PyInterpreterState *);
|
||||
|
||||
|
||||
/* other API */
|
||||
|
||||
#ifndef WITH_FREELISTS
|
||||
// without freelists
|
||||
# define _PyAsyncGen_MAXFREELIST 0
|
||||
#endif
|
||||
|
||||
#ifndef _PyAsyncGen_MAXFREELIST
|
||||
# define _PyAsyncGen_MAXFREELIST 80
|
||||
#endif
|
||||
|
||||
struct _Py_async_gen_state {
|
||||
#if _PyAsyncGen_MAXFREELIST > 0
|
||||
/* Freelists boost performance 6-10%; they also reduce memory
|
||||
fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend
|
||||
are short-living objects that are instantiated for every
|
||||
__anext__() call. */
|
||||
struct _PyAsyncGenWrappedValue* value_freelist[_PyAsyncGen_MAXFREELIST];
|
||||
int value_numfree;
|
||||
|
||||
struct PyAsyncGenASend* asend_freelist[_PyAsyncGen_MAXFREELIST];
|
||||
int asend_numfree;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern void _PyAsyncGen_Fini(_PyFreeListState *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue