8000 gh-126703: Add freelists for small size lists by eendebakpt · Pull Request #129921 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-126703: Add freelists for small size lists #129921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comments
  • Loading branch information
eendebakpt committed Mar 4, 2025
commit 1feab3733f44f25b3b0ad9612006a26f472682ff
7 changes: 3 additions & 4 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,10 @@ _PyList_DebugMallocStats(FILE *out)
static inline int
maybe_small_list_freelist_push(PyObject *self)
{
// todo: in the resizing there are some alignments on the allocation. can we use that here?
assert(PyList_CheckExact(self));

PyListObject *op = (PyListObject *)self;
PyObject **ob_item = _Py_atomic_load_ptr(&op->ob_item);

Py_ssize_t allocated = op->allocated;
if (allocated < PyList_MAXSAVESIZE) {
return _Py_FREELIST_PUSH(small_lists[allocated], self, Py_small_lists_MAXFREELIST);
Expand Down Expand Up @@ -267,9 +266,9 @@ PyList_New(Py_ssize_t size)
//printf("obtained list from small_lists[%d] (id %p, op->allocated %d, size %d, PyList_Size %d)\n", (int) size, op, (int)op->allocated, (int)size, (int)PyList_Size( (PyObject*)op));
assert (op->allocated >= size);
}
op=0;
//op=0;
}
if (!op) {
if (op == NULL) {
// do we still need this freelist? if so, we could store it at small_lists[PyList_MAXSAVESIZE-1] with some special casing
op = _Py_FREELIST_POP(PyListObject, lists);
if (op == NULL) {
Expand Down
0