This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Allow to build Python without freelists
Type: enhancement Stage: resolved
Components: C API Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: Mark.Shannon, christian.heimes, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2021-10-19 11:06 by christian.heimes, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 29056 merged christian.heimes, 2021-10-19 11:21
PR 29086 closed christian.heimes, 2021-10-20 07:16
Messages (6)
msg404289 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-10-19 11:06
Freelists are an optimization trick to avoid allocation and deallocation of commonly used structures. Currently Python has freelists for frame, tuple, float, list, dict, async generators, and context objects. Small ints are also cached.

For experimentation with alternative memory allocators such as mimalloc, I would like to introduce a way to disable freelists. Tuples's _Py_tuple_state struct has a conditional check on #if PyTuple_MAXSAVESIZE > 0. I propose to add same logic to all other structs.
msg404599 - (view) Author: miss-islington (miss-islington) Date: 2021-10-21 13:12
New changeset 9942f42a93ccda047fd3558c47b822e99afe10c0 by Christian Heimes in branch 'main':
bpo-45522: Allow to disable freelists on build time (GH-29056)
https://github.com/python/cpython/commit/9942f42a93ccda047fd3558c47b822e99afe10c0
msg405207 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-10-28 17:25
I think we should revert this. It just makes working with freelists more cumbersome. Having more configure options just makes it more likely that we will fail to test some configuration.

If you want to disable freelists in your experiments, feel free to do so, but it doesn't need to be in main, IMO.
msg405293 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-10-29 09:00
Which part of the patch is causing you extra work? Would you be fine if I only remove the configure option and leave the fixes for zero-length freelists (#define PyList_MAXFREELIST 0) in?
msg410614 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-01-15 00:36
> Freelists for object structs can now be disabled. A new configure option --without-freelists can be used to disable all freelists except empty tuple singleton. (Contributed by Christian Heimes in bpo-45522)

Can you please document the new configuration option in https://docs.python.org/dev/using/configure.html ?

When you write :option:`--without-freelists` in what's new in Python 3.11 to get a link ;-)
msg410778 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-01-17 13:14
I reopen the issue to not forget to complete the doc.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89685
2022-01-17 13:14:15vstinnersetstatus: closed -> open
resolution: fixed ->
messages: + msg410778
2022-01-15 00:36:22vstinnersetnosy: + vstinner
messages: + msg410614
2021-10-29 09:00:25christian.heimessetmessages: + msg405293
2021-10-28 17:25:05Mark.Shannonsetnosy: + Mark.Shannon
messages: + msg405207
2021-10-21 13:12:53christian.heimessetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-10-21 13:12:29miss-islingtonsetnosy: + miss-islington
messages: + msg404599
2021-10-20 07:16:00christian.heimessetpull_requests: + pull_request27352
2021-10-19 11:21:45christian.heimessetkeywords: + patch
pull_requests: + pull_request27327
2021-10-19 11:06:04christian.heimescreate