Skip to content

gh-111968: Use per-thread slice_cache in free-threading#113972

Merged
corona10 merged 2 commits into
python:mainfrom
corona10:gh-111968-slice
Jan 15, 2024
Merged

gh-111968: Use per-thread slice_cache in free-threading#113972
corona10 merged 2 commits into
python:mainfrom
corona10:gh-111968-slice

Conversation

@corona10

@corona10 corona10 commented Jan 12, 2024

Copy link
Copy Markdown
Member

@corona10 corona10 changed the title gh-111968: Use per-thread slice_cahce in free-threading gh-111968: Use per-thread slice_cache in free-threading Jan 12, 2024
struct _Py_tuple_state tuple_state;
struct _Py_list_state list_state;
struct _Py_slice_state slice_state;
} _PyFreeListState;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland @colesbury
IMO, we should rename _PyFreeListState if we consider slice_cache is not freelist :)
Do you have any good suggestion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically a freelist of max-length 1 🤷

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, let's maintain the current naming. (Changing is quite stressful)

Comment thread Objects/sliceobject.c
}

void _PySlice_Fini(PyInterpreterState *interp)
void _PySlice_Fini(_PyFreeListState *state)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to _PySlice_ClearCache. Do we need both functions? If you want to keep both names, maybe have one call the other.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep both names; I don't want to confuse people who work on the default build.

struct _Py_tuple_state tuple_state;
struct _Py_list_state list_state;
struct _Py_slice_state slice_state;
} _PyFreeListState;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically a freelist of max-length 1 🤷

@corona10
corona10 requested a review from colesbury January 12, 2024 16:54
@erlend-aasland

Copy link
Copy Markdown
Contributor

I'll defer to Sam; please take his comments into account :)

@corona10
corona10 merged commit 3eae765 into python:main Jan 15, 2024
@corona10
corona10 deleted the gh-111968-slice branch January 15, 2024 15:39
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants