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

Created on 2021-10-19 11:06 by christian.heimes, last changed 2021-10-29 09:00 by christian.heimes. This issue is now closed.

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 (4)
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?
History
Date User Action Args
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