Skip to content
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

[WIP] bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters #19958

Closed
wants to merge 1 commit into from

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented May 6, 2020

When Python is built with experimental isolated interpreters, declare
PyObject.ob_refcnt and _dictkeysobject.dk_refcnt as atomic variables.

Temporary workaround until subinterpreters stop sharing Python
objects.

https://bugs.python.org/issue40533

When Python is built with experimental isolated interpreters, declare
PyObject.ob_refcnt and _dictkeysobject.dk_refcnt as atomic variables.

Temporary workaround until subinterpreters stop sharing Python
objects.
@vstinner
Copy link
Member Author

@vstinner vstinner commented May 6, 2020

@aeros
Copy link
Member

@aeros aeros commented May 6, 2020

Based on the discussion at https://mail.python.org/archives/list/python-committers@python.org/thread/2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY/#2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY, I think we should leave a DO-NOT-MERGE label until the 3.9 branch is created.

@vstinner vstinner marked this pull request as draft May 6, 2020
@vstinner
Copy link
Member Author

@vstinner vstinner commented May 6, 2020

Based on the discussion at https://mail.python.org/archives/list/python-committers@python.org/thread/2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY/#2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY, I think we should leave a DO-NOT-MERGE label until the 3.9 branch is created.

Right, thanks. I converted this PR into a draft to ensure that nobody merges it by mistake.

@vstinner vstinner changed the title bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters [WIP] bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters May 6, 2020
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
/* bpo-40533: Use an atomic variable for PyObject.ob_refcnt, to ensure that
Py_INCREF() and Py_DECREF() are safe when called in parallel, until
subinterpreters stop sharing Python objects. */
_Atomic Py_ssize_t ob_refcnt;
Copy link
Member

@aeros aeros May 6, 2020

Choose a reason for hiding this comment

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

Perhaps this is somewhat emphasized by the "experimental" part, but could we possibly make it a bit more crystal clear that this is only a temporary stopgap measure? I personally find that "until subinterpreters stop sharing Python objects" could be interpreted as a near indefinite amount of time; I'm not confident that most readers will go over the full context in the bpo issue and related discussions.

Normally, this wouldn't be a huge concern, but I think object.h is likely one of the most public-facing header files in CPython, so it seems important to communicate this as clearly as possible.

@vstinner
Copy link
Member Author

@vstinner vstinner commented Mar 17, 2021

The current plan is to not share any object between two interpreters, so this PR is not needed. I close it.

@vstinner vstinner closed this Mar 17, 2021
@vstinner vstinner deleted the atomic_refcnt branch Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants