bpo-40521: Disable free lists in subinterpreters (GH-19937)

When Python is built with experimental isolated interpreters, disable
tuple, dict and free free lists.

Temporary workaround until these caches are made per-interpreter.

Add frame_alloc() and frame_get_builtins() subfunctions to simplify
_PyFrame_New_NoTrack().
This commit is contained in:
Victor Stinner 2020-05-05 19:55:29 +02:00 committed by GitHub
parent ac4bf42411
commit b4b53868d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 168 additions and 86 deletions

View file

@ -22,6 +22,12 @@ class tuple "PyTupleObject *" "&PyTuple_Type"
#define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */
#endif
/* bpo-40521: tuple free lists are shared by all interpreters. */
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
# undef PyTuple_MAXSAVESIZE
# define PyTuple_MAXSAVESIZE 0
#endif
#if PyTuple_MAXSAVESIZE > 0
/* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty
tuple () of which at most one instance will be allocated.
@ -248,7 +254,9 @@ tupledealloc(PyTupleObject *op)
#endif
}
Py_TYPE(op)->tp_free((PyObject *)op);
#if PyTuple_MAXSAVESIZE > 0
done:
#endif
Py_TRASHCAN_END
}