You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG).
Instead of adding _Py_IsImmortal check to PyStackRef_FromPyObjectSteal for FT builds as in #141675, we make no checks at all in this function.
As a result, immortal objects will be DECREF'ed with no effect at reference closing.
This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG). Instead of adding _Py_IsImmortal check to PyStackRef_FromPyObjectSteal for FR builds as in #141675, we make no checks at all in this function. As a result, immortal objects will be DECREF'ed with no effect at reference closing.
We can't rely on Py_DECREF to do the immortal check, as that is more expensive than simply checking a bit on a pointer. You have to do an atomic read of memory now.
We can't rely on Py_DECREF to do the immortal check, as that is more expensive than simply checking a bit on a pointer. You have to do an atomic read of memory now.
It seems that I'm not quite understand, when we will do additional atomic reads.
Do you mean FT builds? For those nothing changes since Py_DECREF_MORTAL is Py_DECREF on them.
And there's no atomic reads at Py_DECREF on GIL builds.
We can't rely on Py_DECREF to do the immortal check, as that is more expensive than simply checking a bit on a pointer. You have to do an atomic read of memory now.
Actually for immortal check, only ob_ref_local is read with relaxed order so it will get compiled to plain load. That will still be more instructions executed that checking a single bit though.
I like the idea of merging the two implementations, but why choose the slower scheme, not the faster one?
AFAICT, the FT variant has an extra memory access for the immortality check when doing a CLOSE or DUP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG).
Instead of adding
_Py_IsImmortalcheck toPyStackRef_FromPyObjectStealfor FT builds as in #141675, we make no checks at all in this function.As a result, immortal objects will be DECREF'ed with no effect at reference closing.
PyStackReffunctions #139716