Skip to content

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented May 3, 2024

This interns the strings for co_filename, co_name, and co_qualname on codeobjects in the free-threaded build. This partially addresses a reference counting bottleneck when creating closures concurrently. The functions take the name and qualified name from the code object.

This interns the strings for `co_filename`, `co_name`, and `co_qualname`
on codeobjects in the free-threaded build. This partially addresses a
reference counting bottleneck when creating closures concurrently. The
functions take the name and qualified name from the code object.
@colesbury
Copy link
Contributor Author

I think it would also be reasonable to internalize these strings in the default build, but I went with the more conservative option of limiting it to Py_GIL_DISABLED builds for now.

Copy link
Contributor

@DinoV DinoV left a comment

Choose a reason for hiding this comment

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

Intern all the things!

@colesbury colesbury merged commit 37c31be into python:main May 3, 2024
@colesbury colesbury deleted the gh-118527-code-names branch May 3, 2024 22:16
@brandtbucher
Copy link
Member

brandtbucher commented May 4, 2024

I think this made our generated files different for debug vs. non-debug normal vs free-threaded builds, since marshal serializes interned and non-interned strings differently.

SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
…python#118558)

This interns the strings for `co_filename`, `co_name`, and `co_qualname`
on codeobjects in the free-threaded build. This partially addresses a
reference counting bottleneck when creating closures concurrently. The
closures take the name and qualified name from the code object.
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