8000 PEP 683: Immortal Objects v3 by ericsnowcurrently · Pull Request #2372 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

PEP 683: Immortal Objects v3 #2372

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

Merged
merged 26 commits into from
Mar 1, 2022
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3fe96eb
Update the post history.
ericsnowcurrently Feb 26, 2022
6771a73
Expand the abstract.
ericsnowcurrently Feb 26, 2022
dd3861d
Be a little less specific.
ericsnowcurrently Feb 26, 2022
3785039
Drop the old scope section.
ericsnowcurrently Feb 26, 2022
c84919d
Update the performance numbers.
ericsnowcurrently Feb 26, 2022
bf8257e
Elaborate on refcounts and accidental immortality.
ericsnowcurrently Feb 26, 2022
407efc0
Clarify how the PEP supports immutability rather than enforcing it.
ericsnowcurrently Feb 28, 2022
7631bdf
Clarify about the refcount 1.
ericsnowcurrently Feb 28, 2022
d171a3c
Clarify about the immortal bit.
ericsnowcurrently Feb 28, 2022
b27fbcb
Drop some explanation about immortal global objects.
ericsnowcurrently Feb 28, 2022
a0b9d04
Relate cleanup to performance.
ericsnowcurrently Feb 28, 2022
7666c66
Add a note about __del__ and weakrefs.
ericsnowcurrently Feb 28, 2022
365ef60
Drop an open question.
ericsnowcurrently Feb 28, 2022
fb490f9
Add a note about GC.
ericsnowcurrently Feb 28, 2022
34de9b5
Outline solutions to accidental de-immortalizing.
ericsnowcurrently Feb 28, 2022
7f5052b
Update the post history.
ericsnowcurrently Feb 28, 2022
4f1e4fb
Collapse the abstract.
ericsnowcurrently Feb 28, 2022
2772517
Tweak the scope section.
ericsnowcurrently Feb 28, 2022
baa1947
lint
ericsnowcurrently Feb 28, 2022
a6d07a4
Fix a typo.
ericsnowcurrently Feb 28, 2022
5b2fe45
Fix a typo.
ericsnowcurrently Feb 28, 2022
8188ae5
Fix a typo.
ericsnowcurrently Feb 28, 2022
db478a9
Fix the post history.
ericsnowcurrently Feb 28, 2022
f6bab1d
Update the magic bit in examples.
ericsnowcurrently Feb 28, 2022
c8a2d41
Clarify an exmaple.
ericsnowcurrently Feb 28, 2022
4ed4d44
Drop an outdated note.
ericsnowcurrently Mar 1, 2022
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
Update the magic bit in examples.
  • Loading branch information
ericsnowcurrently committed Feb 28, 2022
commit f6bab1d541bef8e1980cc3e4840c4ae48f6f8155
16 changes: 8 additions & 8 deletions pep-0683.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ That means it would accidentally never be cleaned up
On 64-bit builds, this accidental scenario is so unlikely that we need
not worry. Even if done deliberately by using ``Py_INCREF()`` in a
tight loop and each iteration only took 1 CPU cycle, it would take
2^60 cycles (on a 64-bit processor). At a fast 5 GHz that would
2^60 cycles (if the immortal bit were 2^60). At a fast 5 GHz that would
still take nearly 250,000,000 seconds (over 2,500 days)!

Also note that it is doubly unlikely to be a problem because it wouldn't
Expand All @@ -275,11 +275,11 @@ same thing could be done efficiently using ``Py_SET_REFCNT()`` though
that would be even less of an accident.) At that point we don't
consider it a concern of this proposal.

On 32-bit builds it isn't so obvious. The magic refcount would be 2^28.
Using the same specs as above, it would take roughly 1 second to
accidentally immortalize an object. Under reasonable conditions, it
is still highly unlikely that an object be accidentally immortalized.
It would have to meet these criteria:
On 32-bit builds it isn't so obvious. Let's say the magic refcount
were 2^30. Using the same specs as above, it would take roughly
4 seconds to accidentally immortalize an object. Under reasonable
conditions, it is still highly unlikely that an object be accidentally
immortalized. It would have to meet these criteria:

* targeting a non-immortal object (so not one of the high-use builtins)
* the extension increfs without a corresponding decref
Expand All @@ -288,7 +288,7 @@ It would have to meet these criteria:

Under those conditions it would reach accidental immortality (on 32-bit)
in, at most, a year if it averaged at least one of those increfs every
158 seconds on that hypothetical workstation. Of course, then it would
40 seconds on that hypothetical workstation. Of course, then it would
have to run through the same number of (now noop-ing) decrefs before
that one object would be effectively leaking. This is highly unlikely,
especially because we assume no decrefs.
Expand Down Expand Up @@ -552,7 +552,7 @@ _Py_IMMORTAL_REFCNT

We will add two internal constants::

_Py_IMMORTAL_BIT - has the top-most available bit set
_Py_IMMORTAL_BIT - has the top-most available bit set (e.g. 2^62)
_Py_IMMORTAL_REFCNT - has the two top-most available bits set

The actual top-most bit depends on existing uses for refcount bits,
Expand Down
0